Register / Login
Win a copy of
The Way of the Web Tester: A Beginner's Guide to Automating Tests
this week in the
EJB and other Java EE Technologies
Getting javax. naming. NameNotFoundException from new Thread created by JSP page
posted 11 years ago
I am trying to implement the strategy to show the user a waiting page, which a complex SQL query is processed in the background in a separate thread.
When I try to get an
and do a lookup, I get the following exception
javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".
Here is the code which I am using to get a DataSource
Context ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup(jndiName); Connection con = ds.getConnection();
Its the same code I use throughout my application and it works everywhere, except from the new thread. Here is the code from
<% session.removeAttribute("bbtb"); %> <jsp:useBean id="bbtb" class="DapisSVLBBTaskBean" scope="session"> <jsp:setProperty name="bbtb" property="reqNo" /> </jsp:useBean> <% bbtb.setRunning(true); new Thread(bbtb).start(); %> <jsp:forward page="waiting.jsp" />
I am using WebSpehre 5.0
Any ideas would be highly apcodeciated. I just can't seem to understand why would this happen only in new thread but works fine in rest of the places in my WebApplication.
How Tomcat Works: connection pooling in tomcat
Configuring MYSQL Datasource
Access context parameters from Bean.