Topic
7 replies Latest Post - ‏2011-11-01T21:22:45Z by bkail
SystemAdmin
SystemAdmin
37422 Posts
ACCEPTED ANSWER

Pinned topic Problem in class loader in Websphere 8

‏2011-10-25T12:14:18Z |
There seems to be a problem in the class loader of Websphere 8 as it tries too eagerly to load the class referenced in an annotation.
This behaviour blocks the use of Java frameworks that are build on GWT (Google Web Toolkit), e.g Vaadin framework.

For example, when using Vaadin in a JavaEE application that uses injection (e.g CDI, EJB) java.lang.NoClassDefFoundError exceptions are thrown during the deployment on WebSphere v8.

GWT classes are not supposed to be loaded by the class loader. For example UIObject contains a static member (debugIdImpl) that is initialized using GWT.create. GWT.create will always throw an UnsupportedOperationException when invoked outside the special GWT development mode. This will cause NoClassDefFoundError always.

Is there any way so that the class loader does not eagerly load the class that is referenced in an annotation?
Is this a bug in the class loader in Websphere 8?
Updated on 2011-11-01T21:22:45Z at 2011-11-01T21:22:45Z by bkail
  • bkail
    bkail
    372 Posts
    ACCEPTED ANSWER

    Re: Problem in class loader in Websphere 8

    ‏2011-10-25T22:53:18Z  in response to SystemAdmin
    Can you show an example error or stack trace that illustrates the problem?
    • SystemAdmin
      SystemAdmin
      37422 Posts
      ACCEPTED ANSWER

      Re: Problem in class loader in Websphere 8

      ‏2011-10-26T11:59:53Z  in response to bkail
      Caused by: java.lang.NoClassDefFoundError: com.google.gwt.user.client.ui.SimplePanel at java.lang.ClassLoader.defineClassImpl(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:260) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:69) at com.ibm.ws.classloader.CompoundClassLoader._defineClass(CompoundClassLoader.java:828) at com.ibm.ws.classloader.CompoundClassLoader.localFindClass(CompoundClassLoader.java:743) at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:566) at java.lang.ClassLoader.loadClass(ClassLoader.java:612) at java.lang.Class.forNameImpl(Native Method) at java.lang.Class.forName(Class.java:166) at com.ibm.oti.reflect.AnnotationParser.parseClass(AnnotationParser.java:203) at com.ibm.oti.reflect.AnnotationParser.parseElementValue(AnnotationParser.java:156) at com.ibm.oti.reflect.AnnotationParser.parseAnnotation(AnnotationParser.java:131) at com.ibm.oti.reflect.AnnotationParser.parseAnnotations(AnnotationParser.java:57) at java.lang.Class.getDeclaredAnnotations(Class.java:1652) at java.lang.Class.getAnnotations(Class.java:1615) at java.lang.Class.getAnnotation(Class.java:1589) at com.ibm.wsspi.injectionengine.InjectionProcessor.processClassAnnotation(InjectionProcessor.java:906) at com.ibm.wsspi.injectionengine.InjectionProcessor.processAllAnnotations(InjectionProcessor.java:737) at com.ibm.ws.injectionengine.AbstractInjectionEngine.processAnnotations(AbstractInjectionEngine.java:684) at com.ibm.ws.injectionengine.AbstractInjectionEngine.processInjectionMetaData(AbstractInjectionEngine.java:457) at com.ibm.ws.injectionengine.AbstractInjectionEngine.processInjectionMetaData(AbstractInjectionEngine.java:380) at com.ibm.ws.webbeans.services.ResourceInjectionServiceImpl.initialize(ResourceInjectionServiceImpl.java:103) at com.ibm.ws.webbeans.services.JCDIComponentImpl.deployedObjectStart(JCDIComponentImpl.java:376) at com.ibm.ws.webbeans.services.JCDIComponentImpl.stateChanged(JCDIComponentImpl.java:438) at com.ibm.ws.runtime.component.ApplicationMgrImpl.stateChanged(ApplicationMgrImpl.java:1083) at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectEvent(DeployedApplicationImpl.java:1352) at com.ibm.ws.runtime.component.DeployedModuleImpl.setState(DeployedModuleImpl.java:247) at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:635) at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:967) ... 48 more Caused by: java.lang.ClassNotFoundException: com.google.gwt.user.client.ui.SimplePanel at java.net.URLClassLoader.findClass(URLClassLoader.java:434) at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:198) at java.lang.ClassLoader.loadClass(ClassLoader.java:646) at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:113) at java.lang.ClassLoader.loadClass(ClassLoader.java:612) at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62) at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58) at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:564) at java.lang.ClassLoader.loadClass(ClassLoader.java:612) at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:564) at java.lang.ClassLoader.loadClass(ClassLoader.java:612) ... 77 more
      • bkail
        bkail
        372 Posts
        ACCEPTED ANSWER

        Re: Problem in class loader in Websphere 8

        ‏2011-10-26T18:43:03Z  in response to SystemAdmin
        This appears to be an issue with the IBM Java. I would recommend opening a PMR. The following test program illustrates the problem; it produces different output on IBM vs Oracle Java:

        import javax.annotation.Resource
        @Resource(type=b.class)
        public class a {
          public static void main(String[] args) {
            System.out.println(a.class.getAnnotation(Resource.class));
          }
        }
        class b extends c { }
        class c { }
        
        Updated on 2014-03-25T23:56:07Z at 2014-03-25T23:56:07Z by iron-man
        • bkail
          bkail
          372 Posts
          ACCEPTED ANSWER

          Re: Problem in class loader in Websphere 8

          ‏2011-10-26T18:44:33Z  in response to bkail
          Sorry, I forgot to mention: to reproduce the problem, first compile a.java, then delete c.class, then run the main class.
        • SystemAdmin
          SystemAdmin
          37422 Posts
          ACCEPTED ANSWER

          Re: Problem in class loader in Websphere 8

          ‏2011-10-27T07:02:11Z  in response to bkail
          Can you provide me the URL for opening a PMR regarding IBM JDK?
          • bkail
            bkail
            372 Posts
            ACCEPTED ANSWER

            Re: Problem in class loader in Websphere 8

            ‏2011-11-01T21:22:45Z  in response to SystemAdmin
            Since the JDK is bundled with WebSphere Application Server, you would open a PMR for that product and it will be routed internally. Start with http://ibm.com/support or have your account information and dial 1-800-IBM-SERV.
  • SAVE_vrspraveen_atluri
    1 Post
    ACCEPTED ANSWER

    Re: Problem in class loader in Websphere 8

    ‏2011-10-27T16:41:55Z  in response to SystemAdmin
    Hi,

    In websphere you can specify the custom class loader options for your application. try to load the GWT jars from your application first and then load the other jars from the IBM.
    Thanks