I tried to create a simple EJB remote client sample but I keep getting java.lang.NoClassDefFoundError:
any time I tried to deploy the EJB.
The Remote Java Library File Structure is:
> TestRemoteInterface --Source Package -- bean --TestBeanRemote.java -- Libraries -- Java EE 6 API Library --JDK 1.8
The EJB Module File Structure is:
> TestEJBModule --Source Package -- bean --TestBean.java -- Libraries -- TestRemoteInterface – dist/TestRemoteInterface -- Java EE 6 API Library -- JDK 1.8
TestBeanRemote.java
package bean;
import javax.ejb.Remote;
@Remote
public interface TestBeanRemote {
String getName(String name);
}
TestBean .java
package bean;
import javax.ejb.Stateless;
@Stateless public class TestBean implements TestBeanRemote {
@Override public String getName(String name) { return "Here is my " + name; } }
Question: When I try to deploy the TestEJBModule on get the follow log:
WARN [org.jboss.modules] (MSC service thread 1-6) Failed to define class bean.TestBean in Module "deployment.TestEJBModule.jar:main" from Service Module Loader: java.lang.LinkageError: Failed to link bean/TestBean (Module "deployment.TestEJBModule.jar:main" from Service Module Loader)
....
Caused by: java.lang.NoClassDefFoundError: bean/TestBeanRemote
at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.8.0_05]
....
Caused by: java.lang.ClassNotFoundException: bean.TestBeanRemote from [Module "deployment.TestEJBModule.jar:main" from Service Module Loader] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
...
Caused by: java.lang.LinkageError: Failed to link bean/TestBean (Module "deployment.TestEJBModule.jar:main" from Service Module Loader) at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:487) [jboss-modules.jar:1.3.3.Final] .....
Caused by: java.lang.NoClassDefFoundError: bean/TestBeanRemote
.....
Caused by: java.lang.ClassNotFoundException: bean.TestBeanRemote from [Module "deployment.TestEJBModule.jar:main" from Service Module Loader] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
When I tried to deploy this same sample with Glassfish 4. It works fine.
NB: I am using netbeans 8.0.1
There appear to be a similar thread but it didn't help much. Thank you in advance.
I solved this problem by deploying the TestRemoteInterface jar to the sever first. Then I added it to the project manifest.mf as a dependency.
example:
Another option if you are using maven is the use maven dependencies manifest