[jboss-user] [Beginners Corner] - Proxy problem
qler
do-not-reply at jboss.com
Fri Aug 11 04:56:05 EDT 2006
Hello! I've a little problem over here. I want to create a simple stand-alone client, which creates a bean and invokes a method on it.
Here's the code for beans:
package bean;
|
| import javax.ejb.Stateless;
|
| @Stateless
| public class CreaterRemote implements Creater {
|
| public Foo create() {
| return new FooRemote();
| }
|
| }
package bean;
|
| import javax.ejb.Stateful;
|
| @Stateful
| public class FooRemote implements Foo, java.io.Serializable {
|
| private static final long serialVersionUID = 7316005043521549778L;
| private String name = "Hello!";
|
| public String print() {
| return this.name;
| }
|
| }
The code of the client:
package client;
|
| import java.util.Properties;
|
| import javax.naming.Context;
|
| import bean.Creater;
| import bean.Foo;
|
| public class Client {
| public static void main(String [] args) {
| try {
|
| Context jndiContext = getInitialContext( );
| Object ref = jndiContext.lookup("CreaterRemote/remote");
| Creater factory = (Creater)ref;
|
| Foo foo = factory.create();
|
| System.out.println(foo.print());
|
| } catch (javax.naming.NamingException ne){ne.printStackTrace( );}
| }
|
| public static Context getInitialContext( )
| throws javax.naming.NamingException {
|
| Properties p = new Properties( );
| p.put(Context.INITIAL_CONTEXT_FACTORY,
| "org.jnp.interfaces.NamingContextFactory");
| p.put(Context.URL_PKG_PREFIXES,
| "org.jboss.naming:org.jnp.interfaces");
| p.put(Context.PROVIDER_URL, "localhost");
| return new javax.naming.InitialContext(p);
| }
| }
The client class is situated in the other project with remote interfaces imported.
When i try to ru it, the following errors occure:
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
| at $Proxy1.create(Unknown Source)
| at client.Client.main(Client.java:18)
| Caused by: java.lang.ClassNotFoundException: bean.Foo
| at java.net.URLClassLoader$1.run(Unknown Source)
| at java.security.AccessController.doPrivileged(Native Method)
| at java.net.URLClassLoader.findClass(Unknown Source)
| at java.lang.ClassLoader.loadClass(Unknown Source)
| at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
| at java.lang.ClassLoader.loadClass(Unknown Source)
| at org.jboss.remoting.loading.RemotingClassLoader.loadClass(RemotingClassLoader.java:50)
| at org.jboss.remoting.loading.ObjectInputStreamWithClassLoader.resolveClass(ObjectInputStreamWithClassLoader.java:139)
| at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
| at java.io.ObjectInputStream.readClassDesc(Unknown Source)
| at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
| at java.io.ObjectInputStream.readObject0(Unknown Source)
| at java.io.ObjectInputStream.readObject(Unknown Source)
| at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:122)
| at java.io.ObjectInputStream.readExternalData(Unknown Source)
| at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
| at java.io.ObjectInputStream.readObject0(Unknown Source)
| at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
| at java.io.ObjectInputStream.readSerialData(Unknown Source)
| at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
| at java.io.ObjectInputStream.readObject0(Unknown Source)
| at java.io.ObjectInputStream.readObject(Unknown Source)
| at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:128)
| at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:66)
| at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:279)
| at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:143)
| at org.jboss.remoting.Client.invoke(Client.java:525)
| at org.jboss.remoting.Client.invoke(Client.java:488)
| at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:55)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:61)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:55)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:65)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateful.StatefulRemoteProxy.invoke(StatefulRemoteProxy.java:133)
| ... 2 more
As I understand the server didn't generated proxy stub, as it must do. Maybe I have to change some settings on the server or something else?
I would be very grateful if somebody could help me.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3964555#3964555
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3964555
More information about the jboss-user
mailing list