tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Neil Aggarwal" <n...@JAMMConsulting.com>
Subject Has anyone gotten Castor to work using JNDI?
Date Fri, 01 Nov 2002 15:15:12 GMT
Hello:

Has anyone gotten Castor to work using JNDI and
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 JNDI 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


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message