[jboss-user] [JNDI and Naming] - Dependancy injection with datasources within a webservice
Jens Mander
do-not-reply at jboss.com
Wed Apr 28 12:45:51 EDT 2010
Jens Mander [http://community.jboss.org/people/JensMander] created the discussion
"Dependancy injection with datasources within a webservice"
To view the discussion, visit: http://community.jboss.org/message/540065#540065
--------------------------------------------------------------
Hi,
I'am trying to use the @Resouce-Annotation for a datasource in my WebService (wsdl). I guess the datasource is properly configured because the following snippet works without any problems.
public String myFunction(String in) throws NamingException {
InitialContext ctx;
ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:/MyDataSource");
// do something with the datasource
return "something";
}
but if I'am trying something like that
@Resource(name="MyDataSource")
private DataSource ds;
public String myFunction(String in) throws NamingException {
// do something with the datasource ds
return "something";
}
I can't even deploy my webservice to the JBoss AS. The message says that "MyDataSource" couldn't be found ;(
I hope somebody has a piece of advice for me. Thanks a lot.
Jens
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/540065#540065]
Start a new discussion in JNDI and Naming at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100428/5f1e2019/attachment.html
More information about the jboss-user
mailing list