Two Laptop Bag*
The moose likes Struts and the fly likes javax naming name not found exception jndi in struts2.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "javax naming name not found exception jndi in struts2.0" Watch "javax naming name not found exception jndi in struts2.0" New topic
Author

javax naming name not found exception jndi in struts2.0

jaan bhavsar
Ranch Hand

Joined: Aug 23, 2008
Posts: 32
Hi to all Ranchers,
I am making connection pool with tomcat.i define necessary entry in server.xml,web.xml and made one listener class to get the connection.but i am getting error "javax naming name not found exception jndi" when i start the tomcat server.and also in my listener value of dataSourcejndi name is displayed null.

Please guide me how to get the jndidatasource name in listener .I attached three files for your reference in single file.
1)web.xml
2)server.xml
3)Applistener.java

web.xml


2)Server.xml(in tomcat)



3)Listener Class to get the jndidatasource name
i am getting the jndiname null
package util;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.sql.DataSource;

public class AppListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent sce) {

ServletContext servletContext = sce.getServletContext();
String dataSourceJndiName = servletContext.getInitParameter
("dataSourceJndiName");
System.out.println("jndiname-->"+dataSourceJndiName);
try{
Context context = new InitialContext();
DataSource dataSource = (DataSource)context.lookup
("dataSourceJndiName");

servletContext.setAttribute("dataSource",dataSource);
}catch(Exception e)
{
e.printStackTrace();
}
}
public void contextDestroyed(ServletContextEvent des) {

}

}


Thank you in advance
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You should ask in a JNDI/Tomcat-oriented forum; this has nothing to do with Struts.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax naming name not found exception jndi in struts2.0
 
Similar Threads
Configure tomcat resource factory
Name jdbc is not bound in this Context
Pooling w/Tomcat 5 - Oracle
javax.naming.NamingException- Cannot create resource instance
Tomcat Database Connection Pooling Error