Question

When I deploy my application to the integrated WebSphere server, I get NoClassDefFoundErrors for two classes that are contained in the same project. Note: I call the missing class com.my.package.MyClass here.

The consuming project contains Session Beans and imports the exporting project in "Configure Build path". The exporting project is listed as "EAR library" if the consuming project in the Enterprise Explorer. The exporting project is a normal java project that contains com.my.package.MyClass. It exports its source folders.

The exceptions look like that:

com.ibm.websphere.naming.CannotInstantiateObjectException: Exception occurred while the JNDI NamingManager was processing a javax.naming.Reference object. [Root exception is com.ibm.ejs.container.ContainerEJBException: Unable to initialize deferred EJB.; nested exception is: java.lang.NoClassDefFoundError: com.my.package.MyClass]
    at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:1033)
    at com.ibm.ws.naming.urlbase.UrlContextHelper.processBoundObjectForLookup(UrlContextHelper.java:175)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.processBoundObjectForLookup(UrlContextImpl.java:1736)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1249)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1225)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1276)
    at javax.naming.InitialContext.lookup(Unknown Source)
...

or like that

[22.03.13 14:56:12:994 CET] 00000025 EJBContainerI E   WSVR0068E: Attempt to start EnterpriseBean MyEar#MyJar.jar#MyBean failed with exception: java.lang.NoClassDefFoundError: com.my.package.MyClass
    at java.lang.Class.getDeclaredMethodsImpl(Native Method)
    at java.lang.Class.getDeclaredMethods(Class.java:673)
    at com.ibm.ws.metadata.ejb.EJBMDOrchestrator.processTimeoutMetaData(EJBMDOrchestrator.java:6494)
    at com.ibm.ws.metadata.ejb.EJBMDOrchestrator.finishBMDInit(EJBMDOrchestrator.java:1488)
    at com.ibm.ws.runtime.component.EJBContainerImpl.finishDeferredBeanMetaData(EJBContainerImpl.java:5036)
    at com.ibm.ws.runtime.component.EJBContainerImpl.initializeDeferredEJB(EJBContainerImpl.java:4845)
    at com.ibm.ejs.container.HomeOfHomes$1.run(HomeOfHomes.java:406)
    at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    at com.ibm.ejs.container.HomeOfHomes.getHome(HomeOfHomes.java:403)
    at com.ibm.ejs.container.HomeOfHomes.getHome(HomeOfHomes.java:339)
    at com.ibm.ejs.container.util.EJBLocalInterfaceObjectFactory.getObjectInstance(EJBLocalInterfaceObjectFactory.java:139)
    at javax.naming.spi.NamingManager.getObjectInstanceByFactoryInReference(Unknown Source)
    at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
    at com.ibm.ws.naming.util.Helpers.processSerializedObjectForLookupExt(Helpers.java:927)
    at com.ibm.ws.naming.urlbase.UrlContextHelper.processBoundObjectForLookup(UrlContextHelper.java:175)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.processBoundObjectForLookup(UrlContextImpl.java:1736)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1249)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1225)
    at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1276)
    at javax.naming.InitialContext.lookup(Unknown Source)
...

I'm using IBM Rational Application Developer for WebSphere in Version 8.0.4 and IBM WebSphere Application Server in Version 7.0.0.11

My workspace has no errors in the Problems view.

What I already tried: - Starting RAD with the -clean parameter - Refreshing all projects in the Enterprise Explorer - Project > Clean - In the Server view: stopping, restarted, cleaning, publishing - Closing and restarting RAD

First I had a second problem: in RAD I wasn't able to find com.my.package.MyClass by Ctrl + Shift + T. I solved it by deleting files (*.index files and the "savedIndexNames.txt") in /.metadata/.plugins/org.eclipse.jdt.core. But unfortunately that didn't solve the problem at runtime / deploy time. :-(

Can somebody give me hints?

Thanks in advance!

Was it helpful?

Solution

what you need to do is add the Java Project as a Deployment Assembly for the EAR project.

This will than automatically add the $PROJECT.jar from your Java Project under /lib/ folder for thie .ear

WebSphere automatically pics .jar files from lib folder and add them to the classpath and these .jar can be found by all EJB.jar and .war packaged inside the .ear file.

So, right click your EAR project, go to properties, and than selec "Deployment Assembly" than add your Java Project there, you should than see the generated jar under lib folder.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top