Skip to main content

@Resource inside JAX-RS-annotated bean

2 replies [Last post]
sombriks
Offline
Joined: 2006-05-14
Points: 0

hello everyone,

i would like to know if anyone have success injecting a JDBC
datasource inside a JAX-RS resource.

Do i need to make the resources EJB's? or plain old java objects have
the benefit too?

thanks in advance

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jinahya
Offline
Joined: 2010-11-27
Points: 0

Dear sombriks

Did you find the right answer?

sombriks
Offline
Joined: 2006-05-14
Points: 0

Hello,

No i didn't.

For now i gave up to use only webprofile and added @Stateless annotation on JAX-RS along with @Path.

After that, the classes that i already mapped in my javax.ws.rs.core.Application class got the right to use @Resource and @EJB to inject what i need just as if they where servlets... with the plus of being a EJB.

Zero xml configuration untill now, and thanks to JEE6 EJB's have no need to ejb-jar.xml or even an full featured EAR, they just live inside web project.

Of course, it will not run on ordinary and simpler tomcat, but it theory anything JEE6-compliant will run this .war