File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes ServerletException - access denied Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "ServerletException - access denied " Watch "ServerletException - access denied " New topic
Author

ServerletException - access denied

Peter Bang
Greenhorn

Joined: Jun 23, 2006
Posts: 2
I have made a simple login/logout member administration system

I`m trying to register a member.
It works fine on my own computer with tomcat server,
but not on the actual website

It gives me an error below

Can anybody tell me why I`m having this error and how to fix it?
I think there is something wrong with server setting but not sure

========================================================================


Error: 500
Location: /jsp/member/register.jsp
Internal Servlet Error:

javax.servlet.ServletException: access denied (java.io.FilePermission /home/.sites/33/site5/web/WEB-INF/classes read)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:459)
at jsp.member._0002fjsp_0002fmember_0002fregister_0002ejspregister_jsp_2._jspService(_0002fjsp_0002fmember_0002fregister_0002ejspregister_jsp_2.java:201)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)

Root cause:
java.security.AccessControlException: access denied (java.io.FilePermission /home/.sites/33/site5/web/WEB-INF/classes read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:272)
at java.security.AccessController.checkPermission(AccessController.java:399)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
at java.lang.SecurityManager.checkRead(SecurityManager.java:890)
at java.io.File.isDirectory(File.java:564)
at org.apache.tomcat.loader.AdaptiveClassLoader.loadClass(AdaptiveClassLoader.java:481)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:136)
at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313)
at jsp.member._0002fjsp_0002fmember_0002fregister_0002ejspregister_jsp_2._jspService(_0002fjsp_0002fmember_0002fregister_0002ejspregister_jsp_2.java:173)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspCountedServlet.service(JspServlet.java:130)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:282)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection(Ajp12ConnectionHandler.java:166)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Have you deployed it in the other server as an external Context? It lookes like
1) the context is external and
2) the security rules for that Tomcat instance do not allow read (or probably any) access to that directory.

You may be able to fix it easily by deploying within the Tomcat directory structure, or look at adding file permissions for the context.

Dave
Vrunda Joshi
Ranch Hand

Joined: Dec 03, 2001
Posts: 104
Hey Peter Bang,
I am facing same problem. I am trying to upload a file into database.It's working very well on my local machine. But not on my website.It's giving the
"java.security.AccessControlException: access denied (java.io.FilePermission ..filename.. read)" exception

David O'Meara,could you please tell how to add file permissions for the context?
Since I have the web hosting service,I only have the WEB-INF directory as part of the tomcat.

Thanks in advance
-Vrunda Joshi
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

1) You need to know the directory in question
2) You need to know the required permission
3) You need to know the location of the security policy

Now I solved this in the reverse order since I guessed that if it existed, the policy file would be in the conf directory, and there I found the file catalina.policy

If you open it with a text file it gives instructions for allowing read access to the WEB-INF directory when running Tomcat in secure mode.

Dave
Vrunda Joshi
Ranch Hand

Joined: Dec 03, 2001
Posts: 104
Hey David O'Meara,

Thanks for the post. Unfortunately this information is not useful to me. Since my web site is working on a shared web hosting service,we are not allowed to make changes to security level.All I have as a part of tomcat is a "WEB-INF" directory.So I am not able to make any changes at all.Can I make any changes to the web.xml to solve this problem? or any progrmmmatic solution?

I need to read file from client machine and upload it to database.Because of this sharing policies I could not write the file on server so I am trying to store the file in database.But for it's not able to read the file.

Thanks in advance,
Peter Bang, How did you solve your problem?

-Vrunda
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Two things I would check:
1) first that you are writing to the correct location - you probably are, but always worth verifying
2) that the Tomcat process has read/write access to your directory - this is more likely.

You'll need to check with your ISP, but these processes usually run as the user 'nobody' so you may need to give this user access.

Dave.
Vrunda Joshi
Ranch Hand

Joined: Dec 03, 2001
Posts: 104
Hey David O'Meara,

Thanks for your reply. I really appreciate it. I am thinking of the second possiblity too. But if not through the .policy file,how am I going to grant the "read" access to the "WEB-INF". Can I do that in the "web.xml" since it's the only place where I can make such changes.

Thanks in advance
-Vrunda Joshi
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

If yu check the help files for your ISP they should cover this, and chances are you will need to be able to telnet into your workspace. I'd check their help pages first in case I give you the wrong information.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServerletException - access denied