java.io.IOException: code-source:/C:/my/ws31/NewOC4J/ora92/j2ee/home/applications/SeniorApps/ejbSenior.jar has no "!<pat h>" suffix so does not name a path within the code-source.

Hibernate JIRA | Jifeng Liu | 1 decade ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    In Oracle OC4J server, I created an EJB jar file, ejbSenior.jar, and put persistence.xml in its /META-INF folder. After deploying this EJB jar, I called javax.persistence.Persistence.createEntityManagerFactory("hibernate"). I got the following debug information and exception stack trace: 14:36:23 DEBUG Ejb3Configuration - Archive to be processed by hibernate Entity Manager implementation found 14:36:23 DEBUG JarVisitor - Searching mapped entities in jar/par: code-source:/C:/my/ws31/NewOC4J/ora92/j2ee/home/applic ations/SeniorApps/ejbSenior.jar 14:36:23 DEBUG Ejb3Configuration - Persistence unit name: hibernate 14:36:23 DEBUG Ejb3Configuration - emname:hibernate metadata: hibernate 14:36:23 WARN InputStreamZippedJarVisitor - Unable to find file (ignored): code-source:/C:/my/ws31/NewOC4J/ora92/j2ee/h ome/applications/SeniorApps/ejbSenior.jar java.io.IOException: code-source:/C:/my/ws31/NewOC4J/ora92/j2ee/home/applications/SeniorApps/ejbSenior.jar has no "!<pat h>" suffix so does not name a path within the code-source. at oracle.classloader.SharedCodeSourceSet.getResourceStream(SharedCodeSourceSet.java:482) at oracle.classloader.SharedCodeSourceURL$Connection.getInputStream(SharedCodeSourceURL.java:93) at java.net.URL.openStream(URL.java:1007) at org.hibernate.ejb.packaging.InputStreamZippedJarVisitor.doProcessElements(InputStreamZippedJarVisitor.java:33) 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) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27) at com.senior.dal.shared.util.HbSessionFactory.getEntityManagerFactory(HbSessionFactory.java:40) After debugging it, I found Oracle OC4J's class loader creates a special URL with protocol 'code-source'. You can use this URL to get any resource inside EJB jar file. But you can't use it to read the EJB jar file itself. I wrote a small patch to fix it by changing the URL to an URL pointing to a file: In org.hibernate.ejb.packaging.JarVisitor java file, I add new code between "patch begins" and "patch ends" comment: public static final URL getJarURLFromURLEntry(URL url, String entry) throws IllegalArgumentException { URL jarUrl; String file = url.getFile(); if ( ! entry.startsWith( "/" ) ) entry = "/" + entry; file = file.substring( 0, file.length() - entry.length() ); if ( file.endsWith( "!" ) ) file = file.substring( 0, file.length() - 1 ); try { if ( "jar".equals( url.getProtocol() ) ) { jarUrl = new URL( file ); } // patch starts else if ("code-source".equals( url.getProtocol() ) ) { jarUrl = new File(file).toURL(); } // patch ends else { jarUrl = new URL( url.getProtocol(), url.getHost(), url.getPort(), file ); } } catch (MalformedURLException e) { throw new IllegalArgumentException( "Unable to determine JAR Url from " + url + ". Cause: " + e.getMessage() ); } return jarUrl; }

    Hibernate JIRA | 1 decade ago | Jifeng Liu
    java.io.IOException: code-source:/C:/my/ws31/NewOC4J/ora92/j2ee/home/applications/SeniorApps/ejbSenior.jar has no "!<pat h>" suffix so does not name a path within the code-source.
  2. 0

    In Oracle OC4J server, I created an EJB jar file, ejbSenior.jar, and put persistence.xml in its /META-INF folder. After deploying this EJB jar, I called javax.persistence.Persistence.createEntityManagerFactory("hibernate"). I got the following debug information and exception stack trace: 14:36:23 DEBUG Ejb3Configuration - Archive to be processed by hibernate Entity Manager implementation found 14:36:23 DEBUG JarVisitor - Searching mapped entities in jar/par: code-source:/C:/my/ws31/NewOC4J/ora92/j2ee/home/applic ations/SeniorApps/ejbSenior.jar 14:36:23 DEBUG Ejb3Configuration - Persistence unit name: hibernate 14:36:23 DEBUG Ejb3Configuration - emname:hibernate metadata: hibernate 14:36:23 WARN InputStreamZippedJarVisitor - Unable to find file (ignored): code-source:/C:/my/ws31/NewOC4J/ora92/j2ee/h ome/applications/SeniorApps/ejbSenior.jar java.io.IOException: code-source:/C:/my/ws31/NewOC4J/ora92/j2ee/home/applications/SeniorApps/ejbSenior.jar has no "!<pat h>" suffix so does not name a path within the code-source. at oracle.classloader.SharedCodeSourceSet.getResourceStream(SharedCodeSourceSet.java:482) at oracle.classloader.SharedCodeSourceURL$Connection.getInputStream(SharedCodeSourceURL.java:93) at java.net.URL.openStream(URL.java:1007) at org.hibernate.ejb.packaging.InputStreamZippedJarVisitor.doProcessElements(InputStreamZippedJarVisitor.java:33) 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) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27) at com.senior.dal.shared.util.HbSessionFactory.getEntityManagerFactory(HbSessionFactory.java:40) After debugging it, I found Oracle OC4J's class loader creates a special URL with protocol 'code-source'. You can use this URL to get any resource inside EJB jar file. But you can't use it to read the EJB jar file itself. I wrote a small patch to fix it by changing the URL to an URL pointing to a file: In org.hibernate.ejb.packaging.JarVisitor java file, I add new code between "patch begins" and "patch ends" comment: public static final URL getJarURLFromURLEntry(URL url, String entry) throws IllegalArgumentException { URL jarUrl; String file = url.getFile(); if ( ! entry.startsWith( "/" ) ) entry = "/" + entry; file = file.substring( 0, file.length() - entry.length() ); if ( file.endsWith( "!" ) ) file = file.substring( 0, file.length() - 1 ); try { if ( "jar".equals( url.getProtocol() ) ) { jarUrl = new URL( file ); } // patch starts else if ("code-source".equals( url.getProtocol() ) ) { jarUrl = new File(file).toURL(); } // patch ends else { jarUrl = new URL( url.getProtocol(), url.getHost(), url.getPort(), file ); } } catch (MalformedURLException e) { throw new IllegalArgumentException( "Unable to determine JAR Url from " + url + ". Cause: " + e.getMessage() ); } return jarUrl; }

    Hibernate JIRA | 1 decade ago | Jifeng Liu
    java.io.IOException: code-source:/C:/my/ws31/NewOC4J/ora92/j2ee/home/applications/SeniorApps/ejbSenior.jar has no "!<pat h>" suffix so does not name a path within the code-source.

    Root Cause Analysis

    1. java.io.IOException

      code-source:/C:/my/ws31/NewOC4J/ora92/j2ee/home/applications/SeniorApps/ejbSenior.jar has no "!<pat h>" suffix so does not name a path within the code-source.

      at oracle.classloader.SharedCodeSourceSet.getResourceStream()
    2. oracle.classloader
      SharedCodeSourceURL$Connection.getInputStream
      1. oracle.classloader.SharedCodeSourceSet.getResourceStream(SharedCodeSourceSet.java:482)
      2. oracle.classloader.SharedCodeSourceURL$Connection.getInputStream(SharedCodeSourceURL.java:93)
      2 frames
    3. Java RT
      URL.openStream
      1. java.net.URL.openStream(URL.java:1007)
      1 frame
    4. Hibernate EJB
      HibernatePersistence.createEntityManagerFactory
      1. org.hibernate.ejb.packaging.InputStreamZippedJarVisitor.doProcessElements(InputStreamZippedJarVisitor.java:33)
      2. org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(JarVisitor.java:208)
      3. org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:201)
      4. org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:183)
      5. org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
      5 frames
    5. JavaEE 7
      Persistence.createEntityManagerFactory
      1. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
      2. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
      2 frames
    6. com.senior.dal
      HbSessionFactory.getEntityManagerFactory
      1. com.senior.dal.shared.util.HbSessionFactory.getEntityManagerFactory(HbSessionFactory.java:40)
      1 frame