[jboss-user] [EJB 3.0] - JndiUtil - assumes HA-JNDI service is installed

andyredhead do-not-reply at jboss.com
Fri May 15 17:17:42 EDT 2009


Hi,

in JBoss AS 4.2.3 the code for org.jboss.ejb3.JndiUtil includes:


  |       Object object = null;
  | 
  |       try
  |       {
  |          object = jndiContext.lookup(binding);
  |       }
  |       catch (NameNotFoundException e)
  |       {
  |          Context haCtx = InitialContextFactory.getHAContext(jndiContext);
  |          object = haCtx.lookup(binding);
  |       }
  |       
  |       return object;
  |    }
  | 

So, if the local lookup fails, a call is made to the HA context - without checking to see if the haCtx object is not null...

If the HA JNDI service is not installed (i.e. such as in my development environment) then this call fails with a null pointer exception.

I stumbled upon this when I tried to configure an XML based entity manager injection into a stateless session bean and got the persistence-context-ref-name value wrong. I then had to install the ha jndi service (along with the default partition service) to find out what the actual name being looked up was.

I thing it would be helpful if there was a not-null check on haCtx, if haCtx is null then the original naming exception should be re-thrown so the logs show what jndi name failed.

Cheers,

Andy

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4231415#4231415

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4231415



More information about the jboss-user mailing list