Search code examples
javajakarta-eeejb

Inject of remote EJB interface into external module


I have an EAR application with three modules:

  • beans are in "app-ejb" module
  • remote interfaces are in "app-remote"
  • web services are in "app-war"
  • app-ejb and app-war use app-remote as library.

all are packaged in "app.ear".

This is working fine, but now I have to use the same beans outside the EAR application, and injection is not working.

I have in app-ejb:

@Stateless
@LocalBean
public class Services implements ServicesRemote {
  [...]
}

and his remote interface in app-remote:

@Remote
public interface ServicesRemote {
  [...]
}

In my app-war I can inject the remote bean without problem:

@Stateless
@LocalBean
public class UseServices {
  @EJB
  private ServicesRemote services;
  [...]
}

Anyway in my external ejb application, deployed as stand-alone and using the same ejb-remote as library, if I try to inject the same EJB like this:

@Stateless
@LocalBean
public class UseServicesFromAnotherApp {
  @EJB
  private ServicesRemote services;
  [...]
}

Glassfish (4.1) give me an error "Class [ Lcom/[...]/ServicesRemote; ] not found".

Is this expected? How can I inject the remote bean correctly?


Solution

  • The problem was probably generated by a number of hot deploys, made glassfish unstable. When I restarted glassfish my code start to work properly (it's actually still working).

    Sorry for posting here without trying to restart glassfish first.