Two Laptop Bag*
The moose likes Websphere and the fly likes Issues testing Session Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Websphere
Bookmark "Issues testing Session Bean" Watch "Issues testing Session Bean" New topic
Author

Issues testing Session Bean

Ram Ramachandran
Greenhorn

Joined: Nov 13, 2002
Posts: 2
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");

//Properties props = System.getProperties();
Context ctx = new InitialContext(env);
Object obj = ctx.lookup("HelloHome");
HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow(obj, HelloHome.class);
Hello hello = home.create();


and it throws the following error;

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
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.


Merrill
Consultant, Sima Solutions
Ram Ramachandran
Greenhorn

Joined: Nov 13, 2002
Posts: 2
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
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
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.
 
 
subject: Issues testing Session Bean
 
Similar Threads
Error in running EJB client code
Exception accessing Local EJB
Problem while accessing JMS topic of WAS5.1
WSAD 5.0.1 JNDI Lookup
DataSource lookup problem from WebSphere 5.1 Stand alone Client Program