You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by walterw <wa...@hotmail.com> on 2008/09/13 23:38:15 UTC

JNDI configuration in webapp/META-INF/context.xml

Hi all,

I have tried setting up JNDI for my web application inside the applicaton's
WAR file itself to no avail.  If I use the same configuration, but put it in
my server's context.xml, it works fine.

Here is the configuration I am using:
[code]
<?xml version="1.0" encoding="US-ASCII"?>
	<!--
		http://tomcat.apache.org/tomcat-6.0-doc/config/context.html Even
		though this works inside of tomcat/conf/context.xml and the
		documentation says it should work here, it doesn't
	-->
<context reloadable="true">
	<WatchedResource>WEB-INF/web.xml</WatchedResource>
	<WatchedResource>META-INF/context.xml</WatchedResource>
	<Resource name="${jndi.URL}" auth="Container" type="javax.sql.DataSource"
		driverClassName="${jdbc.driverClassName}" url="${jdbc.url}"
username="${jdbc.username}"
		password="${jdbc.password}" maxActive="100" maxIdle="30" maxWait="10000"
/>
</context>
[/code]

The parameters specified dynamically via ${} are filtered via
maven-resources-plugin, so that is not an issue.  The issue is just with
this configuration placed inside my webapp, I can't get a JNDI connection,
but if it is in the server's context.xml, it works great.

Walter
-- 
View this message in context: http://www.nabble.com/JNDI-configuration-in-webapp-META-INF-context.xml-tp19474901p19474901.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: JNDI configuration in webapp/META-INF/context.xml

Posted by walterw <wa...@hotmail.com>.
Hi,

Thanks for your reply, but I am still getting the same error.

[code]
Caused by: org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create
JDBC driver of class '' for connect URL 'null'
	at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150)
	at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
	at
org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:82)
	at
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
	... 69 more
Caused by: java.lang.NullPointerException
	at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507)
	at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476)
	at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307)
	at java.sql.DriverManager.getDriver(DriverManager.java:253)
	at
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143)
	... 72 more
[/code]

[code]
<?xml version="1.0" encoding="US-ASCII"?>
	<!--
		http://tomcat.apache.org/tomcat-6.0-doc/config/context.html Even
		though this works inside of tomcat/conf/context.xml and the
		documentation says it should work here, it doesn't
	-->
<context reloadable="true">
	<WatchedResource>WEB-INF/web.xml</WatchedResource>
	<WatchedResource>META-INF/context.xml</WatchedResource>
	<Resource name="${jndi.URL}" auth="Container" type="javax.sql.DataSource"
		driverClassName="${jdbc.driverClassName}" url="${jdbc.url}"
username="${jdbc.username}"
		password="${jdbc.password}" maxActive="100" maxIdle="30" maxWait="10000"
		useNaming="true"/>
</context>
[/code]

I tried putting useNaming in the resource element as well as the context
element, but all to no avail.  It looks like this configuration is not doing
anything.  This file is supposed to be placed in
servlet.war/META-INF/context.xml in which the servlet.war is the actual
file.  Could it also go in /WEB-INF/classes/META-INF/context.xml?

I tried both places, but nothing changed.

Please let me know what else to try.

Thanks,
Walter

mgainty wrote:
> 
> 
> Walter:<BR>
> 
> check your META-INF/context.xml attribute useNaming="true"<BR>
> 
> http://tomcat.apache.org/tomcat-5.5-doc/config/context.html<BR>
> 
> HTH<BR>
> Martin <BR>
> ______________________________________________ <BR>
> Disclaimer and confidentiality note 
> Everything in this e-mail and any attachments relates to the official
> business of Sender. This transmission is of a confidential nature and
> Sender does not endorse distribution to any party other than intended
> recipient. Sender does not necessarily endorse content contained within
> this transmission. 
> 
> 
>> Date: Sat, 13 Sep 2008 14:38:15 -0700
>> From: walterjwhite@hotmail.com
>> To: users@tomcat.apache.org
>> Subject: JNDI configuration in webapp/META-INF/context.xml
>> 
>> 
>> Hi all,
>> 
>> I have tried setting up JNDI for my web application inside the
>> applicaton's
>> WAR file itself to no avail.  If I use the same configuration, but put it
>> in
>> my server's context.xml, it works fine.
>> 
>> Here is the configuration I am using:
>> [code]
>> <?xml version="1.0" encoding="US-ASCII"?>
>> 	<!--
>> 		http://tomcat.apache.org/tomcat-6.0-doc/config/context.html Even
>> 		though this works inside of tomcat/conf/context.xml and the
>> 		documentation says it should work here, it doesn't
>> 	-->
>> <context reloadable="true">
>> 	<WatchedResource>WEB-INF/web.xml</WatchedResource>
>> 	<WatchedResource>META-INF/context.xml</WatchedResource>
>> 	<Resource name="${jndi.URL}" auth="Container"
>> type="javax.sql.DataSource"
>> 		driverClassName="${jdbc.driverClassName}" url="${jdbc.url}"
>> username="${jdbc.username}"
>> 		password="${jdbc.password}" maxActive="100" maxIdle="30"
>> maxWait="10000"
>> />
>> </context>
>> [/code]
>> 
>> The parameters specified dynamically via ${} are filtered via
>> maven-resources-plugin, so that is not an issue.  The issue is just with
>> this configuration placed inside my webapp, I can't get a JNDI
>> connection,
>> but if it is in the server's context.xml, it works great.
>> 
>> Walter
>> -- 
>> View this message in context:
>> http://www.nabble.com/JNDI-configuration-in-webapp-META-INF-context.xml-tp19474901p19474901.html
>> Sent from the Tomcat - User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>> 
> 
> _________________________________________________________________
> See how Windows connects the people, information, and fun that are part of
> your life.
> http://clk.atdmt.com/MRT/go/msnnkwxp1020093175mrt/direct/01/
> 

