Powered by Syntax Highlighter scripts!

javax.naming.NameNotFoundException {jndiName} not found in context "java:" works in Tomcat but not in Websphere

We were using Tomcat application server in developer systems and have Websphere App server in Stage environment.
Our application which was working fine in Tomcat so far was giving the exception below after deploying it to the WAS server.

javax.naming.NameNotFoundException {jndiName} not found in context "java:"

The jndi Lookups were working fine in tomcat server without any issues. It seemed Websphere was expecting the JNDI names differently at first on seeing the exception. 
  • The JNDI entries are configured correctly on the WAS server
  • Our web layer include Jersey/Jackson for REST services and not using Spring or Struts for MVC layer.
  • The JNDI Lookup above is failing from an utility jar. This utility jar is also developed as a separate Java project.
  • The web application that we are deploying requires a jndi --- call it – jdbc/appjndi  and this lookup works fine.
  • The jndi lookup from the jar file for the jndi – call it jdbc/utiljarjndi -- is failing giving above exception.  
After browsing through some links and we see that the web.xml is having <resource-ref> entries for the jdbc/appjndi only.
    We added the <resource-ref> entries for the jdbc/utiljarjndi  also and this resolved the issue of JNDI lookup.

No comments: