I am new to JBOSS, and I tried to deploy EJB30 in JBoss4.0.4.GA. I can deploy my EJB30
archive file and I can see it in JMX-console. However I cannot use client to call the
stateless session bean. I don't write any deployment description since in EJB30 we can
use annotation.
I can see my ejb30 deployed in JMX-CONSOLE.
jar=HelloBean30.jar,name=HelloBean,service=EJB3
module=HelloBean30.jar,service=EJB3
The Exception is following:
Exception in thread "main" javax.naming.NameNotFoundException: examples not
bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:466)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:707)
at java.lang.Thread.run(Thread.java:595)
at
sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:492)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:471)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at examples.session.stateless.HelloClient.main(HelloClient.java:34)
The following is my session bean, remote interface and client.
-------------HelloBean.java------------
package examples.session.stateless;
import javax.ejb.Remote;
import javax.ejb.Stateless;
/**
* Demonstration stateless session bean.
*/
@Stateless
@Remote(Hello.class)
public class HelloBean implements Hello {
public String sayHello() {
System.out.println("hello()");
return "Hello, World!";
}
-----------------Hello.java-----------
package examples.session.stateless;
///import org.jboss.annotation.ejb.RemoteBinding;
//@RemoteBinding(jndiBinding="/examples/session/stateless/Hello")
public interface Hello {
String sayHello();
}
---------------HelloCLient.java--------------------
package examples.session.stateless;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import examples.session.stateless.Hello;
/**
* This class is an example of client code which invokes
* methods on a simple, remote stateless session bean.
*/
public class HelloClient {
public static void main(String[] args) throws Exception {
/*
* Obtain the JNDI initial context.
*
* The initial context is a starting point for
* connecting to a JNDI tree. We choose our JNDI
* driver, the network location of the server, etc
* by passing in the environment properties.
*/
Hashtable<String,String> h= new Hashtable<String,String>();
h.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
h.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
h.put(Context.PROVIDER_URL, "jnp://localhost:1099");
Context ctx = new InitialContext(h);
// Context ctx = new InitialContext();
/*
* Get a reference to a bean instance, looked up by class name
*/
Hello hello = (Hello) ctx.lookup("/examples/session/stateless/Hello/remote");
/*
* Call the hello() method on the bean.
* We then print the result to the screen.
*/
System.out.println(hello.sayHello());
}
}
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3990465#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...