Topic
  • 3 replies
  • Latest Post - ‏2013-05-07T11:20:24Z by KenwyneJones
KenwyneJones
KenwyneJones
7 Posts

Pinned topic java.lang.NoClassDefFoundError: com.bowstreet.util.XmlUtil (initialization failure)

‏2013-05-03T15:07:48Z |

Hi,

We have an existing application written in WPF 6.1.5.2 which is working fine and as expected.

We have a change request to add some functionality in to this application which involves including a new set of JAR files (written by us) to allow us to add this in.

When we build and deploy our application with these JARs (and other JARs which are dependencies) we are getting the following error:

com.ibm.websphere.servlet.error.ServletErrorReport: java.lang.NoClassDefFoundError: com.bowstreet.util.XmlUtil (initialization failure)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1762)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1595)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:104)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:895)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:932)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:500)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3810)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:183)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
Caused by: java.lang.NoClassDefFoundError: com.bowstreet.util.XmlUtil (initialization failure)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:140)
    at com.bowstreet.factory.model.implementation.XmlExternalModelPropertiesStorage.(XmlExternalModelPropertiesStorage.java:77)
    at java.lang.J9VMInternals.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1325)
    at com.bowstreet.factory.model.SourceModelManager.loadClass(SourceModelManager.java:579)
    at com.bowstreet.factory.model.SourceModelManager.initializeExternalModelProperties(SourceModelManager.java:467)
    at com.bowstreet.factory.model.SourceModelManager.initialize(SourceModelManager.java:502)
    at com.bowstreet.factory.model.SourceModelManager.getManager(SourceModelManager.java:485)
    at com.bowstreet.webapp.engine.WebAppRunner.fixModelCase(WebAppRunner.java:264)
    at com.bowstreet.webapp.engine.WebAppRunner.doRequest(WebAppRunner.java:242)
    at com.bowstreet.webapp.engine.WebAppServlet.doPost(WebAppServlet.java:73)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
    at com.ibm.ws.cache.servlet.ServletWrapper.serviceProxied(ServletWrapper.java:307)
    at com.ibm.ws.cache.servlet.CacheHook.handleFragment(CacheHook.java:571)
    at com.ibm.ws.cache.servlet.CacheHook.handleServlet(CacheHook.java:247)
    at com.ibm.ws.cache.servlet.ServletWrapper.service(ServletWrapper.java:259)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1655)
    ... 25 more
 

Obviously this is some classloader issue.  To try and diagnose we added the com.ibm.ws.classloader.*=all setting to the 'Logging and Tracing' in WAS to try and get additional information on the class loading.  We also read the IBM Red Book at http://www.redbooks.ibm.com/redpapers/pdfs/redp4307.pdf to help diagnose our issues but it hasn't provided the solution.  I have attached the trace.log file which was produced when we added this setting.

Does anyone have and idea what the issue could be?  I can definitely see factory.jar in the WEB-INF/lib folder of my deployed application.

Thanks in advance.

 

 

