if you have
https://github.com/apache/tomee/blob/master/examples/moviefun-rest/src/main/tomee/tomee.xml

@Resource(name="HSQLDB Database") DataSource ds;

will work

or even

@Resource DataSource ds; if you defined a single datasource in the server.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://blog-rmannibucau.rhcloud.com> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2017-01-12 8:07 GMT+01:00 essex2014 <[email protected]>:

> I created a web project and packaged it in war file. Since I defined it in
> ejb-jar.xml I thought tomee would instantiate it ?
>
> Can u share an example for @Resource with all config files ?
>
> > On 11 Jan 2017, at 22:57, Romain Manni-Bucau [via TomEE & OpenEJB] <
> [email protected]> wrote:
> >
> > No
> >
> > You will need to share more cause we have a lot of tests doing that
> without
> > issues.
> >
> > Is it in a jar? Can it ve excluded from the scanning somehow? How is it
> > instantiated? By tomee?
> >
> >
> > Le 11 janv. 2017 23:31, "essex2014" <[hidden email]> a écrit :
> >
> > > Hi ,
> > >
> > > It's an MDB and I have configured it in ejb-jar.xml and also annotated
> > > with @MessageBean
> > >
> > > Is there any other config I need to add to the MDB  to say it is
> managed
> > > by tomee ?
> > >
> > > > On 11 Jan 2017, at 19:13, Romain Manni-Bucau [via TomEE & OpenEJB] <
> > > [hidden email]> wrote:
> > > >
> > > > Hi
> > > >
> > > > is your bean managed by tomee? is it a cdi bean, an ejb?
> > > >
> > > >
> > > > Romain Manni-Bucau
> > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > <https://blog-rmannibucau.rhcloud.com> | Old Blog
> > > > <http://rmannibucau.wordpress.com> | Github <https://github.com/
> > > rmannibucau> |
> > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | JavaEE Factory
> > > > <https://javaeefactory-rmannibucau.rhcloud.com>
> > > >
> > > > 2017-01-11 13:28 GMT+01:00 essex2014 <[hidden email]>:
> > > >
> > > > > Hi,
> > > > >
> > > > > I am trying to inject datasource into my class using @Resource
> > > annotation.
> > > > > I
> > > > > defined the resource in tomee.xml and added the reference in both
> > > web.xml
> > > > > and resources.xml. In the class when I try to access the data
> source I
> > > get
> > > > > null. The same code works when I try in a servlet. Any idea if I
> need
> > > to
> > > > > add
> > > > > any other config to get this working ?
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > View this message in context: http://tomee-openejb.979440.
> > > > > n4.nabble.com/Resource-not-working-in-tomee-1-7-4-tp4680866.html
> > > > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > >
> > > >
> > > >
> > > > If you reply to this email, your message will be added to the
> discussion
> > > below:
> > > > http://tomee-openejb.979440.n4.nabble.com/Resource-not-
> > > working-in-tomee-1-7-4-tp4680866p4680874.html
> > > > To unsubscribe from @Resource not working in tomee 1.7.4, click here.
> > > > NAML
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context: http://tomee-openejb.979440.
> > > n4.nabble.com/Resource-not-working-in-tomee-1-7-4-
> tp4680866p4680875.html
> > > Sent from the TomEE Users mailing list archive at Nabble.com.
> >
> >
> > If you reply to this email, your message will be added to the discussion
> below:
> > http://tomee-openejb.979440.n4.nabble.com/Resource-not-
> working-in-tomee-1-7-4-tp4680866p4680876.html
> > To unsubscribe from @Resource not working in tomee 1.7.4, click here.
> > NAML
>
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.
> n4.nabble.com/Resource-not-working-in-tomee-1-7-4-tp4680866p4680877.html
> Sent from the TomEE Users mailing list archive at Nabble.com.
>

Reply via email to