Do I have a broken classloader?

Help
2009-02-27
2013-04-17
  • Daniel Foguel
    Daniel Foguel
    2009-02-27

    Guys, Andrew, Hi to all

    I'm currently using JIP in my WAS 6 server to profile my J2EE app. Using Struts and Spring in it.

    Well, I'm also using the -already posted- ClassLoaderFilter for Websphere (the one a guy posted in here: )

    When I start my app. I can't see my classes loaded as they were.

    Take a look at the log included at the end of the post.

    What I bealive (and it may be unfair) is that JiP broke it xD

    Thanks to all for this great project !

    Cheers,

    Daniel

    ------Start of DE processing------ = [27/02/09 12:08:19:271 GMT] , key = java.lang.NoClassDefFoundError com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadServlet 218
    Exception = java.lang.NoClassDefFoundError
    Source = com.ibm.ws.webcontainer.webapp.WebAppServletManager.loadServlet
    probeid = 218
    Stack Dump = java.lang.NoClassDefFoundError: com.my-package.MyServlet (initialization failure)
        at java.lang.J9VMInternals.initialize(J9VMInternals.java:123)
        at java.lang.Class.newInstanceImpl(Native Method)
        at java.lang.Class.newInstance(Class.java:1263)
        at java.beans.Beans.instantiate(Beans.java:219)
        at java.beans.Beans.instantiate(Beans.java:63)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper$1.run(ServletWrapper.java:1195)
        at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadServlet(ServletWrapper.java:1190)
        at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.loadServlet(ServletWrapper.java:385)
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1112)
        at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:149)
        at com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:99)
        at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:742)
        at com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:422)
        at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:275)
        at com.ibm.ws.wswebcontainer.webapp.WebApp.initialize(WebApp.java:272)
        at com.ibm.ws.wswebcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:88)
        at com.ibm.ws.wswebcontainer.VirtualHost.addWebApplication(VirtualHost.java:157)
        at com.ibm.ws.wswebcontainer.WebContainer.addWebApp(WebContainer.java:655)
        at com.ibm.ws.wswebcontainer.WebContainer.addWebApplication(WebContainer.java:608)
        at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:333)
        at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:549)
        at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1295)
        at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1129)
        at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:567)
        at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:814)
        at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:948)
        at com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:2114)
        at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:340)
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1510)
    Caused by: java.lang.Throwable: java.lang.NullPointerException
        at com.mentorgen.tools.profile.runtime.Profile.start(Unknown Source)
        at org.apache.commons.logging.LogFactory.getLog(LogFactory.java)
        at com.com.my-package.MyServlet.<clinit>(BrandedContentServlet.java)
        at java.lang.J9VMInternals.initializeImpl(Native Method)
        at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
        ... 29 more

     
    • Andrew Wilcox
      Andrew Wilcox
      2009-03-02

      Hi Daniel,

      First of all, I assume that "com.my-package.MyServlet" (top of the log) and "com.com.my-package.MyServlet" (bottom of the log) are the same class?

      Without a line number for com.mentorgen.tools.profile.runtime.Profile, it's difficult to tell what might be happening. Try running WAS with -Xint option. This should yield a line number.

      Thanks,

      Andrew.

       
    • Daniel Foguel
      Daniel Foguel
      2009-03-03

      Andrew,  thanks for your help

      -Xint haven't worked.

      I read in Profile.javadoc

      * <blockquote>
      * Note: Instrumenting code can interfer with line numbers that are added to
      * the code for debugging. If you are debugging code and your stack traces
      * don't have line numbers, don't use the profiler (ie, don't use <code>
      * -javaagent)</code>
      * </blockquote>

      -Xint is the only chance to change this?

      Any other clues? Try'd ye'old printing-debug technic without success, also adding a trycatch block and same unknown resource error was logged.

       
    • Andrew Wilcox
      Andrew Wilcox
      2009-03-04

      Ah, "ye' old printing-debug technique", I know it well.

      You said you added a try-catch. Did you add it to Profile.start? If you haven't added a try-catch Profile.start, do that. As you said, you probably still won't get line numbers. But if you add a number of try-catches within the method, you should be able to narrow things down to at least a section of code, if not the very line of code that's causing the error. Once you have that, it will be much easier to address this issue.

      Thanks!

      Andrew.

       
    • Daniel Foguel
      Daniel Foguel
      2009-03-05

      Hi Andrew, trying to debug it I found that Sysout.println was not trowing it to SystemOut.log so I checked (for some reason) that I had a Profile.jar in my /lib folder...

      Removed it and profiled succesfully.

      Sorry for the inconvenience.

      Do you know why could it be that WAS was using /lib/profile.jar for some stuff while it was using my fresh and correctly compiled profile.jar?

      Thanks a lot,

      Daniel

       
    • Andrew Wilcox
      Andrew Wilcox
      2009-03-09

      Hi Daniel,

      I've found that the "split personality" issue that you mentioned can be fixed by making sure that the JIP jar is NOT in a place where is can be loaded by ANY classloader. Sounds strange, but the Java Agent mechanism will classload the jar for you. If you have the jar in a place like extensions classpath, the jar will get loaded twice.

      Andrew.