I'm an experienced J2EE developer who is having difficulty understanding why my application won't behave appropriately when deployed to websphere 5. I'm a websphere newbie so please go easy on me ..
My application runs without issue when deployed to JBoss 3.2.3. The application contains three stateless session beans and a single mdb. Two of my session beans reference the third which adds messages to a queue and is also called by my mdb in order to process the message asynchronously. All communication between beans is done using local interfaces to avoid network overhead.
How does websphere know what jndi name to assign to a given session bean? I do not see any location where this information is defined. In JBoss, you must include the jndi-name and local-jndi-name in the META-INF\jboss.xml file of the ejb.jar. The server reads this file at deployment time and creates the appropriate jndi entries.
When I deployed my enterprise application to websphere I was prompted to enter a jndi name for each of my non-mdb enterprise beans. I entered the remote jndi names here .. not the local jndi names. Is this correct?
Lets say I entered 'EchoService' as the remote jndi name for a bean that I would like to lookup. What is the jndi name that I should lookup in order to communicate with my local ejb objects?
Patrick, You are correct that you should enter the remote name. WebSphere automatically assigns the local name. If your remote name is "ejb/com/javaranch/MyBean", the local name would be "local:ejb/ejb/com/javaranch/MyBean"
I did not preface these jndi names with 'ejb/'. Shouldn't matter .. but could that be the issue?
I can lookup each of the jndi names listed above without issue. However, I have never been able to find a local object. I have taken your advice and configured my application to lookup the following jndi names:
OnDemandService --> works but is a remote object .. and results in local nDemandService --> javax.naming.NameNotFoundException: Name "OnDemandService" not found in context "local:". java:comp/env/local nDemandService --> javax.naming.NameNotFoundException: Name "comp/env/local nDemandService" not found in context "java:".
I've heard some people saying that you need to use the java:comp/env as a prefix to jndi names. When should I be prefixing my jndi name with this string?
I was looking in the WebSphere\AppServer\installedApps folder and I see that websphere generated some files in my ejb-jar during the deployment of my enterprise application:
Forgive me .. I was trying to do about 100 things at once when I tried to follow your advice. In the haze, I must have missed the fact that you told me to prefix the jndi name with 'local:ejb/'. When I adjusted my jndi name to be 'local:ejb/OnDemandService' everything worked!