-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Ajay,
On 11/3/16 12:41 AM, Ajay Bilotia wrote: > *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" )); Well, that looks suspicious. What's with the getNameParser stuff? Why not just: DataSource ds = (DataSource)initContext.lookup("java:/comp/env/jdbc/BFDS"); I've never seen any use of Context.getNameParser in the wild. I had to check the API to see what it did... > 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.* Does it work if you DONT have a custom ClassLoader? > DynamicClassLoader classLoader = ClassLoaderFactory.getHibernat > eClassLoader(); > Thread.currentThread().setContextClassLoader(classLoader); This looks like a huge hack. Why do you need to change the CCL? > My configuration is: *Changes in conf/server.xml is:* Changes from what? > <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. On the face of things, this looks okay. When you say it "doesn't work", what specifically happens when it doesn't work? - -chris -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBCAAGBQJYHQeRAAoJEBzwKT+lPKRYvCYQAK5s0bYHsizo77jAumDDxOAf n7haV96t4QXJVuBYGLIi3/hO5mGl9pdGwWZpiPBOhJ2fSIctiJowOQYCgjUPM2AR t95x313s425OAT4vIQ9LvY9yUZpk6EutnXKuCrR6MrZJmDGDnMlo66w6kF9OY3Ee CuYDnwDskTKO5oygp1lRx4oRpKmC1ZbAal2D9wLOO4nyI79d9kt3tHIBkrAAa7ba 9F629r3qwd8BMsWFWs2m7GrNpivWOAkCkwHCQonvJRfi0IB4NIys+yRwNMRY08DV EFVKxw139Hnsir1mzRkWiplwM3OrGYOY+juI34tJIDC8gfC7AmmuIB5Wy8kybLxE Ffwygr3LrU7RxPom0xB9JqyTH7JTog7HXsRFkZucMJr60N51n1nfWGz4N3gNznu5 yh1VgZKAmlsNCLfVfs1cI2DjauE22TC0OcNfs5BnKZEuGe9Ev5GBHs+hIO5ctyrc +kiRoOAxoLCbf7vgEsGce1ikYmtobUImRwQYMlB9g8u48t5v9w22at0/O7nTMBug yQlAaJxyNG46JgJ3i97mhgZYcU5yCHZKlPgtaAQXSP+ueIW63lkI6cCs/1H9IAWd zWae9+MHF3ArKFLslO/N0lAyV8RAZ/fvyYlzkrVmsIU43OaRLCBJwBzBF7Fqe1HZ EndPJ77CtnNNnW0DYqp3 =pW9I -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org