WebSphere 6.0 EJB lookup on single host issue

Filed under: Development — lars @ 04:36:48 pm

I recently discovered a problem and workaround with WAS 6.0.2 in conjunction with RAD.  I had multiple WAS profiles running on my machine and was trying to call an EJB running on one from the other, and I got the following error:

javax.naming.NameNotFoundException: Context: MyPcNode01Cell/nodes/MyPcNode01/servers/server1,
name: ejb/com/myejb/MyEjbHome: First component in name myejb/MyEjbHome not found. 
Root exception is org.omg.CosNaming.NamingContextPackage.NotFound:
IDL:omg.org/CosNaming/NamingContext/NotFound:1.0

When checking in the Universal Test Client I would see that my EJB was indeed running, and that the client was using the correct JNDI name.

This appears to be a bug in WAS.  It seems when you have two servers on the same machine using different profiles with different cell/node names, WAS can get the prefix of the EJB JNDI lookup wrong.  This prefix (eg: CellName/nodes/Nodename/servers/ServerName) normally identifies which cell/node is being called (for example in a clustered environment).  When they are on the same physical box, WAS seems to sometimes get confused and use the cell/node prefix of the caller, instead of the callee.

The workaround to this is to go to the WAS admin console on the remote side of the EJB call and navigate to WAS Admin Console -> Servers -> Application Servers -> server1 -> Ports -> BOOTSTRAP_ADDRESS.  From here, enter a hostname that is different from your machine name.  Localhost is a good option, or even making up a hostname and putting it as an entry in your hosts file pointing to 127.0.0.1 seems to work.  This appears to fool WAS into seeing the remote EJB as on a different machine, causing it to use the correct JNDI prefix.

Comments

  • brian
    Lars,

    I enjoy the broad array of technologies you discuss on your blog. But please spare us from mention of WebSphere and EJBs. The Java development community, of which I am a member, has evolved to the point where it doesn't care about commercial app servers, when there are plenty of free ones, and follow-the-leader arcane specs.

    Comment by brian [Visitor] — 12/04/08 @ 10:21

  • lars
    Believe me Brian - I know where you're coming from. But unfortunately some of us still have to work with this stuff sometimes! I'm glad you enjoy the blog otherwise.

    Comment by lars [Member] — 12/07/08 @ 22:09

Leave a comment

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>


Options:
(Line breaks become <br />)
(Set cookies for name, email & url)




powered by  b2evolution