Daniel Hengst created XMLBEANS-506:

             Summary: NPE trying to load resource file if XmlBeans was loaded 
by the bootstrap ClassLoader
                 Key: XMLBEANS-506
                 URL: https://issues.apache.org/jira/browse/XMLBEANS-506
             Project: XMLBeans
          Issue Type: Bug
    Affects Versions: Version 2.5
         Environment: JBoss 6.1.0, JVM 1.6.0_30, CentOS 5.7 x86_64
            Reporter: Daniel Hengst

To solve a dependency issue, we put XmlBeans 2.5.0 into the endorsed folder. 
This brought the following exception:

  at org.apache.xmlbeans.impl.store.Path.<clinit>(Path.java:65)
  at java.lang.Class.forName0(Native Method)
  at java.lang.Class.forName(Class.java:169)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at org.apache.xmlbeans.XmlBeans.getNoType(XmlBeans.java:856)
  at org.apache.xmlbeans.XmlBeans.<clinit>(XmlBeans.java:881)

The source code of org.apache.xmlbeans.impl.store.Path looks like this:

63: ClassLoader cl = Path.class.getClassLoader();
64: String id = 
65: InputStream in = cl.getResourceAsStream(id); <- NPE occurs here

This appears to be a bug. The JavaDoc for getClassLoader() says: "Some 
implementations may use null to represent the bootstrap class loader. This 
method will return null in such implementations if this class was loaded by the 
bootstrap class loader." So the caller of getClassLoader() should take into 
account that it might return null, which does not happen here. I would suggest 
changing line 65 to the following:

InputStream in = Path.class.getResourceAsStream(id);

I checked XmlBeans 2.6.0 and browsed the SVN sources, the problem still exists.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

To unsubscribe, e-mail: dev-unsubscr...@xmlbeans.apache.org
For additional commands, e-mail: dev-h...@xmlbeans.apache.org

Reply via email to