You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by John Cartwright <Jo...@noaa.gov> on 2008/10/16 19:42:06 UTC

JNDI Datasource works in unpacked war, not in packed war

Hello All,

I have a problem where a Datasource is configured in 
META-INF/context.xml and referenced in web.xml.  If I install this 
webapp unpacked, everything works fine.  However, if I try to run this 
webapp as a packed war, the datasource fails giving the exception:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC 
driver of class '' for connect URL 'null'

tomcat 5.5.17, excerpts from the context.xml and web.xml listed below.

Can anyone help me out w/ this?

Thanks!

-- john


web.xml:
....
    <resource-ref>
        <res-ref-name>jdbc/COUGAR</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
...

context.xml
...
<Resource name="jdbc/COUGAR"
          type="javax.sql.DataSource"
          auth="Container"
          username="myuser"
          password="mypassword"
          driverClassName="oracle.jdbc.OracleDriver"
          url="jdbc:oracle:thin:@localhost:1521:ORACLE"
          maxActive="8"
          maxIdle="4"/>
...



---------------------------------------------------------------------
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 Datasource works in unpacked war, not in packed war

Posted by Yassine <ya...@gmail.com>.
Hi John,

just an other suggestion which you could try too:

the context.xml file inside yourApp/META-INF/context.xml gets by
default copied to
$CATALINA_HOME/conf/Catalina/localhost/yourApp.xml at the first
deployment normally when undeploying
yourApp.war the container does remove the yourApp.xml file from its location:
$CATALINA_HOME/conf/Catalina/localhost/yourApp.xml but sometime this
does not happen
you may want to check its existence and if it still there you can
remove it before redeploying
your war file again.

Hi Chris,

"Hmm. If you deploy a WAR file and then restart Tomcat, sometimes your
context.xml will be copied into either conf/Catalina/localhost or
work/somethingorother and it gets cached and not updated for various
reasons."

i never seen a context.xml file in there or do you mean it gets cached
in the .ser files?


On Sun, Oct 19, 2008 at 5:03 AM, Christopher Schultz
<ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----

Yassine

PEACE :
( P ) Positive ( E ) Energy ( A ) Always ( C ) Correct ( E ) Errors.

---------------------------------------------------------------------
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 Datasource works in unpacked war, not in packed war

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

John,

John Cartwright wrote:
> I have a problem where a Datasource is configured in
> META-INF/context.xml and referenced in web.xml.  If I install this
> webapp unpacked, everything works fine.  However, if I try to run this
> webapp as a packed war, the datasource fails giving the exception:
> 
> org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC
> driver of class '' for connect URL 'null'

Hmm. If you deploy a WAR file and then restart Tomcat, sometimes your
context.xml will be copied into either conf/Catalina/localhost or
work/somethingorother and it gets cached and not updated for various
reasons.

When you deploy the WAR file, are you just dropping it into your
auto-deployment directory (usually CATALINA_BASE/webapps)? If so, Tomcat
may not be triggering the re-load of the context.xml from your WAR file.
You might want to try a few things:

1. Shutdown Tomcat and blow-away the entire 'work' directory.
   Make sure there is no exploded WAR file in your webapps directory.
   Re-start Tomcat with your WAR in place and make sure it gets
   auto-deployed. Hopefully this will work.

2. Use the manager application to re-deploy your WAR file. I don't
   use the manager app for anything, so I don't know if it will
   auto-update the on-disk, cached context.xml, but it's an easy check.

3. Always use exploded WAR files if all else fails. Honestly, if you
   can't get WAR files working, you should head back to the list and
   ask again. I'm sure that other folks have more ideas and understand
   Tomcat's exact behavior in these situations.

> tomcat 5.5.17

This is quite an old version. Are you able to upgrade to a more recent
5.5.x version? I haven't checked the changelog, but it's possible that
these types of behaviors have been tweaked since 5.5.17.

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

iEYEARECAAYFAkj6o3IACgkQ9CaO5/Lv0PC1SgCggYHM0Hs+q3TAjP9ZMC0AXRPo
IjYAoK/kKbMYeGLQcVkITsiwF9vGEWVN
=lbRQ
-----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