javax.naming.NameNotFoundException: Name jdbc is not bound in this ContextBy Roger Keays, 15 April 2008 |
javax.naming.NameNotFoundException: Name jdbc is not bound in this ContextIt seems that Tomcat 5.5 and 6.0 DataSourceRealms don't like referring to JNDI resources declared in the same context. The following configuration gives me a javax.naming.NameNotFoundException:
<Context path="/">
<!-- connection pool for database -->
<Resource name="jdbc/data" auth="Container" type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost/test"
username="postgres" password=""
maxActive="5" maxIdle="2" maxWait="-1"/>
<!-- authentication realm -->
<Realm className="org.apache.catalina.realm.DataSourceRealm"
dataSourceName="jdbc/data" digest="MD5"
userTable="web_users" userRoleTable="web_user_roles"
userNameCol="id" userCredCol="password" roleNameCol="role"/>
</Context>
However, if I move the JNDI resource up it works as expected:
<GlobalNamingResources>
<!-- connection pool for database -->
<Resource name="jdbc/data" auth="Container" type="javax.sql.DataSource"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost/test"
username="postgres" password=""
maxActive="5" maxIdle="2" maxWait="-1"/>
</GlobalNamingResources>
...
<Context path="/">
<!-- authentication realm -->
<Realm className="org.apache.catalina.realm.DataSourceRealm"
dataSourceName="jdbc/data" digest="MD5"
userTable="web_users" userRoleTable="web_user_roles"
userNameCol="id" userCredCol="password" roleNameCol="role"/>
</Context>
Odd...
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
About Roger Keays
|
Roger Keays is an artist, an engineer, and a student of life. He has no fixed address and has left footprints on 40-something different countries around the world. Roger is addicted to surfing. His other interests are music, psychology, languages, the proper use of semicolons, and finding good food.
|
why it showing this type of Message
javax.naming.NameNotFoundException: Name CustomerManagerJNDI is not bound in this Context
SEVERE: Servlet.service() for servlet action threw exception
java.lang.NoClassDefFoundError: javax/ejb/EJBHome
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1817)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1325)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at com.jlcindia.struts.delegate.SessionBeanDelegate.validateUser(SessionBeanDelegate.java:25)
at com.jlcindia.struts.action.LoginAction.execute(LoginAction.java:29)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
@see tomcat-users:
Roger Keays wrote:
> Is that the intended behaviour?
Yes. If you want a realm to use a context defined datasource rather than a global one you need to set: localDataSource="true" on the realm
It is documented in the howto but not the realm docs. I'll fix that now. http://tomcat.apache.org/tomcat-6.0-doc/realm-howto.html#DataSourceRealm
Mark
grrr...