You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by TomK <sw...@yahoo.com> on 2005/01/18 01:57:10 UTC

Help: Context.xml Resource difference between 5.0.x and 5.5.x ?

I'm having trouble moving my webapp from Tomcat 5.0 to 5.5.  The dataSource in Context.xml seems to be the issue.
 
According to the 'JNDI how-to' documentation for 5.0 and 5.5, it looks like the '<ResourceParams>' tag has been removed from the Context.xml and instead you can now supply arbitrary attributes to the <Resource> tag itself.
 
In 5.0, my Context.xml looked like this and it worked fine:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiResourceLocking="true" docBase="myapp" path="/myapp">
  <Resource name="jdbc/db1" auth="Container" 
  type="oracle.jdbc.pool.OracleDataSource" />
  <ResourceParams name="jdbc/db1">
    <parameter>
      <name>factory</name>
      <value>oracle.jdbc.pool.OracleDataSourceFactory</value>
    </parameter>
    <parameter>
      <name>driverClassName</name>
      <value>oracle.jdbc.driver.OracleDriver</value>
    </parameter>
    <parameter>
      <name>url</name>
      <value>jdbc:oracle:thin:@xx:xx:xx</value>
    </parameter>
    <parameter>
      <name>user</name>
      <value>xx</value>
    </parameter>
    <parameter>
      <name>password</name>
      <value>xx</value>
    </parameter>
  </ResourceParams>
</Context>
 
...note that oracle's factory requires "user", not "username".    

 
Moving to 5.5, I changed it to:
 
<?xml version="1.0" encoding="UTF-8"?>
<Context antiResourceLocking="true" docBase="myapp" path="/myapp">
  <Resource auth="Container" 
  driverClassName="oracle.jdbc.driver.OracleDriver" 
  factory="oracle.jdbc.pool.OracleDataSourceFactory" 
  name="jdbc/db1" 
  password="xxx" 
  type="oracle.jdbc.pool.OracleDataSource" 
  url="jdbc:oracle:thin:@xx:xx:xx" 
  user="xx"/>
</Context>

...this new Context.xml doesn't work.  I get the following:
javax.naming.NamingException: Cannot create resource instance
 at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:132)
 at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
 at org.apache.naming.NamingContext.lookup(NamingContext.java:792)
 
....any ideas?  Almost seems as if the "factory" attribute of <Resource> is not being used.
 
thanks
tk_

Solved: Context.xml Resource difference between 5.0.x and 5.5.x?

Posted by TomK <sw...@yahoo.com>.
Solved.    Crazy but true.
 
When using the Oracle factory:
In a Tomcat 5.0 context file, the "url" parameter (name, not the value) must be lower case.  In a Tomcat 5.5 context file, the "url" parameter must be UPPER CASE. 
 
Works now.     Thanks for the help.  Sorry for so many mails...
tk


Parsons Technical Services <pa...@earthlink.net> wrote:
The docs say that the factory parameter is only needed for entries that 
Tomcat is not "aware" of. Since you had a special factory(in your old 5.0 
context) and not the standard one used by Tomcat you will need to have the 
factory element in place.

See:
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/globalresources.html

Under Resource Definitions it says:
"You MUST also define any other needed parameters using attributes on the 
Resource element, to configure the object factory to be used (if not known 
to Tomcat already), and the properties used to configure that object 
factory."

And since Oracle does not use the standard factories that are built into 
Tomcat you will need the parameter for factory.

And I could be full of manure and sprouting daisies. But every now and then 
I get one right.


Doug



----- Original Message ----- 
From: "Sean M. Duncan" 
To: 
Sent: Monday, January 17, 2005 8:45 PM
Subject: Re: Help: Context.xml Resource difference between 5.0.x and 5.5.x?


