[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-dev
Subject:    [jira] [Updated] (XMLBEANS-506) NPE trying to load resource file if XmlBeans was loaded by the boots
From:       "Daniel Hengst (JIRA)" <xmlbeans-dev () xml ! apache ! org>
Date:       2013-10-29 11:18:31
Message-ID: JIRA.12670973.1380301403820.17330.1383045511116 () arcas
[Download RAW message or body]


     [ https://issues.apache.org/jira/browse/XMLBEANS-506?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel \
]

Daniel Hengst updated XMLBEANS-506:
-----------------------------------

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

java.lang.NullPointerException
  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 org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.getMethod(SchemaTypeLoaderBase.java:73)
  at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.<clinit>(SchemaTypeLoaderBase.java:66)
  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: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 = "META-INF/services/org.apache.xmlbeans.impl.store.PathDelegate.SelectPathInterface";
                
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);

Note: The Class method works slightly different. If the resource name does not \
contain a path it will look for the file in the package where the Class is located.

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

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

java.lang.NullPointerException
  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 org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.getMethod(SchemaTypeLoaderBase.java:73)
  at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.<clinit>(SchemaTypeLoaderBase.java:66)
  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: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 = "META-INF/services/org.apache.xmlbeans.impl.store.PathDelegate.SelectPathInterface";
                
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.

    Affects Version/s: Version 2.6

> 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, Version 2.6
> 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: java.lang.NullPointerException
> 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 org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.getMethod(SchemaTypeLoaderBase.java:73)
>  at org.apache.xmlbeans.impl.schema.SchemaTypeLoaderBase.<clinit>(SchemaTypeLoaderBase.java:66)
>  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: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 = "META-INF/services/org.apache.xmlbeans.impl.store.PathDelegate.SelectPathInterface";
>                 
> 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);
> Note: The Class method works slightly different. If the resource name does not \
> contain a path it will look for the file in the package where the Class is located. \
> I checked XmlBeans 2.6.0 and browsed the SVN sources, the problem still exists.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic