--
Neil Aggarwal
JAMM Consulting, Inc.
(972) 612-6056, http://www.JAMMConsulting.com
Custom Internet
Development Websites, Ecommerce, Java,
databases
-----Original Message-----
From: Aadithya Deshpande [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 01, 2002 9:19 AM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Can't create JDO instance using Tomcat & JNDIIs "jdo" a context that's automatically created for you by Tomcat?
I don't know much about Tomcat, and it's JNDI namespacing, but in Resin, in order to provide the jdo/whatever naming, I had to create a startup servlet that would create the "jdo" subcontext like so:
InitialContext initCtx = ( new InitialContext()).lookup( "java:comp/env" );
Context ctx = initCtx.createSubcontext( "jdo" );
ctx.bind( "whatever", jdo )there's some error checking in there, too, to check if that subcontext exists ( so multiple startup servlets could be provided ), but that's the basic gist of it.
-a
-----Original Message-----
From: Neil Aggarwal [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 01, 2002 10:10 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] Can't create JDO instance using Tomcat & JNDI
Hello:
I am tryng to configure castor 0.9.4 thru JNDI using
the JBCP pooling mechanism. My platform is Tomcat 4.0.6,
Apache 2.0.43, and MySQL 3.23.53a on RedHat Linux 8.0.When I try to load the JDO object from the context, here is
the error I get:javax.naming.NamingException: Cannot create resource instance
at
org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.
java:167)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:311)
at org.apache.naming.NamingContext.lookup(NamingContext.java:834)
at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
at org.apache.naming.NamingContext.lookup(NamingContext.java:181)
at org.apache.naming.NamingContext.lookup(NamingContext.java:822)
at org.apache.naming.NamingContext.lookup(NamingContext.java:194)
at org.apache.naming.SelectorContext.lookup(SelectorContext.java:183)
at javax.naming.InitialContext.lookup(InitialContext.java:354)
at top.Utils.getJDO(Utils.java:31)Here is the code that I am using to get the JDO instance:
package top;
// imports
public class Utils {
public static synchronized JDO getJDO() throws NamingException,
SQLException, MappingException {
ClassLoader loader = Utils.class.getClassLoader();
URL url = "loader.getResource("database.xml");
JDO.loadConfiguration(url.toString());
InitialContext ctx = new InitialContext();
return (JDO) ctx.lookup( "java:comp/env/jdo/videoSearchPPV" );
}
}Here is my 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>
<resource-ref>
<description>Resource reference to DataSource</description>
<res-ref-name>jdbc/videoSearchPPV</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<description>Resource reference to JDO</description>
<res-ref-name>jdo/videoSearchPPV</res-ref-name>
<res-type>org.exolab.castor.jdo.JDO</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>Here is my database.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE databases PUBLIC "-//EXOLAB/Castor JDO Configuration DTD Version
1.0//EN" "http://castor.exolab.org/jdo-conf.dtd">
<database name="videoSearchPPV" engine="mysql">
<jndi name="java:comp/env/jdbc/videoSearchPPV" />
<mapping href="mapping.xml"/>
</database>Here is what I put in tomcat's server.xml:
<Service name="Tomcat-Apache">
<Connector ...>
<Engine ...>
<DefaultContext reloadable="true" >
<Resource auth="Container" name="jdo/videoSearchPPV"
scope="Shareable" type="org.exolab.castor.jdo.JDO"/>
<Resource auth="Container" name="jdbc/videoSearchPPV"
scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/videoSearchPPV">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://localhost:3306/videoSearchPPV</value>
</parameter>
<parameter>
<name>password</name>
<value>[The password to my database]</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>100</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>100</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>username</name>
<value>videoSearchPPV</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>30000</value>
</parameter>
</ResourceParams>
</DefaultContext>Any ideas?
Thanks,
Neil.
--
Neil Aggarwal
JAMM Consulting, Inc. (972) 612-6056, http://www.JAMMConsulting.com
Custom Internet Development Websites, Ecommerce, Java, databases-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev
