https://issues.apache.org/bugzilla/show_bug.cgi?id=49631
Summary: Custom DatabaseResourceProvider extension cannot get app context JNDI resources Product: Tomcat 6 Version: 6.0.28 Platform: PC OS/Version: Windows NT Status: NEW Severity: normal Priority: P2 Component: Catalina AssignedTo: dev@tomcat.apache.org ReportedBy: matt.helg...@gmail.com I've written a custom extension to the DatabaseResourceProvider that allows our application to store some subset of files in the database. In order to get a db connection I'm trying to lookup a datasource via JNDI: private Connection getConnection() throws SQLException, NamingException { Context initContext = new InitialContext(); System.out.println("here"); DataSource ds = (DataSource)initContext.lookup("java:/comp/env/"+JDBC_SYSTEM_JNDI); return ds.getConnection(); } I've found that in some cases it does get the datasource and in others it throws a namingexception that the resource was not found. I debugged it out and found that in certain cases it works if the resources is being requested through a servlet or JSP call but when its a direct request for a static file such as an image or CSS file it fails. In those failing cases I've found that its getting the server naming context and not the web app context. More digging into the tomcat naming stuff showed that the way it determines the naming context to use is derived by the current threads class loader. Looks like the class loader is not getting replaced with the web apps class loader in the case of static resource serving. Could something be added to make sure the class loader for the thread is always updated to the current web app class loader before calling into the DirContext classes? -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org