We have a personal java library which is deployed on a tomcat server (v5.5 & v6). This library is shared with many web applications, so it was deployed on shared/lib in tomcat directory.
Exceptionaly, i have to create a new class into this library which lookup a jdbc datasource via JNDI.
For that, here my code :
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource dataSource = (DataSource) envCtx.lookup("jdbc/corp.xx.xx.xxxxDS");
All context are instantiated without problem. But when it lookup the jdbc datasource, i have an exception : Name jdbc not Found in Context
We are not in a webapp, is it a problem ? Is it possible to declare a context.xml with a ResourceLink ? how ?
nb: the jndi is setted in server.xml (a resource in GlobalNamingResources)