-- 
View this message in context: http://www.nabble.com/JNDI-configuration-in-webapp-META-INF-context.xml-tp19474901p19476389.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: JNDI configuration in webapp/META-INF/context.xml

Posted by Martin Gainty <mg...@hotmail.com>.
Walter:<BR>

check your META-INF/context.xml attribute useNaming="true"<BR>

http://tomcat.apache.org/tomcat-5.5-doc/config/context.html<BR>

HTH<BR>
Martin <BR>
______________________________________________ <BR>
Disclaimer and confidentiality note 
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. 


> Date: Sat, 13 Sep 2008 14:38:15 -0700
> From: walterjwhite@hotmail.com
> To: users@tomcat.apache.org
> Subject: JNDI configuration in webapp/META-INF/context.xml
> 
> 
> Hi all,
> 
> I have tried setting up JNDI for my web application inside the applicaton's
> WAR file itself to no avail.  If I use the same configuration, but put it in
> my server's context.xml, it works fine.
> 
> Here is the configuration I am using:
> [code]
> <?xml version="1.0" encoding="US-ASCII"?>
> 	<!--
> 		http://tomcat.apache.org/tomcat-6.0-doc/config/context.html Even
> 		though this works inside of tomcat/conf/context.xml and the
> 		documentation says it should work here, it doesn't
> 	-->
> <context reloadable="true">
> 	<WatchedResource>WEB-INF/web.xml</WatchedResource>
> 	<WatchedResource>META-INF/context.xml</WatchedResource>
> 	<Resource name="${jndi.URL}" auth="Container" type="javax.sql.DataSource"
> 		driverClassName="${jdbc.driverClassName}" url="${jdbc.url}"
> username="${jdbc.username}"
> 		password="${jdbc.password}" maxActive="100" maxIdle="30" maxWait="10000"
> />
> </context>
> [/code]
> 
> The parameters specified dynamically via ${} are filtered via
> maven-resources-plugin, so that is not an issue.  The issue is just with
> this configuration placed inside my webapp, I can't get a JNDI connection,
> but if it is in the server's context.xml, it works great.
> 
> Walter
> -- 
> View this message in context: http://www.nabble.com/JNDI-configuration-in-webapp-META-INF-context.xml-tp19474901p19474901.html
> Sent from the Tomcat - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

_________________________________________________________________
See how Windows connects the people, information, and fun that are part of your life.
http://clk.atdmt.com/MRT/go/msnnkwxp1020093175mrt/direct/01/

RE: JNDI configuration in webapp/META-INF/context.xml

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: walterw [mailto:walterjwhite@hotmail.com]
> Subject: RE: JNDI configuration in webapp/META-INF/context.xml
>
> <Context>
>         <WatchedResource>WEB-INF/web.xml</WatchedResource>
>         <!--<WatchedResource>META-INF/context.xml</WatchedResource>-->
>         <Resource name="${jndi.URL}" auth="Container"
> type="javax.sql.DataSource"
>                 driverClassName="${jdbc.driver}" url="${jdbc.url}"
> username="${jdbc.username}"
>                 password="${jdbc.password}" maxActive="100"
> maxIdle="30" maxWait="10000"/>
> </Context>

Also, exactly where is the above <Context> element located?

If you have a <Context> element in conf/Catalina/[host]/[appName].xml that might have been created from a previous deployment, that will override the one in META-INF/context.xml.  Get rid of the [appName].xml one if it exists.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: JNDI configuration in webapp/META-INF/context.xml

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Walter,

walterw wrote:
> Here are the exact contents in the file after maven filters it.
> 
> [code]
> <?xml version='1.0' encoding='utf-8'?>
> <!--
> 	http://tomcat.apache.org/tomcat-6.0-doc/config/context.html Even
> 	though this works inside of tomcat/conf/context.xml and the
> 	documentation says it should work here, it doesn't
> -->
> <?xml version='1.0' encoding='utf-8'?>

Could the double-XML processing instruction be causing a choke?

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkjQJKUACgkQ9CaO5/Lv0PA/vACdFT/Waez3BWjfotWMjOPXhDeU
L2sAnj5zG5J3m2W0KlubKCGtNWua6LrH
=y+CP
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: JNDI configuration in webapp/META-INF/context.xml

Posted by walterw <wa...@hotmail.com>.
Hi,

Here are the exact contents in the file after maven filters it.

