You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by James Maggs <ja...@virgin.net> on 2003/04/29 11:57:30 UTC

Tomcat Ignoring JNDI Resource Parameters

Hi There,

I've been struggling with a JNDI DataSource setup under Tomcat 4.1.18. The
problem seems to be that while the <Resource> tag is processed, the
<ResourceParams> are completely ignored. Output in my log file confirms
this. Here's the relevant portion of my server.xml:

      <Host name="www.myhost.com" debug="0"
       appBase="webapps" unpackWARs="true" autoDeploy="true">

        <Context path="" docBase="/usr/local/www/myhost.com/htdocs"
          reloadable="true" crossContext="true" debug="5"/>

        <Logger className="org.apache.catalina.logger.FileLogger"
          prefix="localhost_myhost_log." suffix=".txt" timestamp="true"/>

        <Valve className="org.apache.catalina.valves.AccessLogValve"
          directory="logs"  prefix="myhost_access_log." suffix=".txt"
          pattern="common" resolveHosts="false"/>

        <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
          driverName="org.gjt.mm.mysql.Driver"
          connectionURL="jdbc:mysql://localhost:3306/DB"
          connectionName="user"
          connectionPassword="password"
          userTable="USERS" userNameCol="USERNAME" userCredCol="PASSWORD"
          userRoleTable="USER_ROLES" roleNameCol="ROLENAME" />

        <Resource name="jdbc/MyhostDB"
          auth="Container"
          type="javax.sql.DataSource"/>

        <ResourceParams name="jdbc/MyhostDB">
          <parameter>
            <name>factory</name>
            <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
          </parameter>
          <parameter>
            <name>maxActive</name>
            <value>50</value>
          </parameter>
          <parameter>
            <name>maxIdle</name>
            <value>10</value>
          </parameter>
          <parameter>
            <name>maxWait</name>
            <value>10000</value>
          </parameter>
          <parameter>
            <name>username</name>
            <value>user</value>
          </parameter>
          <parameter>
            <name>password</name>
            <value>password</value>
          </parameter>
          <parameter>
            <name>driverClassName</name>
            <value>org.gjt.mm.mysql.Driver</value>
          </parameter>
          <parameter>
            <name>url</name>
            <value>jdbc:mysql://localhost:3306/DB?autoReconnect=true</value>
          </parameter>
        </ResourceParams>

      </Host>

And in my localhost_myhost_log.txt file I see the following:

NamingContextListener[/localhost/www.seeran.com]: Creating JNDI naming
context
NamingContextListener[/localhost/www.seeran.com]:   Resource parameters for
jdbc/SeeranDB = null
NamingContextListener[/localhost/www.seeran.com]:   Adding resource ref
jdbc/SeeranDB
NamingContextListener[/localhost/www.seeran.com]:
ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factory
ClassName=org.apache.naming.factory.ResourceFactory,{type=description,conten
t=DB
Connection},{type=scope,content=Shareable},{type=auth,content=Container}]
NamingContextListener[/localhost/www.seeran.com]:   Resource parameters for
UserTransaction = null

Tomcat starts up without any errors and the default DataDource is created
under the correct JNDI location but as soon as I try and get a connection a
NullPointerException is thrown. Not surprising given that the properties are
ignored. Can anyone see a problem with my configuration?

Many thanks in advance,

-James



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


Re: Tomcat Ignoring JNDI Resource Parameters

Posted by James Maggs <ja...@virgin.net>.
Sorry, the log entries below should read as follows:

NamingContextListener[/localhost/www.myhost.com]: Creating JNDI naming
context
NamingContextListener[/localhost/www.myhost.com]:   Resource parameters for
jdbc/MyhostDB = null
NamingContextListener[/localhost/www.myhost.com]:   Adding resource ref
jdbc/MyhostDB
NamingContextListener[/localhost/www.myhost.com]:
ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factory
ClassName=org.apache.naming.factory.ResourceFactory,{type=description,conten
t=DB
Connection},{type=scope,content=Shareable},{type=auth,content=Container}]
NamingContextListener[/localhost/www.myhost.com]:   Resource parameters for
UserTransaction = null

