Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

Why doesn't work same <Resource name> for different <Context>s?

Boris Folgmann

2003-10-06


Hi!

I have two instances of the same application running on one tomcat4 server.
The only difference is, that they use a different database. The
applications have different names of course. My webapps dir looks like that:

webapp1 <dir>
webapp1.xml
webapp2 <dir>
webapp2.xml

The idea is to define the Data Source with the same name in the XML file:
<Resource name="jdbc/mydb" ...> but referencing different dbs using
different JDBC-URLs in the <ResourceParams> section.

The problem is that tomcat doesn't like the same name for those two
datasource resource defs. I get

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39)
    at
[...]
    at org.apache.catalina.startup.Bootstrap.main(Unknown Source)
Caused by: java.lang.ClassCastException
    at
org.apache.catalina.core.NamingContextListener.createSubcontexts(Unknown
Source)
:
[...]

in catalina.out when starting tomcat. webapp1 works but webapp2 not,
instead I get:

java.sql.SQLException: Cannot load JDBC driver class 'null'
 at
org.apache.commons.dbcp.BasicDataSource.createDataSource (BasicDataSource.java:529)
 at
org.apache.commons.dbcp.BasicDataSource.getConnection (BasicDataSource.java:312)
[...]

But I think that <Resource> should be local to each <Context> (XML-file),
shouldn't it?

You see, I don't want to change the resource name for webapp2, because I
want to use the exact same code for both, and more instances than two are
coming for this application. Any solutions??


cu,
 boris



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)


©2008 junlu.com - Jax Systems, LLC, U.S.A.