JBoss Community

java client use ejb remote service, exception(jboss5.0 + jdk1.6)

created by princesshan1977 princesshan1977 in EJB Development - View the full discussion

I  use myeclise +

 

jboss-5.1.0.GA   + jdk1.6

 

service code like this  

 

@Remote

public interface IHelloEJBService {

public String sayHelloEJB(String name);

}

 

@Stateless
public class HelloEJBService implements IHelloEJBService {

public String sayHelloEJB(String name) {
  // TODO Auto-generated method stub
  String msg = "hello" + name + ", Welcome to EJB world!";
  System.out.print(msg);
  return msg;
}
}

 

then I deploy the service。

 

I create  a new  java   client   project,code like this

 

public class TestClient {

private static Context context;

/**

  * @param args

  */

public static void main(String[] args) {

    try

  {

   Context ctx = getInitialContext();

   Object object = ctx.lookup("HelloEJBService/remote");

  

   IHelloEJBService service= (IHelloEJBService)PortableRemoteObject.narrow(object, IHelloEJBService.class);

   System.out.println(service.sayHelloEJB("Client "));

  }

  catch(Exception e)

  {

   e.printStackTrace();

  }

}

 

protected static Context getInitialContext() throws Exception

{

  if(context == null)

  {

   Hashtable props = new Hashtable();

   props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

   props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

   props.put(Context.PROVIDER_URL, "jnp://localhost:1099");

   context = new InitialContext(props);

  }

  return context;

}

}

 

I  copy  all jars of    D:\jboss-5.1.0.GA\client\    to  client project   and   add  all to classpath.

run  the  client  code  ,occur  exception

javax.naming.NamingException: Could not dereference object [Root exception is java.lang.reflect.UndeclaredThrowableException]

at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1504)

at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:822)

at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)

at javax.naming.InitialContext.lookup(InitialContext.java:392)

at TestClient.main(TestClient.java:18)

Caused by: java.lang.reflect.UndeclaredThrowableException

at $Proxy0.createProxyBusiness(Unknown Source)

at org.jboss.ejb3.proxy.impl.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:129)

at org.jboss.ejb3.proxy.impl.objectfactory.session.stateless.StatelessSessionProxyObjectFactory.getProxy(StatelessSessionProxyObjectFactory.java:79)

at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:158)

at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)

at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1479)

at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1496)

... 4 more

Caused by: java.lang.ClassNotFoundException: com.test.ejb.IHelloEJBService

at org.jboss.remoting.serialization.ClassLoaderUtility.loadClass(ClassLoaderUtility.java:103)

at org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:86)

at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:247)

at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveProxyClass(ObjectInputStreamWithClassLoader.java:253)

at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1531)

at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)

at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:119)

at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1792)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1751)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)

at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)

at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)

at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObjectVersion2_2(JavaSerializationManager.java:238)

at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:138)

at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:123)

at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.versionedRead(MicroSocketClientInvoker.java:1220)

at org.jboss.remoting.transport.socket.MicroSocketClientInvoker.transport(MicroSocketClientInvoker.java:850)

at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:165)

at org.jboss.remoting.Client.invoke(Client.java:1724)

at org.jboss.remoting.Client.invoke(Client.java:629)

at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:60)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

at org.jboss.ejb3.proxy.impl.remoting.IsLocalProxyFactoryInterceptor.invoke(IsLocalProxyFactoryInterceptor.java:72)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)

at $Proxy0.createProxyBusiness(Unknown Source)

at org.jboss.ejb3.proxy.impl.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:129)

at org.jboss.ejb3.proxy.impl.objectfactory.session.stateless.StatelessSessionProxyObjectFactory.getProxy(StatelessSessionProxyObjectFactory.java:79)

at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:158)

at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)

at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1479)

at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1496)

at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:822)

at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)

at javax.naming.InitialContext.lookup(InitialContext.java:392)

at TestClient.main(TestClient.java:18)

at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:72)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

at org.jboss.ejb3.proxy.impl.remoting.IsLocalProxyFactoryInterceptor.invoke(IsLocalProxyFactoryInterceptor.java:72)

at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:102)

at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:62)

... 11 more

Reply to this message by going to Community

Start a new discussion in EJB Development at Community