The Resource is specified, in the server.xml, with a name. This is the JNDI name and is used to refer to the resource from wherever you like.

The setup of the resource is done by the ResourceParams (I hope you didn't copy my example verbatim ;-)

The web.xml is just abstracting that reference for a lower-level JNDI call.

If you are now getting a null connection, the basic JNDI aspect is (probably) working ... and you just need to figure out the url/DB specific stuff. This could be the Factory (I added that param based on the JNDI/JDBC HOWTO - but it worked fine before, so it might be a default), DB permissions (grabbing a connection can fail in loadsa ways!), or ...

If you have coded the JNDI (InitialContext) lookup correctly it will work.

BTW I got badly bitten with 4.1.2 (haven't checked since) - every time I redeployed my app it rewrote the server.xml file (removing my Resource definitions).

If you're still stuck, some more info is needed - server.xml/web.xml snippets and code where you get the ref and the connection for starters.

G'luck

tim

Garrett Dangerfield wrote:
I tried this and it's not giving me the "not found in Context" message, but it's now trying to pass me a null connection.

I think the problem is that it doesn't know where to get the connection from.

With the ResourceLink in the server.xml Context, one specifies the name one wants to use locally as well as the name of the global resource. The resource-ref doesn't allow this.

Any further thoughts?

Thanks,
Garrett Dangerfield.

Tim Shaw wrote:

This works for me ...

web.xml :
<resource-ref>
<description>
Resource reference to a factory for java.sql.Connection
instances that may be used for talking to a particular
database that is configured in the server.xml file.
</description>
<res-ref-name>
jdbc/SessionDB
</res-ref-name>
<res-type>
javax.sql.DataSource
</res-type>
<res-auth>
Container
</res-auth>
</resource-ref>

context.xml :
<snip>
<Resource name="jdbc/SessionDB" auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/SessionDB">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<parameter>
<name>username</name>
<value>tripleplay</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>com.mysql.jdbc.Driver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:mysql://vodmgr:3306/tripleplay</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>20</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
</ResourceParams>
</snip>

Garrett Dangerfield wrote:

I tried this and it's not working.

It's saying:
Name jdbc not found in this context

In my web.xml, I put in:

<env-entry>
<env-entry-name>jdbc/DataWarehouse</env-entry-name>
<env-entry-value>jdbc/DataWarehouse</env-entry-value>
<env-entry-type>javax.sql.DataSource</env-entry-type>
</env-entry>

In my server.xml, I have:

<Resource auth="Container" name="jdbc/DataWarehouse" scope="Shareable"
type="javax.sql.DataSource"/>

Am I missing something?

Thanks
Garrett Dangerfield.

Shapira, Yoav wrote:

Howdy,



- put the equivalent of ResourceEnvRef into the web.xml inside the web



app


See the <env-entry> element in the Servlet Specification, v2.3,
SRC.13.1.

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you.




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to