The provide url should be like this:  

props.setProperty("java.naming.provider.url", "ejbd:"+hostName+":"+port);

On Mon, May 24, 2010 at 8:01 PM, zecas <> wrote:


I'm trying to connect a standalone java client application to an EJB in
Apache Geronimo, but with no success so far.

It's a starting project so I can learn something about EJB and remote
invocation, and ... well, I'll put some info and hope someone can put some
light on the matter.

My Geronimo has the following ports, which are displayed on console, when
starting up:

 Listening on Ports:
      0   Derby Connector
     80   Tomcat Connector HTTP BIO HTTP
   1099   RMI Naming
   1150 CORBA Naming Service
   2001 OpenEJB ORB Adapter
   4201   OpenEJB Daemon
   6882 OpenEJB ORB Adapter
   8009   Tomcat Connector AJP AJP
   8443   Tomcat Connector HTTPS BIO HTTPS
   9999   JMX Remoting Connector
  61613   ActiveMQ Transport Connector
  61616   ActiveMQ Transport Connector

I'm working with Apache Geronimo 2.1.2, in a windows system, installed

My EJB3 has the following definition:

@Stateful(name="test-bean", mappedName="test-bean-map")
public class TestBean implements TestLocal, TestRemote {

   public String hello(String user) {
       return "Hello " + user + ", welcome to this EJB!";

   public List getList(String user) {


And the interfaces, which are part of the EJB client JAR:

public interface TestRemote {

   public String hello(String user);


public interface TestLocal {

   public List getList(String user);


The EAR has the EJB and a WAR module that successfully injects TestLocal and
uses it.

Now I've started a Java project from scratch, and inside a runnable class
main method I do something like:

       String hostName = "localhost";
       String port = "4201";

       Properties props = new Properties();

       props.setProperty("java.naming.provider.url", hostName+":"+port);
//        props.setProperty("", "username");
//        props.setProperty("", "passwd");

       Context ic = null;
       try {
           ic = new InitialContext(props);

           // java:comp/env/
           // @Stateful(name="test-bean", mappedName="test-bean-map")

           TestRemote testBean = (TestRemote) PortableRemoteObject.narrow(

           String result = testBean.hello( "peter" );
           log( result );

       } catch(Throwable ex) {
       } finally {
           if( ic!=null ) {

The result:

java.lang.RuntimeException: Invalid response from server: -1
   at org.apache.openejb.client.JNDIContext.lookup(
   at javax.naming.InitialContext.lookup(

I've tried using ports 1099, 1150 and 4201, with the same result. Shouldn't
I use port 4201   OpenEJB Daemon?

So what am I missing here?

In apache geronimo, where am I suppose to check the jndi name configured? I
can't seem to find it ... although it works on the webapp that goes with the
EJB (on the same EAR).

I've deployed the EAR to Geronimo, without any ejb descriptor and no
geronimo plan descriptor. The EJB uses annotations. But the webapp uses the
injected EJB dependency, so I assume it is properly configured.

Also, can anyone tell me where I should look for the available EJBs? In
JBoss I can check a tree of JNDI entries, and the EJB nammings can be found
there, but in Geronimo I cannot find this EJB name ... I searched in
console->Debug Views (JMX and JNDI) they both present a tree, but I didn't
find the EJB entry that was deployed.

View this message in context:
Sent from the Users mailing list archive at