> On Mon, 2005-01-17 at 16:57 -0800, TomK wrote:
>> I'm having trouble moving my webapp from Tomcat 5.0 to 5.5. The 
>> dataSource in Context.xml seems to be the issue.
>>
>> According to the 'JNDI how-to' documentation for 5.0 and 5.5, it looks 
>> like the '' tag has been removed from the Context.xml and 
>> instead you can now supply arbitrary attributes to the tag 
>> itself.
>>
>> In 5.0, my Context.xml looked like this and it worked fine:
>> 
>> 
>> >> type="oracle.jdbc.pool.OracleDataSource" />
>> 
>> 

>> factory
>> oracle.jdbc.pool.OracleDataSourceFactory
>> 

>> 

>> driverClassName
>> oracle.jdbc.driver.OracleDriver
>> 

>> 

>> url
>> jdbc:oracle:thin:@xx:xx:xx
>> 

>> 

>> user
>> xx
>> 

>> 

>> password
>> xx
>> 

>> 
>> 
>>
>> ...note that oracle's factory requires "user", not "username".
>>
>>
>> Moving to 5.5, I changed it to:
>>
>> 
>> 
>> >> driverClassName="oracle.jdbc.driver.OracleDriver"
>> factory="oracle.jdbc.pool.OracleDataSourceFactory"
>> name="jdbc/db1"
>> password="xxx"
>> type="oracle.jdbc.pool.OracleDataSource"
>> url="jdbc:oracle:thin:@xx:xx:xx"
>> user="xx"/>
>> 
>>
>> ...this new Context.xml doesn't work. I get the following:
>> javax.naming.NamingException: Cannot create resource instance
>> at 
>> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:132)
>> at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
>> at org.apache.naming.NamingContext.lookup(NamingContext.java:792)
>>
>> ....any ideas? Almost seems as if the "factory" attribute of 
>> is not being used.
>>
>> thanks
>> tk_
>
>
> ---------------------------------------------------------------------
> 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


Re: Help: Context.xml Resource difference between 5.0.x and 5.5.x?

Posted by Parsons Technical Services <pa...@earthlink.net>.
The docs say that the factory parameter is only needed for entries that 
Tomcat is not "aware" of. Since you had a special factory(in your old 5.0 
context) and not the standard one used by Tomcat you will need to have the 
factory element in place.

See:
http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/globalresources.html

Under Resource Definitions it says:
"You MUST also define any other needed parameters using attributes on the 
Resource element, to configure the object factory to be used (if not known 
to Tomcat already), and the properties used to configure that object 
factory."

And since Oracle does not use the standard factories that are built into 
Tomcat you will need the parameter for factory.

And I could be full of manure and sprouting daisies. But every now and then 
I get one right.


Doug



----- Original Message ----- 
From: "Sean M. Duncan" <se...@ferrosoft.com>
To: <to...@jakarta.apache.org>
Sent: Monday, January 17, 2005 8:45 PM
Subject: Re: Help: Context.xml Resource difference between 5.0.x and 5.5.x?


