[ https://issues.apache.org/activemq/browse/SM-952?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_40135 ]
Srivatsan Sridharan commented on SM-952: ---------------------------------------- Adding comment here as it is a related issue: When the <library> element provided under <classpath> has a value, the following code snippet to get the SharedLibrary sl returns "null" if the shared library is not installed and throws NPE when sl.getClassLoader() is called. A typical scenario when this could occur is when running maven junit test cases for a su that references a shared-library in the xbean.xml/servicemix.xml. // create the classloader List<ClassLoader> parents = new ArrayList<ClassLoader>(); parents.add(getParentClassLoader(applicationContext)); for (String library : sls) { SharedLibrary sl = container.getRegistry().getSharedLibrary(library); // Check for null to prevent the NPE if ((sl != null) && (sl.getClassLoader() != null)) { parents.add(sl.getClassLoader()); } } A check for null (as shown in the code) prevents the NPE that is thrown. > ClassLoaderXmlPreprocessor not able to load shared libraries from xbean.xml > --------------------------------------------------------------------------- > > Key: SM-952 > URL: https://issues.apache.org/activemq/browse/SM-952 > Project: ServiceMix > Issue Type: Bug > Components: servicemix-common > Affects Versions: 3.2 > Reporter: Honi Jain > Priority: Critical > Fix For: 3.2 > > Attachments: ClassLoaderXmlPreprocessor.java, > ClassLoaderXmlPreprocessor.java.patch > > > If we dont specify location child node but specify library child node of > parent node classpath in xbean.xml we are getting Null Pointer Exception when > we deploy our service assembly in servicemix. > getClassLoader method of ClassLoaderXmlPreprocessor parses the xbean.xml for > the tag 'classpath'. For loading shared-libraries it searches for the child > nodes with tag name 'library'. After it found all the child library nodes it > adds to the arraylist for the shared library using the child node list of > 'location'. This will give null pointer exception if no location node is > there. Even if location node is present when the code will try to look for > shared library it will give an error. > I am attaching the patch file ClassLoaderXmlPreprocessor .java -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.