I am trying to access an EJB via JSE Standalone application.
I was struggling a lot with JNDI Names not being found during lookup.
After some research without any solution I found in the Glassfish server log after a deploy a message stating something like:
"[glassfish 4.1] [INFO] [AS-EJB-00054] [javax.enterprise.ejb.container] [tid: _ThreadID=47 _ThreadName=admin-listener(4)] [timeMillis: 1424811833554] [levelValue: 800] [[ Portable JNDI names for EJB HelloBean:java:global/ponteWS/HelloBean!br.com.pontews.HelloRemote, java:global/ponteWS/HelloBean!br.com.pontews.HelloBean]]] "
I tried the remote name and voilá!!! It works.
I tried the other name and did not work.
Here comes the questions:
1-Why the JNDI name is so weird???? Is there something I can do in order to avoid the package name in front of the name of the bean? 2-What is the error I get when acessing the bean directly instead the HelloRemote Interface?
Here is the HelloRemote:
package br.com.pontews;
import javax.ejb.Remote;
@Remote
public interface HelloRemote {
public String sayHello(String name);
}
Here is the Bean:
package br.com.pontews;
import java.io.Serializable;
import javax.ejb.LocalBean;
import javax.ejb.Remote;
import javax.ejb.Stateless;
@Stateless(name="HelloBean")
@LocalBean
@Remote
public class HelloBean implements HelloRemote, Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Default constructor.
*/
public HelloBean() {
}
public String sayHello(String name) {
return "Hello," + name + ".!" ;
}
}
Here is the call that works:
Object lookup =
ctx.lookup("java:global/ponteWS/HelloBean!br.com.pontews.HelloRemote");
Here is the call that does not works:
Object lookup =
ctx.lookup("java:global/ponteWS/HelloBean!br.com.pontews.HelloBean");
And finally the error I get with call that does not work:
Exception in thread "main" javax.naming.CommunicationException: Communication exception for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is java.rmi.RemoteException: CORBA NO_IMPLEMENT 1398079489 Maybe; nested exception is: org.omg.CORBA.NO_IMPLEMENT: ----------BEGIN server-side stack trace---------- org.omg.CORBA.NO_IMPLEMENT: WARNING: 01000001: Missing local value implementation vmcid: SUN minor code: 1 completed: Maybe : : : Caused by: java.lang.ClassNotFoundException: br.com.pontews.EJB31_Generated__HelloBean__Intf____Bean (no security manager: RMI class loader disabled)
Thanks