[prev in list] [next in list] [prev in thread] [next in thread] 

List:       castor-dev
Subject:    [castor-dev]  Can't create JDO instance using Tomcat & JNDI
From:       "PALLUEL Sylvie" <sylvie.palluel () cnamts ! fr>
Date:       2003-02-25 14:45:09
[Download RAW message or body]

Hi,

I am trying to configure castor 0.9.4 thru JNDI using 
the DBCP pooling mechanism.  My platform is Tomcat 4.0.3, 
and MySQL 3.23.49.

I've found one of your messages in Castor-Dev list archive (Friday,
November 01, 2002 10:10 AM).

I have the same pb you seemed to have then.

You said  "I got it to work" , but you don't say how .

Could you give me the right code for web.xml, server.xml , database.xml
and  the getJDO method ?

Thanks for your help.

Sylvie.

___________________
CREDI RA
Sylvie Palluel

sylvie.palluel@cnamts.fr
___________________


------------------------------------------------------------------------
--------

From: Neil Aggarwal 
Subject: Re: [castor-dev] Can't create JDO instance using Tomcat & JNDI 
Date: Sat, 02 Nov 2002 21:12:28 -0800 

------------------------------------------------------------------------
--------

Title: RE: [castor-dev] Can't create JDO instance using Tomcat & JNDI
Aadithya:
 
Thanks for the info.  I got it to work.
 
Thanks,
    Neil
 
--
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:aadi@clubmom-inc.com]
Sent: Friday, November 01, 2002 9:19 AM
To: castor-dev@exolab.org
Subject: Re: [castor-dev] Can't create JDO instance using Tomcat & JNDI


Is "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:neil@JAMMConsulting.com] 
Sent: Friday, November 01, 2002 10:10 AM 
To: castor-dev@exolab.org 
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(ResourceFact
ory. 
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 






**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
minimalist@exolab.org with a subject of:
	unsubscribe castor-dev

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic