You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mike Baranski <li...@secmgmt.com> on 2009/11/03 14:49:04 UTC
Trouble with context and JNDI resource
I'm using this page, trying to get a resource in a java class:
http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html
I have this in context.xml:
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<!-- Uncomment this to disable session persistence across Tomcat
restarts -->
<!--
<Manager pathname="" />
-->
<Resource name="proteus" auth="Container"
type="org.apache.commons.dbcp.BasicDataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="install" password="install"
driverClassName="com.informix.jdbc.IfxDriver"
url="jdbc:informix-sqli://sigma:1960/proteus:INFORMIXSERVER=sigma;IFX_LOCK_M
ODE_WAIT=-1;IFX_ISOLATION_LEVEL=1">
</Resource>
</Context>
I have this in web.xml:
<resource-env-ref>
<description>
Connection pool for xmlrpc.
</description>
<resource-env-ref-name>
proteus
</resource-env-ref-name>
<resource-env-ref-type>
org.apache.commons.dbcp.BasicDataSource
</resource-env-ref-type>
</resource-env-ref>
I have this code:
l.debug("Created the status xmlrpc class");
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("");
this.setDataSource((BasicDataSource) envCtx.lookup("proteus"));
I get this error:
Name proteus is not bound in this Context
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Trouble with context and JNDI resource
Posted by Mike Baranski <li...@secmgmt.com>.
That worked, thanks.
>-----Original Message-----
>From: Mikolaj Rydzewski [mailto:miki@ceti.pl]
>Sent: Tuesday, November 03, 2009 9:11 AM
>To: Tomcat Users List
>Subject: Re: Trouble with context and JNDI resource
>
>Mike Baranski wrote:
>> <Resource name="proteus" auth="Container"
>> type="org.apache.commons.dbcp.BasicDataSource"
>>
>Why not to use jdbc/proteus? Just to follow convention. I'd also rather
>use javax.sql.DataSource as type attribute.
>> <resource-env-ref-name>
>> proteus
>> </resource-env-ref-name>
>>
>The same, use jdbc/proteus.
>> I have this code:
>>
>> l.debug("Created the status xmlrpc class");
>> Context initCtx = new InitialContext();
>> Context envCtx = (Context) initCtx.lookup("");
>> this.setDataSource((BasicDataSource) envCtx.lookup("proteus"));
>>
>What about following:
>
>new InitialContext().lookup("java:comp/env/jdbc/proteus");
>
>
>--
>Mikolaj Rydzewski <mi...@ceti.pl>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>For additional commands, e-mail: users-help@tomcat.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Trouble with context and JNDI resource
Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
Mike Baranski wrote:
> <Resource name="proteus" auth="Container"
> type="org.apache.commons.dbcp.BasicDataSource"
>
Why not to use jdbc/proteus? Just to follow convention. I'd also rather
use javax.sql.DataSource as type attribute.
> <resource-env-ref-name>
> proteus
> </resource-env-ref-name>
>
The same, use jdbc/proteus.
> I have this code:
>
> l.debug("Created the status xmlrpc class");
> Context initCtx = new InitialContext();
> Context envCtx = (Context) initCtx.lookup("");
> this.setDataSource((BasicDataSource) envCtx.lookup("proteus"));
>
What about following:
new InitialContext().lookup("java:comp/env/jdbc/proteus");
--
Mikolaj Rydzewski <mi...@ceti.pl>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org