java.util.zip.ZipException: Access is denied

Oracle Community | 843802 | 1 decade ago
  1. 0

    Another problem executing JAR files

    Oracle Community | 1 decade ago | 843802
    java.util.zip.ZipException: Access is denied
  2. 0

    I found from the JIRA database that EJB-178 and EJB-181 were written regarding the issue of the Entity Manager not handling paths with spaces in them correctly, and they both are in the 'resolved' state. However, in 3.2.0.cr2 of the EntityManager, I still get this error when running the PackagedEntityManagerTest testExplodedPar JUnit test from a root directory that contains spaces: 12:20:34,331 DEBUG JarVisitor:192 - Searching mapped entities in jar/par: file:/D:/User%20Data/Eclipse_Workspaces/Test/HibernateEntityManagerTest/build/testresources/explodedpar.par 12:20:34,346 WARN FileZippedJarVisitor:37 - Unable to find file (ignored): file:/D:/User%20Data/Eclipse_Workspaces/Test/HibernateEntityManagerTest/build/testresources/explodedpar.par java.util.zip.ZipException: Access is denied at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.<init>(ZipFile.java:203) at java.util.jar.JarFile.<init>(JarFile.java:132) at java.util.jar.JarFile.<init>(JarFile.java:70) at org.hibernate.ejb.packaging.FileZippedJarVisitor.doProcessElements(FileZippedJarVisitor.java:34) at org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(JarVisitor.java:215) at org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:251) at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:227) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) at org.hibernate.ejb.test.PackagedEntityManagerTest.testExplodedPar(PackagedEntityManagerTest.java:110) 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:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) After looking at the EJB-178 and EJB-181 errors and the code, it appears that what happened was that EJB-178 was closed as a duplicate of EJB-181, but they are not the same error. It is the same jarUrl.getFile() call that causes the problem, but it is in different code: EJB-178 covers the org.hibernate.ejb.packaging.JarVisitor.getVisitor() method, whereas EJB-181 covers the org.hibernate.ejb.packaging.ExplodedJarVisitor.doProcessElements() . The source code shows that EJB-181 was fixed but EJB-178 was not. I put the fix in to the JarVisitor.getVisitor() method (changed jar Url.getFile() to jarUrl.toURI().getSchemeSpecificPart() and added exception handling) and rebuilt the Entity Manager jar. I then reran the PackagedEntityManagerTest testExplodedPar JUnit test using the new jar, and the JUnit passed.

    Hibernate JIRA | 1 decade ago | Michael Falco
    java.util.zip.ZipException: Access is denied
  3. 0

    I'm using Hibernate Entity Manager with a WAR deployed on Tomcat 5.5.17, and I'm getting the following error: 11/05/2006 16:12:43 org.hibernate.ejb.packaging.FileZippedJarVisitor doProcessElements WARNING: Unable to find file (ignored): file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapps/[REST OMITTED] java.util.zip.ZipException: Access is denied at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.<init>(Unknown Source) at java.util.jar.JarFile.<init>(Unknown Source) at java.util.jar.JarFile.<init>(Unknown Source) at org.hibernate.ejb.packaging.FileZippedJarVisitor.doProcessElements(FileZippedJarVisitor.java:34) at org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(JarVisitor.java:208) at org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:201) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:183) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) [MORE...] Two strange things: 1) the directory exists; 2) Hibernate is treating the path as being part of a JAR file. I found the cause of the problem when analysing org.hibernate.ejb.packaging.JarVisitor.getVisitor(URL, Filter[]): File file = new File( jarUrl.getFile() ); if ( file.isDirectory() ) { return new ExplodedJarVisitor( jarUrl, filters ); } else { return new FileZippedJarVisitor( jarUrl, filters ); } As my path has some spaces, jarUrl.getFile() returns "/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapps/[REST OMITTED]", which is not a directory, because of the "%20"'s. The specification of the java.net.URL class says: "The URL class does not itself encode or decode any URL components according to the escaping mechanism defined in RFC2396. It is the responsibility of the caller to encode any fields, which need to be escaped prior to calling URL, and also to decode any escaped fields, that are returned from URL." Although I did not have the time to build the project with it, I think that jarUrl.toURI().getPath() would solve the problem. Here is a snippet to prove it: import java.io.File; import java.net.URL; public class Main { public static void main( String[] args ) throws Exception { URL url = new URL( "file:///C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%205.5/webapps" ); System.out.println( "url.getFile()" ); System.out.println( url.getFile() ); System.out.println( new File( url.getFile() ).isDirectory() ); System.out.println(); System.out.println(); System.out.println(); System.out.println( "url.toURI().getPath()" ); System.out.println( url.toURI().getPath() ); System.out.println( new File( url.toURI().getPath() ).isDirectory() ); } }

    Hibernate JIRA | 1 decade ago | Alexandrino Lucas
    java.util.zip.ZipException: Access is denied
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    starting tomcat problem, please help urgent

    Oracle Community | 1 decade ago | 843834
    java.util.zip.ZipException: Access is denied
  6. 0

    ClientDeployer and ZipException: Access is denied

    Oracle Community | 1 decade ago | 3004
    java.util.zip.ZipException: Access is denied

  1. cesarnog 291 times, last 1 month ago
21 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.util.zip.ZipException

    Access is denied

    at java.util.zip.ZipFile.open()
  2. Java RT
    JarFile.<init>
    1. java.util.zip.ZipFile.open(Native Method)
    2. java.util.zip.ZipFile.<init>(ZipFile.java:112)
    3. java.util.jar.JarFile.<init>(JarFile.java:127)
    4. java.util.jar.JarFile.<init>(JarFile.java:65)
    4 frames