tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ajay Bilotia <ajaybiloti...@gmail.com>
Subject JNDI look up with tomcat 8.5.6
Date Thu, 03 Nov 2016 04:41:20 GMT
Hi,

*Below code is for JNDI look up which is working fine in tomcat 7 and 8 .*

InitialContext  initContext = new InitialContext();
DataSource ds = (DataSource)initContext.lookup(initContext.getNameParser(
"" ).parse( "java:/comp/env/jdbc/BFDS" ));
Connection conn = ds.getConnection();

*Same code is not working in tomcat 8 after setting custom class loader as
per our requirement. In tomcat 7 it was working.*

DynamicClassLoader classLoader = ClassLoaderFactory.getHibernat
eClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);

My configuration is:
*Changes in conf/server.xml is:*

 <GlobalNamingResources>

<Resource  name="jdbc/BFDS" auth="Container" type="javax.sql.DataSource"
               maxTotal="100" maxIdle="30" maxWaitMillis="10000"
               username="db2admin" password="db2@dm1n" allowLinking="true"
driverClassName="com.ibm.db2.jcc.DB2Driver"
               url="jdbc:db2://localhost:50000/TRUNK"
   validationQuery="SELECT current date FROM sysibm.sysdummy1"/>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>


*Changes is conf/context.xml is: *
<Context>

    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource>

<ResourceLink  name="jdbc/BFDS"  global="jdbc/BFDS"
 type="javax.sql.DataSource"/>
</Context>


Please let me know if i am missing any configuration for tomcat 8. Thanks
in advance.

-- 
Thanks and Regards
Ajay Bilotia

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message