You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Atishay Kumar <at...@gmail.com> on 2004/09/21 21:41:03 UTC
cud not solve javax.naming.NamingException: Cannot create resource instance
hi,
i am trying to do MySql Connection Pooling in Tomcat 4.1.27. I am
getting the following error
------------------
javax.naming.NamingException: Cannot create resource instance
------------------
doing some googly revealed that i need some commons-.. jar files to be
present in common/lib folder. but i already had them in common/lib
folder. the files in lib folder are
--------------------------
activation.jar commons-dbcp.jar jdbc2_0-stdext.jar
naming-common.jar
ant.jar commons-logging-api.jar jndi.jar
naming-factory.jar
classes111.jar commons-pool.jar jta.jar
naming-resources.jar
classes12.jar jasper-compiler.jar mail.jar
servlet.jar
commons-collections.jar jasper-runtime.jar
mysql-connector-java-3.0.11-stable-bin.jar
-------------------------
my server.xml
<Context path="/student" docBase="student_directory" debug="0"
priveledge="true">
</Context>
<Context path="/testing" docBase="test" debug="0" priveledge="true">
<Resource name="jdbc/testDataSource" auth="Container"
type="java.sql.DataSource"/>
<ResourceParams name="jdbc/testDataSource">
<parameter>
<name>user</name>
<value>root</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/mysql</value>
</parameter>
</ResourceParams>
</Context>
------------------------------------
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>This is a test folder </display-name>
<description>
Welcome to the test folder
</description>
<resource-ref>
<description>MySql Datasource for Student Directory</description>
<res-ref-name>jdbc/testDataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
-----------------------------
mysql_connection_test.jsp
<%@ page import="java.sql.*" %>
<%@ page import="javax.naming.*"%>
<%@ page import="javax.sql.*"%>
<html>
<head>
<title>test</title>
</head>
<body>
<%
try
{
Context ctx= new InitialContext();
if(ctx==null)
throw new Exception("not able to find intial context");
DataSource
ds=(DataSource)ctx.lookup("java:comp/env/jdbc/testDataSource");
if(ds!=null)
{
Connection conn=ds.getConnection();
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select current_date()");
if(rs==null)
out.println("No rowset returned");
else
{
rs.next();
out.println("Current Date"+rs.getString(1));
}
rs.close();
stmt.close();
conn.close();
}
}
catch(Exception e)
{
out.println("Error found: "+e);
}
%>
</body>
</html>
-------------------------------------------
please help me in resolving it.
thanks
--
:)
Atishay Kumar
Btech, SEM VII
DA-IICT
Gandhinagar - 382009
India
ph: +91 9825383948
/****************************************************************************
* Learn the rules as you would need them to break them properly *
****************************************************************************/
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: cud not solve javax.naming.NamingException: Cannot create resource instance
Posted by Antony Paul <an...@hotmail.com>.
Do you have MySQL JDBC Driver jar ?. Put it in common\lib and restart Tomcat
to test
rgds
Antony Paul
----- Original Message -----
From: "Atishay Kumar" <at...@gmail.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, September 22, 2004 9:30 AM
Subject: Re: cud not solve javax.naming.NamingException: Cannot create
resource instance
> i was not putting the following lines, that's why i namingException
> was coming. BUT I AM NOW GETTING THE DataSource as null. Any clues??
>
> ----------------
> <parameter>
> <name>factory</name>
> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
> </parameter>
> -------------------------
>
>
> On Tue, 21 Sep 2004 19:41:03 +0000, Atishay Kumar
> <at...@gmail.com> wrote:
> > hi,
> > i am trying to do MySql Connection Pooling in Tomcat 4.1.27. I am
> > getting the following error
> > ------------------
> > javax.naming.NamingException: Cannot create resource instance
> > ------------------
> > doing some googly revealed that i need some commons-.. jar files to be
> > present in common/lib folder. but i already had them in common/lib
> > folder. the files in lib folder are
> > --------------------------
> > activation.jar commons-dbcp.jar jdbc2_0-stdext.jar
> > naming-common.jar
> > ant.jar commons-logging-api.jar jndi.jar
> > naming-factory.jar
> > classes111.jar commons-pool.jar jta.jar
> > naming-resources.jar
> > classes12.jar jasper-compiler.jar mail.jar
> > servlet.jar
> > commons-collections.jar jasper-runtime.jar
> > mysql-connector-java-3.0.11-stable-bin.jar
> > -------------------------
> > my server.xml
> >
> > <Context path="/student" docBase="student_directory" debug="0"
> > priveledge="true">
> > </Context>
> > <Context path="/testing" docBase="test" debug="0"
priveledge="true">
> > <Resource name="jdbc/testDataSource" auth="Container"
> > type="java.sql.DataSource"/>
> > <ResourceParams name="jdbc/testDataSource">
> > <parameter>
> > <name>user</name>
> > <value>root</value>
> > </parameter>
> > <parameter>
> > <name>password</name>
> > <value></value>
> > </parameter>
> > <parameter>
> > <name>driverClassName</name>
> > <value>com.mysql.jdbc.Driver</value>
> > </parameter>
> > <parameter>
> > <name>url</name>
> > <value>jdbc:mysql://localhost:3306/mysql</value>
> > </parameter>
> > </ResourceParams>
> > </Context>
> > ------------------------------------
> > web.xml
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> >
> > <!DOCTYPE web-app
> > PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> > "http://java.sun.com/dtd/web-app_2_3.dtd">
> > <web-app>
> > <display-name>This is a test folder </display-name>
> > <description>
> > Welcome to the test folder
> > </description>
> > <resource-ref>
> > <description>MySql Datasource for Student Directory</description>
> > <res-ref-name>jdbc/testDataSource</res-ref-name>
> > <res-type>javax.sql.DataSource</res-type>
> > <res-auth>Container</res-auth>
> > </resource-ref>
> > </web-app>
> > -----------------------------
> > mysql_connection_test.jsp
> >
> > <%@ page import="java.sql.*" %>
> > <%@ page import="javax.naming.*"%>
> > <%@ page import="javax.sql.*"%>
> > <html>
> > <head>
> > <title>test</title>
> > </head>
> > <body>
> > <%
> > try
> > {
> > Context ctx= new InitialContext();
> > if(ctx==null)
> > throw new Exception("not able to find intial context");
> > DataSource
> > ds=(DataSource)ctx.lookup("java:comp/env/jdbc/testDataSource");
> > if(ds!=null)
> > {
> > Connection conn=ds.getConnection();
> > Statement stmt=conn.createStatement();
> > ResultSet rs=stmt.executeQuery("select current_date()");
> > if(rs==null)
> > out.println("No rowset returned");
> > else
> > {
> > rs.next();
> > out.println("Current Date"+rs.getString(1));
> > }
> > rs.close();
> > stmt.close();
> > conn.close();
> >
> > }
> > }
> > catch(Exception e)
> > {
> > out.println("Error found: "+e);
> > }
> >
> > %>
> > </body>
> > </html>
> > -------------------------------------------
> > please help me in resolving it.
> >
> > thanks
> > --
> > :)
> > Atishay Kumar
> > Btech, SEM VII
> > DA-IICT
> > Gandhinagar - 382009
> > India
> > ph: +91 9825383948
> >
/***************************************************************************
*
> > * Learn the rules as you would need them to break them properly *
> >
****************************************************************************
/
> >
>
>
>
> --
> :)
> Atishay Kumar
> Btech, SEM VII
> DA-IICT
> Gandhinagar - 382009
> India
> ph: +91 9825383948
>
/***************************************************************************
*
> * Learn the rules as you would need them to break them properly *
>
****************************************************************************
/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
Re: cud not solve javax.naming.NamingException: Cannot create resource instance
Posted by Atishay Kumar <at...@gmail.com>.
i was not putting the following lines, that's why i namingException
was coming. BUT I AM NOW GETTING THE DataSource as null. Any clues??
----------------
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
-------------------------
On Tue, 21 Sep 2004 19:41:03 +0000, Atishay Kumar
<at...@gmail.com> wrote:
> hi,
> i am trying to do MySql Connection Pooling in Tomcat 4.1.27. I am
> getting the following error
> ------------------
> javax.naming.NamingException: Cannot create resource instance
> ------------------
> doing some googly revealed that i need some commons-.. jar files to be
> present in common/lib folder. but i already had them in common/lib
> folder. the files in lib folder are
> --------------------------
> activation.jar commons-dbcp.jar jdbc2_0-stdext.jar
> naming-common.jar
> ant.jar commons-logging-api.jar jndi.jar
> naming-factory.jar
> classes111.jar commons-pool.jar jta.jar
> naming-resources.jar
> classes12.jar jasper-compiler.jar mail.jar
> servlet.jar
> commons-collections.jar jasper-runtime.jar
> mysql-connector-java-3.0.11-stable-bin.jar
> -------------------------
> my server.xml
>
> <Context path="/student" docBase="student_directory" debug="0"
> priveledge="true">
> </Context>
> <Context path="/testing" docBase="test" debug="0" priveledge="true">
> <Resource name="jdbc/testDataSource" auth="Container"
> type="java.sql.DataSource"/>
> <ResourceParams name="jdbc/testDataSource">
> <parameter>
> <name>user</name>
> <value>root</value>
> </parameter>
> <parameter>
> <name>password</name>
> <value></value>
> </parameter>
> <parameter>
> <name>driverClassName</name>
> <value>com.mysql.jdbc.Driver</value>
> </parameter>
> <parameter>
> <name>url</name>
> <value>jdbc:mysql://localhost:3306/mysql</value>
> </parameter>
> </ResourceParams>
> </Context>
> ------------------------------------
> web.xml
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> <!DOCTYPE web-app
> PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd">
> <web-app>
> <display-name>This is a test folder </display-name>
> <description>
> Welcome to the test folder
> </description>
> <resource-ref>
> <description>MySql Datasource for Student Directory</description>
> <res-ref-name>jdbc/testDataSource</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
> </web-app>
> -----------------------------
> mysql_connection_test.jsp
>
> <%@ page import="java.sql.*" %>
> <%@ page import="javax.naming.*"%>
> <%@ page import="javax.sql.*"%>
> <html>
> <head>
> <title>test</title>
> </head>
> <body>
> <%
> try
> {
> Context ctx= new InitialContext();
> if(ctx==null)
> throw new Exception("not able to find intial context");
> DataSource
> ds=(DataSource)ctx.lookup("java:comp/env/jdbc/testDataSource");
> if(ds!=null)
> {
> Connection conn=ds.getConnection();
> Statement stmt=conn.createStatement();
> ResultSet rs=stmt.executeQuery("select current_date()");
> if(rs==null)
> out.println("No rowset returned");
> else
> {
> rs.next();
> out.println("Current Date"+rs.getString(1));
> }
> rs.close();
> stmt.close();
> conn.close();
>
> }
> }
> catch(Exception e)
> {
> out.println("Error found: "+e);
> }
>
> %>
> </body>
> </html>
> -------------------------------------------
> please help me in resolving it.
>
> thanks
> --
> :)
> Atishay Kumar
> Btech, SEM VII
> DA-IICT
> Gandhinagar - 382009
> India
> ph: +91 9825383948
> /****************************************************************************
> * Learn the rules as you would need them to break them properly *
> ****************************************************************************/
>
--
:)
Atishay Kumar
Btech, SEM VII
DA-IICT
Gandhinagar - 382009
India
ph: +91 9825383948
/****************************************************************************
* Learn the rules as you would need them to break them properly *
****************************************************************************/
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org