I have this EJB
@Stateless
public class HelloBean{
public String sayHello(){
return "hello";
}
}
When I test with this unit test:
@Test
public void testEmbeddedPersistence() throws NamingException {
assertTrue(true);
Map<String, Object> props = new HashMap<String, Object>();
props.put(EJBContainer.MODULES, new File("target/classes"));
props.put("org.glassfish.ejb.embedded.glassfish.instance.root", "./src/test/resources/glassfish-testing-domain");
ec = EJBContainer.createEJBContainer(props);
ctx = ec.getContext();
String s = "java:global/classes/HelloBean";
HelloBean helloBean = (HelloBean) ctx.lookup(s);
assertNotNull(helloBean);
assertABunchOfStuff();
ec.close();
}
everything works fine.
But when I change it to
@Stateless
public class HelloBean implements RemoteHello{
public String sayHello(){
return "hello";
}
}
@Remote
public interface RemoteHello{
public String sayHello();
}
@Test
public void testEmbeddedPersistence() throws NamingException {
assertTrue(true);
Map<String, Object> props = new HashMap<String, Object>();
props.put(EJBContainer.MODULES, new File("target/classes"));
props.put("org.glassfish.ejb.embedded.glassfish.instance.root", "./src/test/resources/glassfish-testing-domain");
ec = EJBContainer.createEJBContainer(props);
ctx = ec.getContext();
String s = "java:global/classes/HelloBean!com.mycompany.remoteInterface.RemoteHello";
RemoteHello remoteHello = (RemoteHello) ctx.lookup(s);
assertNotNull(remoteHello);
assertABunchOfStuff();
ec.close();
}
I get a javax.naming.NamingException
the weirdest thing is, When the EJBContainer is intializing it says:
INFO: EJB5181:Portable JNDI names for EJB HelloBean: [java:global/classes/HelloBean!com.mycompany.remoteInterface.RemoteHello, java:global/classes/HelloBean] Feb 10, 2012 3:55:22 PM com.sun.ejb.containers.BaseContainer initializeHome
followed shortly after:
Tests in error: testEmbeddedPersistence(com.mycompaony.HelloBean): Lookup failed for 'java:global/classes/HelloBean!com.mycompany.remoteInterface.RemoteHello' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
How can I get a successful jndi lookup with a remote interface.
Thanks