Thanks.

-James

----- Original Message -----
From: "James Maggs" <ja...@virgin.net>
To: <to...@jakarta.apache.org>
Sent: Tuesday, April 29, 2003 10:57 AM
Subject: Tomcat Ignoring JNDI Resource Parameters


> Hi There,
>
> I've been struggling with a JNDI DataSource setup under Tomcat 4.1.18. The
> problem seems to be that while the <Resource> tag is processed, the
> <ResourceParams> are completely ignored. Output in my log file confirms
> this. Here's the relevant portion of my server.xml:
>
>       <Host name="www.myhost.com" debug="0"
>        appBase="webapps" unpackWARs="true" autoDeploy="true">
>
>         <Context path="" docBase="/usr/local/www/myhost.com/htdocs"
>           reloadable="true" crossContext="true" debug="5"/>
>
>         <Logger className="org.apache.catalina.logger.FileLogger"
>           prefix="localhost_myhost_log." suffix=".txt" timestamp="true"/>
>
>         <Valve className="org.apache.catalina.valves.AccessLogValve"
>           directory="logs"  prefix="myhost_access_log." suffix=".txt"
>           pattern="common" resolveHosts="false"/>
>
>         <Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
>           driverName="org.gjt.mm.mysql.Driver"
>           connectionURL="jdbc:mysql://localhost:3306/DB"
>           connectionName="user"
>           connectionPassword="password"
>           userTable="USERS" userNameCol="USERNAME" userCredCol="PASSWORD"
>           userRoleTable="USER_ROLES" roleNameCol="ROLENAME" />
>
>         <Resource name="jdbc/MyhostDB"
>           auth="Container"
>           type="javax.sql.DataSource"/>
>
>         <ResourceParams name="jdbc/MyhostDB">
>           <parameter>
>             <name>factory</name>
>             <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>           </parameter>
>           <parameter>
>             <name>maxActive</name>
>             <value>50</value>
>           </parameter>
>           <parameter>
>             <name>maxIdle</name>
>             <value>10</value>
>           </parameter>
>           <parameter>
>             <name>maxWait</name>
>             <value>10000</value>
>           </parameter>
>           <parameter>
>             <name>username</name>
>             <value>user</value>
>           </parameter>
>           <parameter>
>             <name>password</name>
>             <value>password</value>
>           </parameter>
>           <parameter>
>             <name>driverClassName</name>
>             <value>org.gjt.mm.mysql.Driver</value>
>           </parameter>
>           <parameter>
>             <name>url</name>
>
<value>jdbc:mysql://localhost:3306/DB?autoReconnect=true</value>
>           </parameter>
>         </ResourceParams>
>
>       </Host>
>
> And in my localhost_myhost_log.txt file I see the following:
>
> NamingContextListener[/localhost/www.seeran.com]: Creating JNDI naming
> context
> NamingContextListener[/localhost/www.seeran.com]:   Resource parameters
for
> jdbc/SeeranDB = null
> NamingContextListener[/localhost/www.seeran.com]:   Adding resource ref
> jdbc/SeeranDB
> NamingContextListener[/localhost/www.seeran.com]:
>
ResourceRef[className=javax.sql.DataSource,factoryClassLocation=null,factory
>
ClassName=org.apache.naming.factory.ResourceFactory,{type=description,conten
> t=DB
> Connection},{type=scope,content=Shareable},{type=auth,content=Container}]
> NamingContextListener[/localhost/www.seeran.com]:   Resource parameters
for
> UserTransaction = null
>
> Tomcat starts up without any errors and the default DataDource is created
> under the correct JNDI location but as soon as I try and get a connection
a
> NullPointerException is thrown. Not surprising given that the properties
are
> ignored. Can anyone see a problem with my configuration?
>
> Many thanks in advance,
>
> -James
>
>
>
> ---------------------------------------------------------------------
> 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