I am using the apress 'Beginning Java EE, from Novice to Professional' book. In its first EJB example it attempts to create am extremely simple stateless session bean. I am using jboss application server 4.2.2 and java Runtime Environment, Standard Edition 1.5.0. There are two classes and a remote interface as follows;
After this you create an ejb3 jar; jar cf SimpleSessionApp.ejb3 beans\*.java And deploy this jar to your jboss deploy directory while jboss is running. Once this is done you run the client with the following arguments and switches while inside the client directory of SimpleSessionApp;
java -Djava.naming.factory.initial= org.jnp.interfaces.NamingContextFactory -Djava.naming.factory.url.pkgs= org.jboss.namingrg.jnp.interfaces -Djava.naming.provider.url= localhost client.SimpleSessionClient Now is the time for all good men
After having done all of this I get the following error
The class you are trying to run does not have a main method. Check that the class file you are running really is SimpleSessionClient.class in the client directory.
Also, check that you are not running some other (and incorrect version) of this class. For example, these method signatures would cause the problem you have.
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Joined: Feb 19, 2008
The class definitely has a main method and it is the correct syntax. I am also sure that I am running SimpleSessionClient and not something else.
I've tried to create the project in eclipse and I got the same error. Then I tried to rejig the code a little and my SimpleSessionClient now looks like this;
Instead of providing the various properties at runtime I put them in a HashTable and pass them to the InitialContext constructor. Its now giving me a different error;
javax.naming.NameNotFoundException: SimpleSessionBeans 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:613) 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:667) at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627) at javax.naming.InitialContext.lookup(InitialContext.java:351) at client.SimpleSessionClient.main(SimpleSessionClient.java:28)
Joined: Sep 29, 2002
Somehow you have overcome your main method problem.
Your new problem occurs possibly because the EJB is not bound into the server's JNDI tree. The JNDI name for the EJB is specified in the jboss.xml deployment descriptor with the jndi-name element.
Joined: Feb 19, 2008
I thought that by simply deploying the application on Jboss you are adding it to the jndi lookup tree. Assuming this is not the case, how would I go about adding the EJB to the servers jndi tree? I have an application.xml file in my SimpleApp Ear, but it does not contain any jndi information. It looks something like this;
Since the topic is relatively old, I don't know if the OP still cares, but I had a very similar problem that stemmed from the fact "jar cf SimpleSessionApp.ejb3 beans\*.java" doesn't compile the classes, so I got an *.ejb3 that can not be deployed. I changed the line to "jar cf SimpleSessionApp.ejb3 beans\*.class" and it worked.