Naming issue...
seanlmcgill Dec 8, 2002 2:44 PMI'm having a problem just getting a hello world application working...
I've compiled & deployed a HelloWorld application, but when I try to run the client... I always get the following exception :
javax.naming.NameNotFoundException: Hello not bound at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
at sun.rmi.transport.StreamRemoteCall.executeCall (StreamRemoteCall.java:220)
.
.
.
Here's the code in a nutshell (- imports, comments, etc) :
// Remote interface
public interface HelloWorld extends EJBObject
{
 public String hello() throws RemoteException;
}
// Home interface
public interface HelloWorldHome extends EJBHome
{
 HelloWorld create() throws RemoteException, CreateException;
}
// EJB class
public class HelloWorldEJB implements SessionBean
{
 private SessionContext ctx;
 public void setSessionContext(SessionContext ctx)
 {
 this.ctx = ctx;
 }
 public void ejbRemove()
 {
 System.out.println( "ejbRemove()" );
 }
 public void ejbActivate()
 {
 System.out.println( "ejbActivate()" );
 }
 public void ejbPassivate()
 {
 System.out.println( "ejbPassivate()" );
 }
 /**
 * The method called to display the string "Hello World!"
 * on the client.
 */
 public String hello()
 {
 return "Hello World!";
 }
}
// XML Deployment stuff
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar>
 JBoss Hello World Application
 <display-name>Hello World EJB</display-name>
 <enterprise-beans>
 <ejb-name>Hello</ejb-name>
 helloworld.HelloWorldHome
 helloworld.HelloWorld
 <ejb-class>helloworld.HelloWorldEJB</ejb-class>
 <session-type>Stateless</session-type>
 <transaction-type>Bean</transaction-type>
 </enterprise-beans>
</ejb-jar>
// Client
public class HelloWorldClient
{
 public static void main(String[] args)
 {
 Hashtable env = new Hashtable();
 env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
 env.put(Context.PROVIDER_URL, "localhost:1099");
 env.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
 try
 {
 Context ctx = new InitialContext(env);
 Object obj = ctx.lookup( "Hello" );
 HelloWorldHome home = (HelloWorldHome)javax.rmi.PortableRemoteObject.narrow(obj, HelloWorldHome.class );
 HelloWorld helloWorld = home.create();
 System.out.println( helloWorld.hello());
 helloWorld.remove();
 }
 catch ( Exception e )
 {
 e.printStackTrace();
 System.out.println( "Exception: " + e.getMessage() );
 }
 }
}
1. I compiled the class files for everything, except the client and packaged them into HelloWorld.jar w/ the xml meta information.
2. Copied the HelloWorld.jar file into the jboss deploy directory and got the following :
14:22:08,397 INFO [MainDeployer] Starting deployment of package: file:/C:/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/H
14:22:08,413 INFO [MainDeployer] Deployed package: file:/C:/jboss-3.0.4_tomcat-4.1.12/server/default/deploy/HelloWorld.jar
(In the tutorial I noticed more output when deploying the interfaces, etc.. things refering to creating EJB objects)
3. Compiled & ran the client
 
     
     
    