tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Context.INITIAL_CONTEXT_FACTORY
Date Thu, 01 Feb 2007 18:25:04 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Fran,

Fran Varin wrote:
> On the one hand
> it "appears" that you can modify the server.xml file (which we have done)
> and the the datasource and context will be defined globally. We tried
> that...same error. 

Here is exactly what I have in my setup.

context.xml:

   <Resource name="jdbc/myDbName"
        auth="Container"
        type="javax.sql.DataSource"
        .
        .
        .
        />

In my code:
            Context ctx = new InitialContext();

            DataSource ds = (DataSource)ctx.lookup(_dataSourcePath);

            if(null == ds)
                throw new ServiceException("Cannot obtain DataSource");

            return ds.getConnection();

(_dataSourcePath is set to "java:/comp/env/jdbc/myDbName")

Sometimes, it's not entirely obvious when you should use the
"java:/comp/env" prefix and when you shouldn't. I hope this helps.

Another thing to check is whether or not your context.xml is actually
being used. I'm not sure what will happen if you have a <context> in
your server.xml as well as a context.xml file. I recommend picking one
and sticking with it.

One more question: if you are using WebSphere in production, why use
Tomcat in development?

- -chris

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

iD8DBQFFwjB/9CaO5/Lv0PARAqf6AKC52r4lk/tK2GxIG9Ksi/YoeH9RiwCfcg+6
D91lUVDWyXiSGqRXi6Z6WoU=
=m6oD
-----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


Mime
View raw message