Hi,

does someone have any experience using Castor with Tomcat 4.0? In 
particular, I'm having problems using the JNDI lookup mechanism to get a 
reference to the JDO object. This is a portion of the source file I'm 
using:

try
{
    InitialContext ctx = new InitialContext();
    DataObjects jdo = (DataObjects) ctx.lookup ("java:comp/env/jdo/mydb");
    Database db = jdo.getDatabase();

    /* do stuff with database */
}
catch (Exception e)
{
    e.printStackTrace();
}


This is the web.xml containing references to my database and the JDO:

<web-app>
    <resource-ref>
        <description>Resource reference to DataSource</description>
        <res-ref-name>jdbc/mydb</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/mydb</res-ref-name>
        <res-type>org.exolab.castor.jdo.JDO</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>    
</web-app>


This is the corresponding Resource-tag in Tomcat's server.xml file:

<Resource name="jdo/mydb" auth="Container"
    type="org.exolab.castor.jdo.JDO"/>


I'm using the following database.xml:

<database name="tst" engine="sapdb" >
    <jndi name="java:comp/env/jdbc/mydb"/>  
    <mapping href="webapps/dysk/WEB-INF/mapping.xml" />
</database>


When I execute the program, Tomcat gives me the following error (only 
first couple of lines pasted):

javax.naming.NamingException: Cannot create resource instance
        at org.apache.naming.NamingContext.lookup(NamingContext.java:837)
        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(Unknown Source)
        
Does anyone know what this error means?
When I create the JDO class as if the servlet were a client-type program 
(that is: without the JNDI-lookup), it works correctly, but that's not 
what I want to do. Can anyone tell me what I'm doing wrong?

Regards,
Dirk Kemper

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to