[code]
<?xml version='1.0' encoding='utf-8'?>
<!--
	http://tomcat.apache.org/tomcat-6.0-doc/config/context.html Even
	though this works inside of tomcat/conf/context.xml and the
	documentation says it should work here, it doesn't
-->
<?xml version='1.0' encoding='utf-8'?>
<!--
	http://tomcat.apache.org/tomcat-6.0-doc/config/context.html Even
	though this works inside of tomcat/conf/context.xml and the
	documentation says it should work here, it doesn't
-->
<Context>
	<WatchedResource>WEB-INF/web.xml</WatchedResource>
	<!--<WatchedResource>META-INF/context.xml</WatchedResource>-->
	<Resource name="jdbc/serverConsole" auth="Container"
type="javax.sql.DataSource"
		driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/serverConsole?createDatabaseIfNotExist=true&amp;useUnicode=true&amp;characterEncoding=utf-8&amp;useCompression=true&amp;zeroDateTimeBehavior=convertToNull"
username="serverConsole"
		password="serverConsole" maxActive="100" maxIdle="30" maxWait="10000"/>
</Context>
[/code]

Let me know if that helps. I have redeployed the web app a few times with
this configuration to no avail.  It must be something small - Is there
anything in Tomcat that may enable/disable this configuration in the web
application itself?

Walter

Caldarale, Charles R wrote:
> 
>> From: walterw [mailto:walterjwhite@hotmail.com]
>> Subject: RE: JNDI configuration in webapp/META-INF/context.xml
>>
>> <Context>
>>         <WatchedResource>WEB-INF/web.xml</WatchedResource>
>>         <!--<WatchedResource>META-INF/context.xml</WatchedResource>-->
>>         <Resource name="${jndi.URL}" auth="Container"
>> type="javax.sql.DataSource"
>>                 driverClassName="${jdbc.driver}" url="${jdbc.url}"
>> username="${jdbc.username}"
>>                 password="${jdbc.password}" maxActive="100"
>> maxIdle="30" maxWait="10000"/>
>> </Context>
> 
> Without seeing what's really being inserted for the various attributes, I
> don't think it's possible to go much further as is.  For now, try
> replacing the variable references with the actual values and see what
> happens.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/JNDI-configuration-in-webapp-META-INF-context.xml-tp19474901p19484963.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: JNDI configuration in webapp/META-INF/context.xml

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: walterw [mailto:walterjwhite@hotmail.com]
> Subject: RE: JNDI configuration in webapp/META-INF/context.xml
>
> <Context>
>         <WatchedResource>WEB-INF/web.xml</WatchedResource>
>         <!--<WatchedResource>META-INF/context.xml</WatchedResource>-->
>         <Resource name="${jndi.URL}" auth="Container"
> type="javax.sql.DataSource"
>                 driverClassName="${jdbc.driver}" url="${jdbc.url}"
> username="${jdbc.username}"
>                 password="${jdbc.password}" maxActive="100"
> maxIdle="30" maxWait="10000"/>
> </Context>

Without seeing what's really being inserted for the various attributes, I don't think it's possible to go much further as is.  For now, try replacing the variable references with the actual values and see what happens.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: JNDI configuration in webapp/META-INF/context.xml

Posted by walterw <wa...@hotmail.com>.
Hi,

Thanks for your reply.  I noticed my configuration in the Tomcat
installation directory did have a capital C in context.  However, the files
are identical now, but I'm still not getting a JNDI connection.

[code]
<?xml version='1.0' encoding='utf-8'?>
<!--
	http://tomcat.apache.org/tomcat-6.0-doc/config/context.html Even
	though this works inside of tomcat/conf/context.xml and the
	documentation says it should work here, it doesn't
-->
<Context>
	<WatchedResource>WEB-INF/web.xml</WatchedResource>
	<!--<WatchedResource>META-INF/context.xml</WatchedResource>-->
	<Resource name="${jndi.URL}" auth="Container" type="javax.sql.DataSource"
		driverClassName="${jdbc.driver}" url="${jdbc.url}"
username="${jdbc.username}"
		password="${jdbc.password}" maxActive="100" maxIdle="30" maxWait="10000"/>
</Context>
[/code]

Thanks for your suggestion, please let me know what else to try.

I am running Tomcat 6.0.18 on Linux.

Thanks,
Walter

Caldarale, Charles R wrote:
> 
>> From: walterw [mailto:walterjwhite@hotmail.com]
>> Subject: JNDI configuration in webapp/META-INF/context.xml
>>
>> Here is the configuration I am using:
>> <context reloadable="true">
> 
> It's <Context>, not <context> - case matters.
> 
>> </context>
> 
> Ditto.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/JNDI-configuration-in-webapp-META-INF-context.xml-tp19474901p19484751.html
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


RE: JNDI configuration in webapp/META-INF/context.xml

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: walterw [mailto:walterjwhite@hotmail.com]
> Subject: JNDI configuration in webapp/META-INF/context.xml
>
> Here is the configuration I am using:
> <context reloadable="true">

It's <Context>, not <context> - case matters.

> </context>

Ditto.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org