Hi, ALL,

I am trying to write a standalone EJB client, but failed.

I have a standalone OpenEJB in C drive, I place simple-stateless-1.0.jar into its app folder. This jar is from OpenEjb example. It works, from log I can see,

///////////////
2011-05-09 21:07:30,825 - INFO - Jndi(name=CalculatorImplLocal) --> Ejb(deployment-id=CalculatorImpl) 2011-05-09 21:07:30,827 - INFO - Jndi(name=CalculatorImplRemote) --> Ejb(deployment-id=CalculatorImpl) 2011-05-09 21:07:30,856 - INFO - Created Ejb(deployment-id=CalculatorImpl, ejb-name=CalculatorImpl, container=My Stateless Container) 2011-05-09 21:07:30,856 - INFO - Deployed Application(path=C:\openejb-3.1.4\apps\simple-stateless-1.0.jar)
///////////////

Now the clinent is
//////////////////////
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory"); //properties.put("java.naming.provider.url", "ejbd://localhost:4201"); properties.put("java.naming.provider.url", "http://localhost:4204/ejb";);

        InitialContext initialContext = new InitialContext(properties);

        Object object = initialContext.lookup("CalculatorImplRemote");
/////////////////////////////
It always give me error:

/////////////////
Exception in thread "main" javax.naming.NamingException: Cannot lookup '/CalculatorImplRemote'. [Root exception is java.rmi.RemoteException: Cannot open object input stream to server (OEJP/3.1) : null; nested exception is:
    java.io.EOFException]
    at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:240)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at com.Test.main(Test.java:20)
Caused by: java.rmi.RemoteException: Cannot open object input stream to server (OEJP/3.1) : null; nested exception is:
    java.io.EOFException
    at org.apache.openejb.client.Client.processRequest(Client.java:159)
    at org.apache.openejb.client.Client.request(Client.java:42)
    at org.apache.openejb.client.JNDIContext.request(JNDIContext.java:87)
    at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:234)
    ... 2 more
Caused by: java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
    at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
    at java.io.ObjectInputStream.<init>(Unknown Source)
at org.apache.openejb.client.EjbObjectInputStream.<init>(EjbObjectInputStream.java:31)
    at org.apache.openejb.client.Client.processRequest(Client.java:156)
    ... 5 more

////////
I am using  openejb-itests-standalone-client-3.0.jar as its reference api.

Please help me on this.

Thanks
Edward


Reply via email to