Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

EJB3 example

phantasmoApr 16 2008 — edited Apr 20 2008
I've got myself a Java EE book and started learning. So, the first EJB3 example was as following:
package beans;
import javax.ejb.Remote;
@Remote
public interface SimpleSession
{
    public String getEchoString(String clientString);
}
package beans;
import javax.ejb.Stateless;
@Stateless
public class SimpleSessionBean implements SimpleSession {
      public String getEchoString(String clientString) {
         return clientString + " - from session bean";
      }
}
package client;
import beans.SimpleSession;
import javax.naming.InitialContext;
public class SimpleSessionClient {
   public static void main(String[] args) throws Exception
   {
      InitialContext ctx = new InitialContext();
      SimpleSession simpleSessio = (SimpleSession) ctx.lookup(SimpleSession.class.getName());
      for (int i = 0; i < args.length; i++) {
         String returnedString = simpleSession.getEchoString(args);
System.out.println("sent string: " + args[i] + ", received string: " + returnedString);
}
}
}
For some reason, I can't run this. I opened the command prompt, typed
set CLASSPATH=.;C:\java\jboss\lib\concurrent.jar;C:\java\jboss\lib\jboss-common.jar;C:\java\jboss\server\all\lib\jboss.jar;C:\java\jboss\server\all\lib\jboss-remoting.jar;C:\java\jboss\server\all\lib\jboss-transaction.jar;C:\java\jboss\server\all\lib\jnpserver.jar;C:\java\jboss\server\all\deploy\ejb3.deployer\jboss-ejb3.jar;C:\java\jboss\server\all\deploy\ejb3.deployer\jboss-ejb3x.jar;C:\java\jboss\server\all\deploy\jboss-aop.deployer\jboss-aop.jar;C:\java\jboss\server\all\deploy\jboss-aop.deployer\jboss-aspect-library.jar
My CLASSPATH sys variable is set to include every jar in JavaEE\lib directory. I did "jar cf SimpleSessionApp.ejb3 beans\*.java" and copied the resulting ejb3 into jboss\server\all\deploy. Then, when  tried running the accursed thing with 
java -Djava.naming.factory.initial=org.jnp.interfaces.NamingContextFactory -Djava.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces -Djava.naming.provider.url=localhost client.SimpleSessionClient Now is the time for all good men
it said 
Exception in thread "main" javax.naming.NameNotFoundException: beans.SimpleSession not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
I know it has to be a very bothersome question, but could you please help me understanding what happened here and how should I resolve it? I get the concept of binding a name to a resource beforehand and asking for it later, but what I do not get is where should I have done it so that I do not get this error...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 18 2008
Added on Apr 16 2008
14 comments
128 views