my dog learned polymorphism
The moose likes BEA/Weblogic and the fly likes @Resource annotation in web logic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "@Resource annotation in web logic " Watch "@Resource annotation in web logic " New topic

@Resource annotation in web logic

chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 197
Hi All,

Can I use @Resource annotation in web logic version ?

The following code is working :
DataSource datasource = (DataSource) initialContext.lookup(DATASOURCE_CONTEXT);

But when I am using the annotation it’s failed.
@Resource(name = "dy/mydb/ds")
private DataSource ds;


Wendy Gibbons

Joined: Oct 21, 2008
Posts: 1107

Chen, This has been moved to the WebLogic forum, you are much more likely to get an answer there.
sudipto shekhar
Ranch Hand

Joined: Apr 02, 2008
Posts: 823

Thanks Wendy.

Hey Chen, what are you trying to achieve in your application?

We would like to know what exactly have you tried till now; and the issue that you have faced !

If you intend to use dependency injection using @Resource, it can be achieved.

Regards, Sud.
chen young
Ranch Hand

Joined: Sep 09, 2005
Posts: 197

I want to connect my web application to the db via the web logic data source.

This function is working perfectly:

But when I am using the annotation approach I get NullPointerException for example:

any advice ?

I agree. Here's the link:
subject: @Resource annotation in web logic
jQuery in Action, 3rd edition