Opening a file

5 views
Skip to first unread message

rajan kochhar

unread,
Jul 21, 2010, 1:38:50 AM7/21/10
to Google Web Toolkit
I am trying to read an excel file as follows:


public class LMSServiceImpl extends RemoteServiceServlet implements
LMSService{
public String getExcel(String path)
{
String r=null;
try {
File file = new File("D:/q.xls");
FileInputStream is = new FileInputStream(file);
Workbook workBook = Workbook.getWorkbook(is);
Sheet sheet = workBook.getSheet(0);
System.out.println("No of sheets="+workBook.getNumberOfSheets());
r=""+sheet.getRows();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return r;
}
}


I am getting an exception :

java.security.AccessControlException: access denied
(java.io.FilePermission D:\q.xls read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at com.google.appengine.tools.development.DevAppServerFactory
$CustomSecurityManager.checkPermission(DevAppServerFactory.java:166)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at com.cummins.lms.server.LMSServiceImpl.getExcel(LMSServiceImpl.java:
29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:
100)
at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
562)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:
188)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:
224)
at
com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:
62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:713)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
511)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1166)
at
com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:
51)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:
43)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:
122)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
388)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
182)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
418)
at
com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:
70)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at com.google.appengine.tools.development.JettyContainerService
$ApiProxyHandler.handle(JettyContainerService.java:349)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
542)
at org.mortbay.jetty.HttpConnection
$RequestHandler.content(HttpConnection.java:938)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:755)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
409)
at org.mortbay.thread.QueuedThreadPool
$PoolThread.run(QueuedThreadPool.java:582)

Can someone please help in how to access a local file.

Thanks

aditya sanas

unread,
Jul 21, 2010, 5:41:00 AM7/21/10
to google-we...@googlegroups.com
I think this must be a server side issue should not be posted here.

--
Aditya



--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Eric

unread,
Jul 21, 2010, 10:26:27 AM7/21/10
to Google Web Toolkit
The server application has no way of magically accessing client
files. Depending on how the web server is configured, it might not be
allowed to access files on the server itself. After all, the operators
of a web server might be hosting web applications from many different
sources. Those operators don't want these applications to interfere
with each other or the operations of the server itself. How is your
server configured?

I assume the file name D:/q.xls is a placeholder for something else;
otherwise, you could include it in your WAR file. If the real file
comes from your client, use an upload control and an upload handler.

Eric

cokol

unread,
Jul 21, 2010, 4:13:46 PM7/21/10
to Google Web Toolkit
hi actually, this is a question to googles appengine forum, appengine
implies many restriction, such as those, you cannot access the
filesystem, put the excel file into classpath and access the stream
via getResourceAsStream("foo.xls") from your classloader

br,
Reply all
Reply to author
Forward
0 new messages