I have an EJB with a remote interface deployed on Tomee:
*@Remote
public interface HelloEjbRemote {
String getMessage();
}
@Singleton(name = "myHelloEjbForRemote",
mappedName="myHelloEjbForRemoteMappedName")
@Remote(HelloEjbRemote.class)
public class HelloEjbRemoteImpl implements HelloEjbRemote{
/**
* Default constructor.
*/
public HelloEjbRemoteImpl() {
// TODO Auto-generated constructor stub
}
@Override
public String getMessage() {
return "Hello World";
}
}
*
When I try to call that EJB from another war deployed on the same Tomee, I
can look it up like this:
*Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "http://localhost/tomee/ejb");
InitialContext ctx;
try {
ctx = new InitialContext(p);
helloEjb = (HelloEjbRemote)
ctx.lookup("java:global/TomeeProj/myHelloEjbForRemote"); *
Or like that:
*helloEjb = (HelloEjbRemote)
ctx.lookup("java:global/TomeeProj/myHelloEjbForRemote!com.myPackage.HelloEjbRemote");*
When I try to access in remotely using a simple void main() client, this
works:
*Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "http://localhost:8080/tomee/ejb");
InitialContext ctx;
try {
ctx = new InitialContext(p);
HelloEjbRemote helloEjb = (HelloEjbRemote)
ctx.lookup("java:global/TomeeProj/myHelloEjbForRemote!com.myPackage.HelloEjbRemote");*
But this doesn't:
*Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "http://localhost:8080/tomee/ejb");
InitialContext ctx;
try {
ctx = new InitialContext(p);
HelloEjbRemote helloEjb = (HelloEjbRemote)
ctx.lookup("java:global/TomeeProj/myHelloEjbForRemote");*
I get *javax.naming.NameNotFoundException:
global/TomeeProj/myHelloEjbForRemote does not exist in the system. Check
that the app was successfully deployed. *
Shouldn't it work without the !Interface? It does when I do the lookup from
another war (on the same Tomee).
--
View this message in context:
http://tomee-openejb.979440.n4.nabble.com/Remote-EJB-JNDI-lookup-without-the-full-qualified-interface-name-doesn-t-always-work-tp4677663.html
Sent from the TomEE Users mailing list archive at Nabble.com.