Attachments

  • mburati
    mburati
    2568 Posts

    Re: java.lang.NoClassDefFoundError: com.bowstreet.util.XmlUtil (initialization failure)

    ‏2013-05-03T15:16:07Z  

    What jars did you add?   It's possible that you're colliding with equivalent (but different version) jars that Portal or WEF provides.

    I hope that info helps,
    ..Mike Burati 
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.

     

  • kevintap
    kevintap
    748 Posts

    Re: java.lang.NoClassDefFoundError: com.bowstreet.util.XmlUtil (initialization failure)

    ‏2013-05-03T15:22:12Z  

    You are correct that there are classloader issues here.  I looked over the attached trace.log file, but it doesn't go back far enough to contain the relevant exception which is the root cause.  When you receive a NoClassDefFoundError which indicates an "initialization failure" as the case is here:

    java.lang.NoClassDefFoundError: com.bowstreet.util.XmlUtil (initialization failure)

    This indicates that the class was previously found but could not be loaded.  The initial attempt to load this class will have some additional logging, typically an ExceptionInInitializerError which indicates the root cause of the classloading issue.

    Take a look back through your log files and see if you can find this ExceptionInInitializerError.  This should indicate the cause of the issue.

    Most likely, this issue is being caused by duplicate classes which you have added (through your custom .jars) into the WEB-INF/lib directory of your application.  The likely cause is that XML based APIs such as Xerces have been added in your .jar files.

  • KenwyneJones
    KenwyneJones
    7 Posts

    Re: java.lang.NoClassDefFoundError: com.bowstreet.util.XmlUtil (initialization failure)

    ‏2013-05-07T11:20:24Z  
    • kevintap
    • ‏2013-05-03T15:22:12Z

    You are correct that there are classloader issues here.  I looked over the attached trace.log file, but it doesn't go back far enough to contain the relevant exception which is the root cause.  When you receive a NoClassDefFoundError which indicates an "initialization failure" as the case is here:

    java.lang.NoClassDefFoundError: com.bowstreet.util.XmlUtil (initialization failure)

    This indicates that the class was previously found but could not be loaded.  The initial attempt to load this class will have some additional logging, typically an ExceptionInInitializerError which indicates the root cause of the classloading issue.

    Take a look back through your log files and see if you can find this ExceptionInInitializerError.  This should indicate the cause of the issue.

    Most likely, this issue is being caused by duplicate classes which you have added (through your custom .jars) into the WEB-INF/lib directory of your application.  The likely cause is that XML based APIs such as Xerces have been added in your .jar files.

    Thanks for the responses.

    With regards to the trace files, I'm not sure what was going on on Friday as I attached everything that was produced.  However, I restarted the server this morning to see if there were any more trace files produced and indeed there were.  After looking through them I can see the following initializationException:

    [07/05/13 09:26:27:343 BST] 0000000a servlet       E com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0100E: Uncaught init() exception created by servlet WebEngineServlet in application XXXXXXXX: java.lang.ExceptionInInitializerError
        at java.lang.J9VMInternals.initialize(J9VMInternals.java:222)
        at com.bowstreet.util.XmlUtil.<clinit>(XmlUtil.java:1024)
        at java.lang.J9VMInternals.initializeImpl(Native Method)
        at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
        at com.bowstreet.generation.implementation.XmlBuilderManager.addBuilder(XmlBuilderManager.java:469)
        at com.bowstreet.generation.implementation.XmlBuilderManager.addBuilders(XmlBuilderManager.java:368)
        at com.bowstreet.generation.implementation.XmlBuilderManager.addBuilders(XmlBuilderManager.java:361)
        at com.bowstreet.generation.implementation.XmlBuilderManager.addBuilders(XmlBuilderManager.java:361)
        at com.bowstreet.generation.implementation.XmlBuilderManager.addBuilders(XmlBuilderManager.java:361)
        at com.bowstreet.generation.implementation.XmlBuilderManager.addBuilders(XmlBuilderManager.java:361)
        at com.bowstreet.generation.implementation.XmlBuilderManager.loadBuilders(XmlBuilderManager.java:261)
        at com.bowstreet.generation.BuilderManager.updateBuilderDefs(BuilderManager.java:186)
        at com.bowstreet.generation.BuilderManager.getBuilderDefs(BuilderManager.java:157)
        at com.bowstreet.generation.BuilderManager.initialize(BuilderManager.java:480)
        at com.bowstreet.generation.BuilderManager.getManager(BuilderManager.java:427)
        at com.bowstreet.webapp.engine.WebAppRunner.initSubSystems(WebAppRunner.java:1426)
        at com.bowstreet.webapp.engine.WebAppRunner.makeNewInstance(WebAppRunner.java:1278)
        at com.bowstreet.webapp.engine.WebAppRunner.getInstance(WebAppRunner.java:195)
        at com.bowstreet.webapp.engine.WebAppServlet.init(WebAppServlet.java:32)
        at com.ibm.ws.cache.servlet.ServletWrapper.init(ServletWrapper.java:238)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:358)
        at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:168)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1807)
        at com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:98)
        at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:1008)
        at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:929)
        at com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:608)
        at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:426)
        at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:303)
        at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:100)
        at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:166)
        at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:731)
        at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:616)
        at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:376)
        at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:668)
        at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1122)
        at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1315)
        at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:619)
        at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:940)
        at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:725)
        at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2046)
        at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:439)
        at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:123)
        at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:382)
        at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$300(CompositionUnitMgrImpl.java:110)
        at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:949)
        at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:349)
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1550)
    Caused by: java.lang.ClassCastException: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl incompatible with javax.xml.parsers.DocumentBuilderFactory
        at javax.xml.parsers.DocumentBuilderFactory.newInstance(Unknown Source)
        at com.bowstreet.util.XmlUtil$PooledDocumentBuilderFactory.createDocumentBuilderFactory(XmlUtil.java:1037)
        at com.bowstreet.util.XmlUtil$PooledDocumentBuilderFactory.<clinit>(XmlUtil.java:1032)
        at java.lang.J9VMInternals.initializeImpl(Native Method)
        at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)

    DocumentBuilderFactoryImpl is within xercesImpl.jar and having checked all of the JARs which our custom JARs depend on, I can see a different version of xercesImpl.jar has been pulled into WEB-INF/lib (which looks like an older version).  There has also been a different version of xml-apis.jar and xmlParsersAPIs.jar also been pulled in which are causing a conflict.

    I have excluded these three JARs within the project POM (I'm using Maven to pull in the custom JARs and any dependencies) and this problem has now been fixed.

    Thanks a lot for your help.