I am new to EJB, so please can someone help. I am trying to access a stateless session EJB from a class but am having some problems. I am using Rational Application Developer 6 with Websphere Application Server 6.
I have been trying a number of different ways to do a JNDI lookup on the session EJB. Whic I will give examples of below. I am using a class with a main method to test this. I have an EJB Project that contins a session EJB called "Manager". Then I have a Web Project that has a class with a main method which is trying to access the EJB in the EJB Project.
I have 'Run Validation' over the EJB project successfully. I then did a 'Deploy' over the EJB Project.I have modified the Web Projects web.xml file to contain the Manager EJB (see below). I make sure the WAS6 server is running. Then I invoke the test class with the main method:
<pre> javax.naming.NameNotFoundException: Context: your-ky2idxv32cNode01Cell/nodes/your-ky2idxv32cNode01/servers/server1, name: cell/nodes/localhost/servers/server1/ejb/Manager: First component in name localhost/servers/server1/ejb/Manager not found. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL mg.org/CosNaming/NamingContext/NotFound:1.0 at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:85) at com.ibm.WsnOptimizedNaming._NamingContextStub.resolve_complete_info(Unknown Source) at com.ibm.ws.naming.jndicos.CNContextImpl.cosResolve(CNContextImpl.java:4045) ....
06-Aug-2005 10:48:05 com.ibm.ws.naming.java.javaURLContextFactory SEVERE: javaAccessorNotSet javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment. at com.ibm.ws.naming.java.javaURLContextFactory.isNameSpaceAccessable(javaURLContextFactory.java:98) at com.ibm.ws.naming.urlbase.UrlContextFactory.getObjectInstance(UrlContextFactory.java:73) at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:592) .... </pre>
I have also tried all of the above without setting the the properties in the InitialContext() constructor.
javax.naming.InitialContext ctx = new InitialContext();
I get the same Exception:
<pre> 06-Aug-2005 10:50:42 com.ibm.ws.naming.java.javaURLContextFactory SEVERE: javaAccessorNotSet javax.naming.ConfigurationException: Name space accessor for the java: name space has not been set. Possible cause is that the user is specifying a java: URL name in a JNDI Context method call but is not running in a J2EE client or server environment. at com.ibm.ws.naming.java.javaURLContextFactory.isNameSpaceAccessable(javaURLContextFactory.java:98) at com.ibm.ws.naming.urlbase.UrlContextFactory.getObjectInstance(UrlContextFactory.java:73) at javax.naming.spi.NamingManager.getURLObject(NamingManager.java:592)
My ejb-jar.xml in the EJB Project is the following:
Blikkies, Are you using WSAD or WebSphere server? If WSAD, the easiest thing to do is test the EJB using the Universal Test Client. This will tell you whether the error is in the EJB configuration or your client code/configuration.
To get to the Universal Test Client, right click the server when it is running. Then just drill down to your bean.
I am using IBM Rational Application Developer 6 with WebSphere 6 server.
Do you know how I can invoke the test client n this tool?
Joined: Jun 12, 2003
I managed to get the Universal Test Client to run my session EJB. But oly once I changed the 'Server Connection Type and Admin port' in the server overview from RMI(Better performance) to SOAP(More firewall compatable)? - I guess the firewall must have been affecting it. But it does not expln wht I could not do local lookups, but the client work now.
However, I cannot seem to invoke the session EJB from outside the client still. How do I testt what the JNDI name is?
In the Universal Test Clienrt, when I expand the JNDI Explorer, I can see my EJB there (Method visibility, create()). But how do I know what the JNDI names? (The name I should put in the ctx.lookup("xxx")?
author & internet detective
Blikkies, You can't do local lookups from the client by default because it runs in a separate JVM. Note that the local and remote JNDI names are different. The local adds "local:ejb/" to the name. You can test the remote JNDI name by typing it into the Universal Test Client. To get it in the first place, you can see what is defined on your EJB in the J2EE perspective or see what the path is that you drilled down to in the Universal Test Client.
Note: I am not yet using RAD 6, so this procedure is for WSAD 5.1.