views:

177

answers:

3

I have deployed a war-file, with actionclasses and a facade, and a jar-file with ejb-components (a stateless bean, a couple of entities and a persistence.xml) on glassfish3. My problem is that i cant find my remote interface to the stateless bean from my facade.

My bean and interface looks like:

@Remote
public interface RecordService {...


@Stateless(name="RecordServiceBean", mappedName="ejb/RecordServiceJNDI")
public class RecordServiceImpl implements RecordService {

 @PersistenceContext(unitName="record_persistence_ctx")
 private EntityManager em;...

and if i look in the server.log the portable jndi looks like:

Portable JNDI names for EJB RecordServiceBean : [java:global/recordEjb/RecordServiceBean, java:global/recordEjb/RecordServiceBean!domain.service.RecordService]|#]

and my facade:

...InitialContext ctx= new InitialContext();
    try{
       recordService = (RecordService) ctx.lookup("java:global/recordEjb/RecordServiceBean!domain.service.RecordService");
      }
      catch(Throwable t){
       System.out.println("ooops");
       try{
        recordService = (RecordService)ctx.lookup("java:global/recordEjb/RecordServiceImpl");
       }
       catch(Throwable t2){
        System.out.println("noooo!");
       }...



  }

and when the facade makes the first call this exception occur:

javax.naming.NamingException: Lookup failed for 'java:global/recordEjb/RecordServiceBean!domain.service.RecordService' in SerialContext  [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacedomain.service.RecordService [Root exception is java.lang.ClassNotFoundException: domain.service.RecordService]]

and the second call:

javax.naming.NamingException: Lookup failed for 'java:global/recordEjb/RecordServiceBean' in SerialContext  [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacedomain.service.RecordService [Root exception is java.lang.ClassNotFoundException: domain.service.RecordService]]

I have also tested to inject the bean with the @EJB-annotation:

@EJB(name="RecordServiceBean")
 private RecordService recordService;

But that doesnt work either. What have i missed? I tried with an ejb-jar.xml but that shouldnt be nessesary. Is there anyone who can tell me how to fix this problem?

A: 

I found a sollution to this problem. If i pack the interfacefile in a jarfile and drop that jar in to WEB-INF/lib in the warfile the problem is solved.

andersmo
A: 

When server gets started, the global jndi names of the interfaces are displayed in console. Use those to lookup interfaces instead of trying to call them by giving names explicitly.

Nayan Wadekar
A: 

Have you tried commenting out all the ejb related sections of your xml files and then using just

@Stateless
public class RecordServiceImpl implements RecordService {

and then 

@EJB
private RecordService recordService;

They've tried to make the process fairly brain dead in EJB 3.1 Also, while JNDI browsing didn't make it into gf 3.0 you can dig up some info with

asadmin list-jndi-entries --context java:global/yourAppName
perilandmishap