ClassLoader Problem

Discussions

EJB programming & troubleshooting: ClassLoader Problem

  1. ClassLoader Problem (3 messages)

    My entreprise application contains two subprojects
    one java project and an EJB project that call classes in a java project.
    when i start the server i get the exception below:

     This is often caused by having the class at a higher point in the classloader hierarchy
    Dumping the current context classloader hierarchy:
        ==> indicates defining classloader
        *** indicates classloader where the missing class could have been found
    ==>[0]
    com.ibm.ws.classloader.CompoundClassLoader@5ceda25e
     .......

    Any idea ?
  2. ClassLoader Problem[ Go to top ]

    If your application is packages as a ear, as it should, it should pack two modules: an ejb module and a java library module. Your java module should be referenced by the class path entry of your ejb module's MANIFEST.MF. This way the application server will be aware of the dependency and your application will work in any class loader configuration.

    I see you use websphere. If this is a case, you can also get away by choosing another class loader configuration. As far as I remember, WAS lets you do that and there should be a "flat" class loader configuration which makes every class in your application globally visible to the entire application, no matter which module it comes from.

    the manifest is the way to go, though. this way your application will be more portable.

    this article is a good point for you to start reading how class loaders ( are supposed to :-) ) work in application servers: http://www.theserverside.com/articles/article.tss?l=ClassLoading

    Cheers,
    Emil ( http://www.thekirschners.com/software/testare/testare.html )
  3. now there is no problem with classloader.
    my EJB is calling a class that bind an object in JNDI.
    while trying to bind the object i get the exception below :

    java.io.NotSerializableException: javax.naming.InitialContext
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1083)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1419)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1391)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1334)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:307)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.util.HashMap.writeObject(HashMap.java:1054)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.lang.reflect.Method.invoke(Method.java:386)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:917)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1383)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1334)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1419)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1391)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1334)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:307)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.util.HashMap.writeObject(HashMap.java:1054)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.lang.reflect.Method.invoke(Method.java:386)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:917)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1383)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1334)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1419)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1391)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1334)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:307)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.util.HashMap.writeObject(HashMap.java:1054)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.lang.reflect.Method.invoke(Method.java:386)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:917)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1383)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1334)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1419)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1391)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1334)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:307)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at com.ibm.ws.naming.util.Serialization.serializeObject(Serialization.java:69)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at com.ibm.ws.naming.util.Helpers.processJavaObjectForBinding(Helpers.java:591)
    [20/04/06 09:34:50:875 GMT] 3e59ed38 SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.doBind(CNContextImpl.java:1855)
    [20/04/06 09:34:50:891 GMT] 3e59ed38 SystemErr R at com.ibm.ws.naming.jndicos.CNContextImpl.bind(CNContextImpl.java:461)
    [20/04/06 09:34:50:891 GMT] 3e59ed38 SystemErr R at ma.gov.finances.impots.assiette.kernel.JNDIResourceProvider.store(JNDIResourceProvider.java:45)
    [20/04/06 09:34:50:891 GMT] 3e59ed38 SystemErr R at ma.gov.finances.impots.assiette.kernel.AbstractResourceProvider.init(AbstractResourceProvider.java:47)
    [20/04/06 09:34:50:891 GMT] 3e59ed38 SystemErr R at ma.gov.finances.impots.assiette.kernel.Kernel.reload(Kernel.java:28)
    [20/04/06 09:34:50:891 GMT] 3e59ed38 SystemErr R at ma.gov.finances.impots.assiette.kernel.Kernel.<init>(Kernel.java:21)
    [20/04/06 09:34:50:891 GMT] 3e59ed38 SystemErr R at ma.gov.finances.impots.assiette.kernel.StartupClass.startup(StartupClass.java:21)
    [20/04/06 09:34:50:891 GMT] 3e59ed38 SystemErr R at at ma.gov.finances.impots.assiette.ejb.server.SessionEJBBean.<clinit>(SessionEJBBean.java:47).null(Unknown Source)
    [20/04/06 09:34:50:891 GMT] 3e59ed38 SystemErr R at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    [20/04/06 09:34:50:891 GMT] 3e59ed38 SystemErr R at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:79)
    [20/04/06 09:34:50:891 GMT] 3e59ed38 SystemErr R at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:43)
    [20/04/06 09:34:50:891 GMT] 3e59ed38 SystemErr R at java.lang.reflect.Constructor.newInstance(Constructor.java:313)
    [20/04/06 09:34:50:891 GMT] 3e59ed38 SystemErr R at java.lang.Class.newInstance3(Class.java:363)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at java.lang.Class.newInstance(Class.java:301)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ejs.container.EJSContainer.loadBeanMetaData(EJSContainer.java:1349)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ejs.container.EJSContainer.getHomeWrapperCommon(EJSContainer.java:1012)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ejs.container.EJSContainer.getHomeInstance(EJSContainer.java:934)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ejs.container.EJSContainer.startBean(EJSContainer.java:913)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.EJBContainerImpl.startBean(EJBContainerImpl.java:1301)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.EJBContainerImpl.install(EJBContainerImpl.java:1034)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.EJBContainerImpl.start(EJBContainerImpl.java:1508)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:505)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:808)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:354)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:578)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:299)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:256)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
    [20/04/06 09:34:50:938 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
    [20/04/06 09:34:50:953 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:128)
    [20/04/06 09:34:50:953 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:536)
    [20/04/06 09:34:50:953 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:413)
    [20/04/06 09:34:50:953 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:183)
    [20/04/06 09:34:50:953 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.WsServer.start(WsServer.java:128)
    [20/04/06 09:34:50:953 GMT] 3e59ed38 SystemErr R at com.ibm.ws.runtime.WsServer.main(WsServer.java:225)
    [20/04/06 09:34:50:953 GMT] 3e59ed38 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [20/04/06 09:34:50:953 GMT] 3e59ed38 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
    [20/04/06 09:34:50:953 GMT] 3e59ed38 SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
    [20/04/06 09:34:50:953 GMT] 3e59ed38 SystemErr R at java.lang.reflect.Method.invoke(Method.java:386)
    [20/04/06 09:34:50:953 GMT] 3e59ed38 SystemErr R at com.ibm.ws.bootstrap.WSLauncher.main(WSLauncher.java:105)
    [20/04/06 09:34:50:953 GMT] 3e59ed38 SystemErr R at com.ibm.etools.websphere.tools.runner.api.ServerRunnerV5$1.run(ServerRunnerV5.java:97)

    i don't know why?
  4. does your object's class implement java.io.Serializable? if not, try that.

    As a general rule, each time you create a class who's instances will at some point be passed to the j2ee container, it must be serializable. When I say passed to the j2ee container I mean either as an ejb method parameter, return value, placed in jndi, placed in a jms message, etc. This must be because j2ee wants at any time to able to send the instance of your class over the network. This may be necessary if your application is deployed in a cluster, if your JNDI storage is a remote LDAP server, if you have remove EJB or JMS clients.

    hope this helps.

    Cheers, Emil
    ( http://www.thekirschners.com/software/testare/testare.html )