You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Arthur van Dorp <ar...@gmx.net> on 2006/05/18 12:56:06 UTC

Extract resource from context.xml from external app

Hi all

I've got webapps deployed in tomcat 5.5.x that use some resources defined in
their respective context.xml files. I'd like to use those resource in a java
program on the same machine (which isn't a webapp). Most resource
descriptions would be easy enough to parse with a bit of xpath, but for
general resource definitions I'd rather reuse the classes that parse those
context files in tomcat or the J2SE. I'd imagine the code from my side to
look something like this:

Context ctx = SomeClass.SomeHowParseContext(somepath+"context.xml");
Context env = (Context) ctx.lookup("java:comp/env");
DataSource dataSource = (DataSource) env.lookup("jdbc/SOMEDB");

I couldn't figure out from the tomcat source code where the context.xml
loading part gets done and what classes I'd need to use. Any pointers
welcome.

Thanks, Arthur.





-- 
Mobile Internet - E-Mail und Internet immer und �berall!
GMX zum Mitnehmen: http://www.gmx.net/de/go/pocketweb

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


Re: Extract resource from context.xml from external app

Posted by Bill Barker <wb...@wilshire.com>.
"Arthur van Dorp" <ar...@gmx.net> wrote in message 
news:1696.1147949766@www024.gmx.net...
> Hi all
>
> I've got webapps deployed in tomcat 5.5.x that use some resources defined 
> in
> their respective context.xml files. I'd like to use those resource in a 
> java
> program on the same machine (which isn't a webapp). Most resource
> descriptions would be easy enough to parse with a bit of xpath, but for
> general resource definitions I'd rather reuse the classes that parse those
> context files in tomcat or the J2SE. I'd imagine the code from my side to
> look something like this:
>
> Context ctx = SomeClass.SomeHowParseContext(somepath+"context.xml");
> Context env = (Context) ctx.lookup("java:comp/env");
> DataSource dataSource = (DataSource) env.lookup("jdbc/SOMEDB");
>
> I couldn't figure out from the tomcat source code where the context.xml
> loading part gets done and what classes I'd need to use. Any pointers
> welcome.
>

Well, it's pretty integrated into Tomcat, so it won't be pretty to strip out 
:).  The actual JNDI code is under the o.a.naming package (located under 
container/catalina/src/share in the source distro).  The code that parses 
'context.xml' is in o.a.c.startup.ContextConfig (located under the same 
path).

> Thanks, Arthur.
>
>
>
>
>
> -- 
> Mobile Internet - E-Mail und Internet immer und �berall!
> GMX zum Mitnehmen: http://www.gmx.net/de/go/pocketweb 




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