[JIRA] Created: (JXT-90) NullPointerException in createClassInstance in org.opensaml.xml.XMLConfigurator
jbuhacoff@idp.protectnetwork.org (JIRA)
noreply at shibboleth.net
Wed Aug 29 15:46:06 EDT 2012
NullPointerException in createClassInstance in org.opensaml.xml.XMLConfigurator
-------------------------------------------------------------------------------
Key: JXT-90
URL: https://issues.shibboleth.net/jira/browse/JXT-90
Project: XMLTooling - Java
Issue Type: Bug
Components: Validation
Affects Versions: 1.3.4
Environment: Stand-alone Java application using system classloader
Reporter: jbuhacoff at idp.protectnetwork.org
Assignee: Brent Putman
Priority: Minor
In a stand-alone Java application using the system classloader, when using OpenSAML to verify a SAML assertion, the function createClassInstance is called (for example, to create an instance of XSAnyBuilder) and causes a NullPointerException.
This happens because the getClassLoader() function may return null if the class was loaded by the system, or bootstrap, class loader. I tested with Sun JRE versions 1.5, 1.6, and 1.7 and they all do return null for the bootstrap classloader.
Here are the relevant lines from XMLConfigurator in xmltooling version 1.3.4:
328 ClassLoader classLoader = this.getClass().getClassLoader();
329 Class clazz = classLoader.loadClass(className);
When running in a web container or Junit test in an IDE, there is a custom classloader hierarchy in place and everything works fine. But in an independent environment using the system class loader, the code throws a NullPointerException.
This can be easily fixed by inserting the following line between the two lines shown:
if( classLoader == null ) { classLoader = ClassLoader.getSystemClassLoader(); }
I made this patch in my own project and it's working fine now.
Hope you will adopt this little fix in the next release.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the commits
mailing list