java.util.zip.ZipException: No such file or directory

Hibernate JIRA | Jonathan Eric Miller | 1 decade ago
  1. 0

    I'm having problems using a .par file in Tomcat. The .par file works fine if I use it with a standalone application. However, if I bundle it in the WEB-INF/lib directory with my Web application, I receive a java.lang.NoClassDefFoundError exception. If I rename the .par file so that it has a .jar extension instead it works, but, I receive the following exception. Aug 22, 2005 11:48:20 AM org.hibernate.ejb.packaging.ZippedJarVisitor doProcessElements WARNING: Unable to find file (ignored): opt/jakarta-tomcat-5.5.9-dev/webapps/alt/WEB-INF/lib/alt-persistence.jar java.util.zip.ZipException: No such file or directory 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.ZippedJarVisitor.doProcessElements(ZippedJarVisitor.java:29) at org.hibernate.ejb.packaging.JarVisitor.getClassNames(JarVisitor.java:79) at org.hibernate.ejb.HibernatePersistence.addMetadataFromVisitor(HibernatePersistence.java:216) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:185) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) at edu.uchicago.at.alt.persistence.EntityManagerManager.getEntityManagerFactory(EntityManagerManager.java:89) at edu.uchicago.at.alt.persistence.EntityManagerManager.getEntityManager(EntityManagerManager.java:77) at edu.uchicago.at.alt.manager.ManagerHandler.listApplications(ManagerHandler.java:80) at org.apache.jsp.manager.listApplications_jspx._jspService(listApplications_jspx.java:126) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) ... Note, it works, I just receive the exception as a warning. Also, the path listed in the exception above is pretty much the correct path, only it looks like maybe the path needs a leading '/'. I'm using the following in my persistence.xml in case that makes a difference. <?xml version="1.0" encoding="UTF-8"?> <entity-manager> <name>alt</name> <class>edu.uchicago.at.alt.persistence.entity.Application</class> <class>edu.uchicago.at.alt.persistence.entity.Reference</class> <class>edu.uchicago.at.persistence.entity.Department</class> <class>edu.uchicago.at.persistence.entity.Person</class> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/> <property name="hibernate.use_sql_comments" value="true"/> </properties> </entity-manager> What I'm wondering is whether it's valid to use a file with a .par extension in Tomcat. I'm guessing the reason I received the first exception is because Tomcat only looks for classes that are in .jar files. Please let me know if you have any questions or need more information. Thanks.

    Hibernate JIRA | 1 decade ago | Jonathan Eric Miller
    java.util.zip.ZipException: No such file or directory
  2. 0

    I'm having problems using a .par file in Tomcat. The .par file works fine if I use it with a standalone application. However, if I bundle it in the WEB-INF/lib directory with my Web application, I receive a java.lang.NoClassDefFoundError exception. If I rename the .par file so that it has a .jar extension instead it works, but, I receive the following exception. Aug 22, 2005 11:48:20 AM org.hibernate.ejb.packaging.ZippedJarVisitor doProcessElements WARNING: Unable to find file (ignored): opt/jakarta-tomcat-5.5.9-dev/webapps/alt/WEB-INF/lib/alt-persistence.jar java.util.zip.ZipException: No such file or directory 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.ZippedJarVisitor.doProcessElements(ZippedJarVisitor.java:29) at org.hibernate.ejb.packaging.JarVisitor.getClassNames(JarVisitor.java:79) at org.hibernate.ejb.HibernatePersistence.addMetadataFromVisitor(HibernatePersistence.java:216) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:185) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) at edu.uchicago.at.alt.persistence.EntityManagerManager.getEntityManagerFactory(EntityManagerManager.java:89) at edu.uchicago.at.alt.persistence.EntityManagerManager.getEntityManager(EntityManagerManager.java:77) at edu.uchicago.at.alt.manager.ManagerHandler.listApplications(ManagerHandler.java:80) at org.apache.jsp.manager.listApplications_jspx._jspService(listApplications_jspx.java:126) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) ... Note, it works, I just receive the exception as a warning. Also, the path listed in the exception above is pretty much the correct path, only it looks like maybe the path needs a leading '/'. I'm using the following in my persistence.xml in case that makes a difference. <?xml version="1.0" encoding="UTF-8"?> <entity-manager> <name>alt</name> <class>edu.uchicago.at.alt.persistence.entity.Application</class> <class>edu.uchicago.at.alt.persistence.entity.Reference</class> <class>edu.uchicago.at.persistence.entity.Department</class> <class>edu.uchicago.at.persistence.entity.Person</class> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/> <property name="hibernate.use_sql_comments" value="true"/> </properties> </entity-manager> What I'm wondering is whether it's valid to use a file with a .par extension in Tomcat. I'm guessing the reason I received the first exception is because Tomcat only looks for classes that are in .jar files. Please let me know if you have any questions or need more information. Thanks.

    Hibernate JIRA | 1 decade ago | Jonathan Eric Miller
    java.util.zip.ZipException: No such file or directory
  3. 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
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 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
  6. 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

  1. cesarnog 291 times, last 2 months 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

    No such file or directory

    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>(Unknown Source)
    3. java.util.jar.JarFile.<init>(Unknown Source)
    4. java.util.jar.JarFile.<init>(Unknown Source)
    4 frames
  3. Hibernate EJB
    HibernatePersistence.createEntityManagerFactory
    1. org.hibernate.ejb.packaging.ZippedJarVisitor.doProcessElements(ZippedJarVisitor.java:29)
    2. org.hibernate.ejb.packaging.JarVisitor.getClassNames(JarVisitor.java:79)
    3. org.hibernate.ejb.HibernatePersistence.addMetadataFromVisitor(HibernatePersistence.java:216)
    4. org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:185)
    4 frames
  4. JavaEE 7
    Persistence.createEntityManagerFactory
    1. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
    1 frame
  5. edu.uchicago.at
    ManagerHandler.listApplications
    1. edu.uchicago.at.alt.persistence.EntityManagerManager.getEntityManagerFactory(EntityManagerManager.java:89)
    2. edu.uchicago.at.alt.persistence.EntityManagerManager.getEntityManager(EntityManagerManager.java:77)
    3. edu.uchicago.at.alt.manager.ManagerHandler.listApplications(ManagerHandler.java:80)
    3 frames
  6. org.apache.jsp
    listApplications_jspx._jspService
    1. org.apache.jsp.manager.listApplications_jspx._jspService(listApplications_jspx.java:126)
    1 frame
  7. GWT dev
    HttpJspBase.service
    1. org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    1 frame
  8. JavaServlet
    HttpServlet.service
    1. javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    1 frame