4
votes

I have a no-interface ejb deployed in an ear (MyEar.ear)

@Stateless
@LocalBean
public class MyService{
// stuff
}

The ear is deployed to jboss-6.0.0.Final

I confirmed the JNDI name from the server jmx console:

MyEar/MyService/no-interface

I'm trying to reference this ejb from another ejb in a war (outside the ear) in the same server:

@EJB(mappedName = "MyEar/MyService/no-interface")
private MyService myService;

I'm referencing the ear project from the war project in eclipse, and compilation is successful.

I keep getting a ClassNotFoundException exception when deploying the war:

java.lang.ClassNotFoundException: eg.com.test.MyService

Why is the ejb in the war not seeing the ejb from the other ear?

Edit: I updated to the follwing

remote interface

@Remote
public interface MyServiceRemote{
// stuff
}

ejb

@Stateless
public class MyService implements MyServiceRemote{
// stuff
}

ejb reference in a different application

@EJB(mappedName = "MyEar/MyService/remote")
private MyServiceRemote myService;

I verified the new JNDI name on the server: MyEar/MyService/remote

But i'm still getting the same exception, this time the interface not found:

java.lang.ClassNotFoundException: eg.com.test.MyServiceRemote

Update: I needed to package the Remote Interface with the war, its working correctly now.

2

2 Answers

2
votes

That EJB would need to have a remote interface, and you would access it the same as any remote EJB from the external WAR. The external WAR has a seperate class loader to the EAR, hence it will not find EAR classes.

0
votes

You must use a fully qualified name for referencing EJB in another application using EJB 3.1 portable naming format:

java:global/[<application-name>]/<module-name>/<bean-name>!<fully-qualified-bean-interface-name>