tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alla winter <alla1.win...@gmail.com>
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

<resource-ref>
<description>*Cobra* DataSource</description>
<res-ref-name>*jdbc*/*Cobra*</res-ref-name>
<res-type>*javax*.*sql*.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

here the definition in my context:

<Resource name=*"jdbc/Cobra"* auth=*"Container"* type=*
"javax.sql.DataSource"
*maxActive=*"100"* maxIdle=*"30"* maxWait=*"10000"
*username=*"yyyyyy"* password=*"xxxxxx"* driverClassName=*
"com.microsoft.sqlserver.jdbc.SQLServerDriver"
*url=*"jdbc:sqlserver://myserver:1645;databaseName=Cobra"*/>

environment:

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

thanks

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