> On Mon, 2005-01-17 at 16:57 -0800, TomK wrote:
>> I'm having trouble moving my webapp from Tomcat 5.0 to 5.5.  The 
>> dataSource in Context.xml seems to be the issue.
>>
>> According to the 'JNDI how-to' documentation for 5.0 and 5.5, it looks 
>> like the '<ResourceParams>' tag has been removed from the Context.xml and 
>> instead you can now supply arbitrary attributes to the <Resource> tag 
>> itself.
>>
>> In 5.0, my Context.xml looked like this and it worked fine:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <Context antiResourceLocking="true" docBase="myapp" path="/myapp">
>>   <Resource name="jdbc/db1" auth="Container"
>>   type="oracle.jdbc.pool.OracleDataSource" />
>>   <ResourceParams name="jdbc/db1">
>>     <parameter>
>>       <name>factory</name>
>>       <value>oracle.jdbc.pool.OracleDataSourceFactory</value>
>>     </parameter>
>>     <parameter>
>>       <name>driverClassName</name>
>>       <value>oracle.jdbc.driver.OracleDriver</value>
>>     </parameter>
>>     <parameter>
>>       <name>url</name>
>>       <value>jdbc:oracle:thin:@xx:xx:xx</value>
>>     </parameter>
>>     <parameter>
>>       <name>user</name>
>>       <value>xx</value>
>>     </parameter>
>>     <parameter>
>>       <name>password</name>
>>       <value>xx</value>
>>     </parameter>
>>   </ResourceParams>
>> </Context>
>>
>> ...note that oracle's factory requires "user", not "username".
>>
>>
>> Moving to 5.5, I changed it to:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <Context antiResourceLocking="true" docBase="myapp" path="/myapp">
>>   <Resource auth="Container"
>>   driverClassName="oracle.jdbc.driver.OracleDriver"
>>   factory="oracle.jdbc.pool.OracleDataSourceFactory"
>>   name="jdbc/db1"
>>   password="xxx"
>>   type="oracle.jdbc.pool.OracleDataSource"
>>   url="jdbc:oracle:thin:@xx:xx:xx"
>>   user="xx"/>
>> </Context>
>>
>> ...this new Context.xml doesn't work.  I get the following:
>> javax.naming.NamingException: Cannot create resource instance
>>  at 
>> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:132)
>>  at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
>>  at org.apache.naming.NamingContext.lookup(NamingContext.java:792)
>>
>> ....any ideas?  Almost seems as if the "factory" attribute of <Resource> 
>> is not being used.
>>
>> thanks
>> tk_
>
>
> ---------------------------------------------------------------------
> 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


Re: Help: Context.xml Resource difference between 5.0.x and 5.5.x ?

Posted by "Sean M. Duncan" <se...@ferrosoft.com>.
On Mon, 2005-01-17 at 16:57 -0800, TomK wrote:
> I'm having trouble moving my webapp from Tomcat 5.0 to 5.5.  The dataSource in Context.xml seems to be the issue.
>  
> According to the 'JNDI how-to' documentation for 5.0 and 5.5, it looks like the '<ResourceParams>' tag has been removed from the Context.xml and instead you can now supply arbitrary attributes to the <Resource> tag itself.
>  
> In 5.0, my Context.xml looked like this and it worked fine:
> <?xml version="1.0" encoding="UTF-8"?>
> <Context antiResourceLocking="true" docBase="myapp" path="/myapp">
>   <Resource name="jdbc/db1" auth="Container" 
>   type="oracle.jdbc.pool.OracleDataSource" />
>   <ResourceParams name="jdbc/db1">
>     <parameter>
>       <name>factory</name>
>       <value>oracle.jdbc.pool.OracleDataSourceFactory</value>
>     </parameter>
>     <parameter>
>       <name>driverClassName</name>
>       <value>oracle.jdbc.driver.OracleDriver</value>
>     </parameter>
>     <parameter>
>       <name>url</name>
>       <value>jdbc:oracle:thin:@xx:xx:xx</value>
>     </parameter>
>     <parameter>
>       <name>user</name>
>       <value>xx</value>
>     </parameter>
>     <parameter>
>       <name>password</name>
>       <value>xx</value>
>     </parameter>
>   </ResourceParams>
> </Context>
>  
> ...note that oracle's factory requires "user", not "username".    
> 
>  
> Moving to 5.5, I changed it to:
>  
> <?xml version="1.0" encoding="UTF-8"?>
> <Context antiResourceLocking="true" docBase="myapp" path="/myapp">
>   <Resource auth="Container" 
>   driverClassName="oracle.jdbc.driver.OracleDriver" 
>   factory="oracle.jdbc.pool.OracleDataSourceFactory" 
>   name="jdbc/db1" 
>   password="xxx" 
>   type="oracle.jdbc.pool.OracleDataSource" 
>   url="jdbc:oracle:thin:@xx:xx:xx" 
>   user="xx"/>
> </Context>
> 
> ...this new Context.xml doesn't work.  I get the following:
> javax.naming.NamingException: Cannot create resource instance
>  at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:132)
>  at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
>  at org.apache.naming.NamingContext.lookup(NamingContext.java:792)
>  
> ....any ideas?  Almost seems as if the "factory" attribute of <Resource> is not being used.
>  
> thanks
> tk_


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