@Resource annotation is null at run-time.

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-06-12T23:28:14Z Indexed on 2010/06/12 23:32 UTC
Read the original article Hit count: 210

Filed under:
|
|
|

I'm using GlassFish v3. The following field is declared in a class:

@Resource
private javax.sql.DataSource _data_source;

The following is declare in web.xml:

   <data-source>
        <name>java:app/env/data</name>
        <class-name>com.mysql.jdbc.Driver</class-name>        
        <server-name>localhost</server-name>
        <port-number>3306</port-number>
        <user>myUser</user>            
        <password>myPass</password>
    </data-source>

At run-time _data_source is empty. What am I doing wrong?

© Stack Overflow or respective owner

Related posts about java

Related posts about annotations