Using annotations - @Resource

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Using annotations - @Resource

Rui Lopes
Hi all!

Are annotations such as @Resource possible to use?

If I use
session = ctx.lookup("java:/comp/env/mail/Session”);
it works fine.

If I use
@Resource(name="java:/comp/env/mail/Session”)
Session session;
or
@Resource(mappedName="java:/comp/env/mail/Session”)
Session session;
or
@Resource(lookup="java:/comp/env/mail/Session”)
Session session;

it does not work, although the session is not null (assumes the smtp host as localhost)

/rp


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

smime.p7s (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using annotations - @Resource

Carey Evans
On Thu, 26 Feb 2015, at 09:23, Rui Lopes wrote:
> Hi all!
>
> Are annotations such as @Resource possible to use?

Jetty doesn't directly support CDI. You'd need to use something like
Weld. I've never used this with Jetty myself, but there's documentation
at
http://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_servlet_containers_such_as_tomcat_or_jetty.

--
  Carey Evans
  [hidden email]
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Using annotations - @Resource

Jan Bartel-3
http://www.eclipse.org/jetty/documentation/current/using-annotations.html

Jan

On 26 February 2015 at 11:57, Carey Evans <[hidden email]> wrote:

> On Thu, 26 Feb 2015, at 09:23, Rui Lopes wrote:
>> Hi all!
>>
>> Are annotations such as @Resource possible to use?
>
> Jetty doesn't directly support CDI. You'd need to use something like
> Weld. I've never used this with Jetty myself, but there's documentation
> at
> http://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_servlet_containers_such_as_tomcat_or_jetty.
>
> --
>   Carey Evans
>   [hidden email]
> _______________________________________________
> jetty-users mailing list
> [hidden email]
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/jetty-users



--
Jan Bartel <[hidden email]>
www.webtide.com
'Expert Jetty/CometD developer,production,operations advice'
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Using annotations - @Resource

Rui Lopes
Yes, I figured it would work, although it doesn’t…
Maybe I’me doing something wrong… don’t have a clue what.
However, context.lookup works...

/rp

> On 26 Feb 2015, at 05:48, Jan Bartel <[hidden email]> wrote:
>
> http://www.eclipse.org/jetty/documentation/current/using-annotations.html
>
> Jan
>
> On 26 February 2015 at 11:57, Carey Evans <[hidden email]> wrote:
>> On Thu, 26 Feb 2015, at 09:23, Rui Lopes wrote:
>>> Hi all!
>>>
>>> Are annotations such as @Resource possible to use?
>>
>> Jetty doesn't directly support CDI. You'd need to use something like
>> Weld. I've never used this with Jetty myself, but there's documentation
>> at
>> http://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_servlet_containers_such_as_tomcat_or_jetty.
>>
>> --
>> Carey Evans
>> [hidden email]
>> _______________________________________________
>> jetty-users mailing list
>> [hidden email]
>> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
>> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
>
>
> --
> Jan Bartel <[hidden email]>
> www.webtide.com
> 'Expert Jetty/CometD developer,production,operations advice'
> _______________________________________________
> jetty-users mailing list
> [hidden email]
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

smime.p7s (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using annotations - @Resource

Carey Evans
In reply to this post by Jan Bartel-3
On Thu, 26 Feb 2015, at 16:48, Jan Bartel wrote:
> http://www.eclipse.org/jetty/documentation/current/using-annotations.html
>
> Jan

Sorry. Obviously I should have said that last time I tried, the version
of Jetty I was using didn't support @Resource annotations the way I was
trying to use them.

I think my confusion came from trying to use @Resource on arbitrary
objects, not just servlets, etc., where CDI takes things a bit further.

--
  Carey Evans
  [hidden email]
_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users