Hi I am trying to write a hello world test client in am using RAD 6.0 and WAS 5.1 test environment. I have created and deployed a simple session bean but have problems accessing it using a test client.
Following is the code I use; Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory"); env.put(Context.PROVIDER_URL, "iiop://localhost:2809");
Exception in thread "P=485337 =0:CT" javax.naming.NameNotFoundException: Context: localhost/nodes/localhost/servers/server1, name: HelloHome: First component in name HelloHome 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:3491) at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1519) at com.ibm.ws.naming.jndicos.CNContextImpl.doLookup(CNContextImpl.java:1480) at com.ibm.ws.naming.jndicos.CNContextImpl.lookupExt(CNContextImpl.java:1187) at com.ibm.ws.naming.jndicos.CNContextImpl.lookup(CNContextImpl.java:1067) at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:144) at javax.naming.InitialContext.lookup(InitialContext.java:361) at HelloTestClient.main(HelloTestClient.java:29)
Can some one help debug the problem.
Thanks, Ram
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
posted
0
The message is telling you that it can't find the JNDI name "HelloHome". If you took the defaults when you created the session bean, the JNDI name of your bean's Home is most likely not "HelloHome". It is probably something like "ejb/com/mycompany/mypackage/HelloHome" To see what the JNDI name of the bean is, open the EJB deployment descriptor, select the bean tab and select your session bean. Then in the lower right part of the panel, scroll down to WebSphere Bindings. There you will see the JNDI name of the bean.
Thanks Merril. I did correct that missing JNDI parameter and then I found my bean was not deployed when I started the server. When I right click to deploy the session bean I get the following error. Would you know the cause?
I am trying to just get the session bean to pring "Hello" and I have copied the sample code from an online book.
Deployment from com.ibm.etools.ejbdeploy.EJBDeployer had errors: RMIC command failed on project: HelloWorldEJB with message:
c:\dev\workspace\HelloWorldEJB\ejbModule\EJSRemoteStatelessHelloWorldEJB_2f219ba2.java:21: Method doesJaccNeedsEJBArguments(EJSRemoteStatelessHelloWorldEJB_2f219ba2) not found in class com.ibm.ejs.container.EJSContainer. if (container.doesJaccNeedsEJBArguments( this )) ^ c:\dev\workspace\HelloWorldEJB\ejbModule\EJSRemoteStatelessHelloWorldEJB_2f219ba2.java:25: Incompatible type for method. Can't convert java.lang.Object[] to java.lang.String. HelloBean beanRef = (HelloBean)container.preInvoke(this, 0, _EJS_s, _jacc_parms); ^ c:\dev\workspace\HelloWorldEJB\ejbModule\EJSRemoteStatelessHelloWorldEJB_2f219ba2.java:28: Exception java.rmi.RemoteException is never thrown in the body of the corresponding try statement. catch (java.rmi.RemoteException ex) { ^ c:\dev\workspace\HelloWorldEJB\ejbModule\EJSRemoteStatelessHelloWorldEJBHome_2f219ba2.java:21: Method doesJaccNeedsEJBArguments(EJSRemoteStatelessHelloWorldEJBHome_2f219ba2) not found in class com.ibm.ejs.container.EJSContainer. if (container.doesJaccNeedsEJBArguments( this )) ^ c:\dev\workspace\HelloWorldEJB\ejbModule\EJSRemoteStatelessHelloWorldEJBHome_2f219ba2.java:25: Incompatible type for method. Can't convert java.lang.Object[] to java.lang.String. EJSStatelessHelloWorldEJBHomeBean_2f219ba2 _EJS_beanRef = (EJSStatelessHelloWorldEJBHomeBean_2f219ba2)container.preInvoke(this, 0, _EJS_s, _jacc_parms);
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
posted
0
Was the tutorial you used specifically for creating an EJB within RAD? If not, I'd suggest you scrap the tutorial and use one that was specifically made for RAD. Here is a link to one. Hopefully, then your EJB will deploy successfully.
Ryan Haman
Greenhorn
Joined: May 28, 2008
Posts: 1
posted
0
I just found out why RAD does this (at least when using WebSphere 6.0). If you have any public methods that take a variable with the name "container", you will get this error. As soon as you change that variable, everything will work.