tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alla winter <>
Subject usage of @resource annotation
Date Wed, 08 Jul 2009 17:51:08 GMT
I can sucessfully access the DataStore using JNDI, but cannot access it when
I am using @RESOURCE annotation.
I do not use JPA.  I though that I do not need JPA for @RESOURCE annotation
 Here it is the code:
* private* @Resource (mappedName="jdbc/Cobra")
DataSource ds;
*public* DataSource getDefaultDs() *throws* Throwable{
*return* ds;

here the code with JNDI that is working:

*public* DataSource getDefaultDs() *throws* Throwable{
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:comp/*env*");
DataSource *ds* = (DataSource)envContext.lookup("*jdbc*/*Cobra*");
*return* ds;


Here the definition is the web.xml

<description>*Cobra* DataSource</description>

here the definition in my context:

<Resource name=*"jdbc/Cobra"* auth=*"Container"* type=*
*maxActive=*"100"* maxIdle=*"30"* maxWait=*"10000"
*username=*"yyyyyy"* password=*"xxxxxx"* driverClassName=*


TOMCAT 5.5.25; Windows XP, JDK 1.5.0_17.  Currently I am trying to use
Tomcat from IBM RAD

I would appreciate if you would help me with


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message