You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mark Woon <mo...@helix.stanford.edu> on 2004/06/06 04:22:30 UTC

[TC5] Problems with context.xml

Hi all.

According to the docs, it's possible to stick <Context> specific data 
into it's own config file in the 
|$CATALINA_HOME/conf/[enginename]/[hostname] |directory.  Unfortunately, 
I'm having problems when using it with JNDI resources.  When I take the 
<Context> element from my server.xml and put it in its own context.xml 
file it is suddenly unable to find the ResourceParams for the JNDI 
resource it needs.  Here are the relevant sections from my config files:

 From server.xml:
<GlobalNamingResources>
  <Resource name="global/jdbc/pharmgkb" type="javax.sql.DataSource" 
auth="Container" scope="Shareable" />
  <ResourceParams name="global/jdbc/pharmgkb">
    <parameter>
      <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>
    <parameter>
      <name>driverClassName</name>
      <value>oracle.jdbc.driver.OracleDriver</value>
    </parameter>
    ...
  </ResourceParams>
</GlobalNamingResources>

 From |$CATALINA_HOME/conf/[enginename]/[hostname]|/context-cas.xml:
<Context path="/cas" docBase="${dir.runtime.tomcat}/webapps/cas"
  override="true"
  allowLinking="true" caseSensitive="true"
  cachingAllowed="true" reloadable="${pharmgen.runtime.tomcat.reloadable}"
  debug="${pharmgen.runtime.tomcat.loglevel}">
  <ResourceLink global="global/jdbc/pharmgkb" name="jdbc/pharmgkb" 
type="javax.sql.DataSource"/>
</Context>


When this <Context> element is under the <Host> element in server.xml, 
it works fine.  When it is in its own file, I'm getting:

org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of 
class '' for connect URL 'null', cause:
java.sql.SQLException: No suitable driver


Any pointers would be greatly appreciated.  Tomcat 5 supports this usage 
scenario, right?  I've tested this with Tomcat 5.0.19, 5.0.25 and 
5.0.26-beta with no success.


Thanks,
-Mark

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


Re: [TC5] Problems with context.xml

Posted by "alu, artifex" <ap...@artifex.co.at>.
mhhhm... actually i don't think its possible to define a server-wide 
resource inside the context configuration.
the <globalnamingresources> tag is nested within the <server> tag, the 
context.xml file is based on the
<context> element which doesn't allow the <globalnamingresources> 
element within. (actually since there
is no dtd for the server.xml it will allow but almost certain ignore the 
tag).
i'm afraid you have to bind the resource manually in your java code.

mfg
art

Mark Woon wrote:

> alu, artifex wrote:
>
>> another try: =)
>>
>> how does the xml structure look like in your context.xml file? i think
>> you have to omit the
>> <globalnamingresources> tag if you haven't already done so.
>>
>
>
> Sorry, but no.  I specifically want to use a server-wide JNDI resource 
> instead of redefining the same resource within my context.
>
> Next?  ;)
>
>
> -Mark
>
> ---------------------------------------------------------------------
> 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: [TC5] Problems with context.xml

Posted by Mark Woon <mo...@helix.stanford.edu>.
alu, artifex wrote:

> another try: =)
>
> how does the xml structure look like in your context.xml file? i think
> you have to omit the
> <globalnamingresources> tag if you haven't already done so.
>


Sorry, but no.  I specifically want to use a server-wide JNDI resource 
instead of redefining the same resource within my context.

Next?  ;)


-Mark

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


Re: [TC5] Problems with context.xml

Posted by "alu, artifex" <ap...@artifex.co.at>.
another try: =)

how does the xml structure look like in your context.xml file? i think 
you have to omit the
<globalnamingresources> tag if you haven't already done so.

the xml file should look like this:

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

<Context path="" .... >

 <Resource name="" .....>

  <ResourceParams name="" .... >
    <parameter>
      <name>...</name>
      <value>...</value>
    </parameter>

    ...

  </ResourceParams>

</Context>
-----------------

mfg
alu

Mark Woon wrote:

> alu, artifex wrote:
>
>> where did you place your driver .jar-file in? i think you placed it
>> into CATALINA_HOME/server/lib - for your configuration
>> (resource is defined in the context) it should be placed in
>> CATALINA_HOME/common/lib i think.
>>
>
> I've tried it in both places with no luck.
>
> If you look at the error message carefully, it's not finding the 
> driver because it doesn't know what driver to look for, which would 
> indicate that it cannot find the ResourceParams.
>
> Any other ideas?
>
> Thanks,
> -Mark
>
> ---------------------------------------------------------------------
> 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: [TC5] Problems with context.xml

Posted by Mark Woon <mo...@helix.stanford.edu>.
alu, artifex wrote:

> where did you place your driver .jar-file in? i think you placed it
> into CATALINA_HOME/server/lib - for your configuration
> (resource is defined in the context) it should be placed in
> CATALINA_HOME/common/lib i think.
>

I've tried it in both places with no luck.

If you look at the error message carefully, it's not finding the driver 
because it doesn't know what driver to look for, which would indicate 
that it cannot find the ResourceParams.

Any other ideas?

Thanks,
-Mark

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


Re: [TC5] Problems with context.xml

Posted by "alu, artifex" <ap...@artifex.co.at>.
where did you place your driver .jar-file in? i think you placed it
into CATALINA_HOME/server/lib - for your configuration
(resource is defined in the context) it should be placed in
CATALINA_HOME/common/lib i think.

mfg
alu

Mark Woon wrote:

> Hi all.
>
> According to the docs, it's possible to stick <Context> specific data 
> into it's own config file in the 
> |$CATALINA_HOME/conf/[enginename]/[hostname] |directory.  
> Unfortunately, I'm having problems when using it with JNDI resources.  
> When I take the <Context> element from my server.xml and put it in its 
> own context.xml file it is suddenly unable to find the ResourceParams 
> for the JNDI resource it needs.  Here are the relevant sections from 
> my config files:
>
> From server.xml:
> <GlobalNamingResources>
>  <Resource name="global/jdbc/pharmgkb" type="javax.sql.DataSource" 
> auth="Container" scope="Shareable" />
>  <ResourceParams name="global/jdbc/pharmgkb">
>    <parameter>
>      <name>factory</name>
>      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
>    </parameter>
>    <parameter>
>      <name>driverClassName</name>
>      <value>oracle.jdbc.driver.OracleDriver</value>
>    </parameter>
>    ...
>  </ResourceParams>
> </GlobalNamingResources>
>
> From |$CATALINA_HOME/conf/[enginename]/[hostname]|/context-cas.xml:
> <Context path="/cas" docBase="${dir.runtime.tomcat}/webapps/cas"
>  override="true"
>  allowLinking="true" caseSensitive="true"
>  cachingAllowed="true" reloadable="${pharmgen.runtime.tomcat.reloadable}"
>  debug="${pharmgen.runtime.tomcat.loglevel}">
>  <ResourceLink global="global/jdbc/pharmgkb" name="jdbc/pharmgkb" 
> type="javax.sql.DataSource"/>
> </Context>
>
>
> When this <Context> element is under the <Host> element in server.xml, 
> it works fine.  When it is in its own file, I'm getting:
>
> org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver 
> of class '' for connect URL 'null', cause:
> java.sql.SQLException: No suitable driver
>
>
> Any pointers would be greatly appreciated.  Tomcat 5 supports this 
> usage scenario, right?  I've tested this with Tomcat 5.0.19, 5.0.25 
> and 5.0.26-beta with no success.
>
>
> Thanks,
> -Mark
>
> ---------------------------------------------------------------------
> 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