Meaningless Drivel is fun!*
The moose likes Tomcat and the fly likes ZipException: Access is Denied Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "ZipException: Access is Denied" Watch "ZipException: Access is Denied" New topic
Author

ZipException: Access is Denied

Daniel Gee
Ranch Hand

Joined: Aug 29, 2003
Posts: 202
My simple Struts application worked fine until I added a abc.jar in the WEB-INF/lib directory and a xyz.tld in the WEB-INF directory.

At runtime, I got the Status 404 - /MyApplication/index.jsp : the requested resources is not available.

Without that .jar and .tld, the index.jsp at the web root could be found.

I have checked properties of the abc.jar and xyz.tld, they are not read-only.

Then I looked at the log. The root cause is ZipException: Access is Denied. I am showing the log below:

----- Root Cause -----
java.util.zip.ZipException: Access is denied
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:111)
at java.util.jar.JarFile.<init>(JarFile.java:127)
at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:51)
at sun.net.www.protocol.jar.URLJarFile$1.run(URLJarFile.java:178)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.jar.URLJarFile.retrieve(URLJarFile.java:164)
at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:42)
at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:78)
at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:85)
at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:69)
at org.apache.catalina.startup.ContextConfig.tldScanJar(ContextConfig.java:847)
at org.apache.catalina.startup.ContextConfig.tldScan(ContextConfig.java:809)
at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:587)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:181)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3523)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:774)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:760)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:548)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:260)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:741)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:512)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:354)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:671)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1149)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:707)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1141)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:316)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2143)
at org.apache.catalina.startup.Catalina.start(Catalina.java:463)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:350)
at org.apache.catalina.startup.Catalina.process(Catalina.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:156)

2006-05-09 13:07:21 ContextConfig[/struts-mailreader]: Marking this application unavailable due to previous error(s)
2006-05-09 13:07:21 StandardManager[/struts-mailreader]: Seeding random number generator class java.security.SecureRandom
2006-05-09 13:07:21 StandardManager[/struts-mailreader]: Seeding of random number generator has been completed
2006-05-09 13:07:21 StandardContext[/struts-mailreader]: Context startup failed due to previous errors
2006-05-09 13:07:21 StandardHost[localhost]: ContainerBase.addChild: start:
LifecycleException: Context startup failed due to previous errors
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3578)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:774)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:760)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:548)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:260)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:741)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:512)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:354)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:671)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1149)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:707)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1141)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:316)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2143)
at org.apache.catalina.startup.Catalina.start(Catalina.java:463)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:350)
at org.apache.catalina.startup.Catalina.process(Catalina.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:156)

2006-05-09 13:07:21 StandardHost[localhost]: Error deploying application at context path /struts-mailreader
java.lang.IllegalStateException: ContainerBase.addChild: start: LifecycleException: Context startup failed due to previous errors
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:777)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:760)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:548)
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:260)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:741)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:512)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:354)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:671)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1149)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:707)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1141)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:316)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2143)
at org.apache.catalina.startup.Catalina.start(Catalina.java:463)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:350)
at org.apache.catalina.startup.Catalina.process(Catalina.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:156)

2006-05-09 13:07:21 HostConfig[localhost] Error deploying web application directory struts-mailreader
java.io.IOException: java.lang.IllegalStateException: ContainerBase.addChild: start: LifecycleException: Context startup failed due to previous errors
at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.java:265)
at org.apache.catalina.core.StandardHost.install(StandardHost.java:741)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:512)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:354)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:671)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1149)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:707)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1141)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:316)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2143)
at org.apache.catalina.startup.Catalina.start(Catalina.java:463)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:350)
at org.apache.catalina.startup.Catalina.process(Catalina.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:156)

2006-05-09 13:07:21 HostConfig[localhost]: Deploying web application directory tomcat-docs
2006-05-09 13:07:21 StandardHost[localhost]: Installing web application at context path /tomcat-docs from URL file:C:\Tomcat4.1\webapps\tomcat-docs
2006-05-09 13:07:21 WebappLoader[/tomcat-docs]: Deploying class repositories to work directory C:\Tomcat4.1\work\Standalone\localhost\tomcat-docs
2006-05-09 13:07:21 StandardManager[/tomcat-docs]: Seeding random number generator class java.security.SecureRandom
2006-05-09 13:07:21 StandardManager[/tomcat-docs]: Seeding of random number generator has been completed
2006-05-09 13:07:21 StandardWrapper[/tomcat-docs efault]: Loading container servlet default
2006-05-09 13:07:21 StandardWrapper[/tomcat-docs:invoker]: Loading container servlet invoker
2006-05-09 13:07:21 HostConfig[localhost]: Deploying web application directory webdav
2006-05-09 13:07:21 StandardHost[localhost]: Installing web application at context path /webdav from URL file:C:\Tomcat4.1\webapps\webdav
2006-05-09 13:07:21 WebappLoader[/webdav]: Deploying class repositories to work directory C:\Tomcat4.1\work\Standalone\localhost\webdav
2006-05-09 13:07:21 StandardManager[/webdav]: Seeding random number generator class java.security.SecureRandom
2006-05-09 13:07:21 StandardManager[/webdav]: Seeding of random number generator has been completed
2006-05-09 13:07:21 StandardWrapper[/webdav efault]: Loading container servlet default
2006-05-09 13:07:21 StandardWrapper[/webdav:invoker]: Loading container servlet invoker
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Windows? Linux? OS X?

I await more details breathlessly.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Daniel Gee
Ranch Hand

Joined: Aug 29, 2003
Posts: 202
Thanks for your attention to my question. I am using the Windows 2000, Tomcat 4.1.31, and j2sdk1.4.2_10.
[ May 10, 2006: Message edited by: Daniel Gee ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

OK, since you are using a system totally lacking in user security, that elimnates file system user permissions as a factor.

My next guess would be a corrupt file. Can you open the file with tools such as WinZip or the jar command at the command prompt?
[ May 10, 2006: Message edited by: Bear Bibeault ]
Daniel Gee
Ranch Hand

Joined: Aug 29, 2003
Posts: 202
Which file/files do you want me to open with either WinZip or the jar command in the DOS window?

The jar file that I added to the MyApplication/WEB-INF/lib directory can be opened using the WinZip. I right clicked on the jar file, selected the WinZip from the menu, and a zip file for that jar was generated.

The tld file that I added to the MyApplication/WEB-INF directory can be read using a NotePad.

Thanks.
[ May 10, 2006: Message edited by: Daniel Gee ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

Hmmm, if all goes well when you remove the jar file, it must be that one that's causing the issue.

If the file is not corrupt, and the file permissions are set appropriately, I cannot account for the problem.

I'm remanding this to the Tomcat forum for any further discussion.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

One work-around would be to unpack the jar file with the jar command and place the classes (and their package directory structure) under WEB-INF classes.

Using jar to unpack it will probably be a better test than using WinZip since Tomcat will be using java classes and not WinZip to read the jar file.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Daniel Gee
Ranch Hand

Joined: Aug 29, 2003
Posts: 202
I think the Bear is right in moving this thread to the Tomcat Forum.

I moved the application and the JAR file to the WebSphere, everyting worked without any problem.

Now, the question is how robust the Tomcat is?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ZipException: Access is Denied
 
Similar Threads
Problems with Tiles Def
Servlet Action currently Unavailable
Exception processing JAR at resource path /WEB-INF/lib/xmlParserAPIs
Tomcat Access Problem
Ant could not deploy the web application