You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@openwebbeans.apache.org by Steve Sobol - Lobos Studios <st...@LobosStudios.com> on 2016/06/07 17:04:47 UTC

OWB, Servlets and Jetty 9

Hey all,

New to CDI - I'm working on switching my JEE webapps from JSF managed 
beans to CDI.

I use Jetty, exclusively, and JSF works fine with Jetty and OWB, but 
@Inject in servlets (and presumably elsewhere) does not.

I started out with JBoss Weld, which ships with Jetty 9, but trying to 
get Weld working in my IDE was a nightmare and I gave up. (IntelliJ IDEA 
Ultimate 2016.2 if anyone cares, but this morning I upgraded to 2016.3)

So as an alternative to getting the bundled CDI functionality to work, I 
tried OpenWebBeans instead and now I'm good to go, except that I can't 
use DI in the servlets I'm creating.

I have a workaround (query BeanManager through JNDI), so this is not a 
life-or-death urgent issue (not even close!) - but it would be nice if I 
could get it working. A mailing list search turned up

http://markmail.org/search/?q=servlet+injection+jetty+list%3Aorg.apache.openwebbeans.user+order%3Adate-backward#query:servlet%20injection%20jetty%20list%3Aorg.apache.openwebbeans.user%20order%3Adate-backward+page:2+mid:gzti4hxxl76lqyhf+state:results

That thread states that Jetty 8 is buggy and that the OWB team even gave 
up on working with Jetty and switched to Tomcat* - but the thread is 
from 2012, and Jetty 8 was EOL'd a while ago.

So my questions are:

** What is the current state of @Inject using OWB and Jetty?
** If it's not working, what would be required to *get* it working?

Weld can do DI into Servlets and Filters in Jetty 7, 8 or 9, and into 
Servlet listeners in 9.1.1 or newer. (according to 
https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty)

But I'd much rather use OWB.

Thanks,
    Steve

* OWB and Tomcat are both ASF projects. Weird that y'all didn't use 
Tomcat from the start.


--
Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | 
Facebook.com/LobosStudios | @LobosStudios
Web Development - Mobile Development - Helpdesk/Tech Support - Computer 
Sales & Service
Acer Authorized Reseller - Computers, Windows and Android Tablets, 
Accessories

Steve Sobol - CEO, Senior Developer and Server Jockey
steve@LobosStudios.com

Re[4]: OWB, Servlets and Jetty 9

Posted by Steve Sobol - Lobos Studios <st...@LobosStudios.com>.
That is my plan.

As previously mentioned, I'm new to CDI, having used JSF managed beans 
for a few years now - but my desire to use the latest version of 
Omnifaces with a new project forced my hand (version 2.* requires CDI). 
I'm glad I'm going in that direction, and I look forward to being a 
productive member of this community.

--
Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | 
Facebook.com/LobosStudios | @LobosStudios
Web Development - Mobile Development - Helpdesk/Tech Support - Computer 
Sales & Service
Acer Authorized Reseller - Computers, Windows and Android Tablets, 
Accessories

Steve Sobol - CEO, Senior Developer and Server Jockey
steve@LobosStudios.com



------ Original Message ------
From: "Romain Manni-Bucau" <rm...@gmail.com>
To: "Steve Sobol - Lobos Studios" <st...@lobosstudios.com>
Cc: "user@openwebbeans.apache.org" <us...@openwebbeans.apache.org>
Sent: 6/7/2016 10:33:07 AM
Subject: Re: Re[2]: OWB, Servlets and Jetty 9

>Thanks for the explanations!
>
>If you get it working and want to submit it as a new module to 
>openwebbeans it would be very welcomed!
>
>
>Romain Manni-Bucau
>@rmannibucau |  Blog | Old Wordpress Blog | Github | LinkedIn | 
>Tomitriber | JavaEE Factory
>
>2016-06-07 19:19 GMT+02:00 Steve Sobol - Lobos Studios 
><st...@lobosstudios.com>:
>>I've used Jetty for years. My impression is that it is used pretty 
>>heavily in an embedded role, but not very often at all as a standalone 
>>server. But I personally use it as a standalone server.
>>
>>The webapps I'm working on will be deployed to existing servers 
>>already running Jetty.
>>
>>Years ago I started working on Java webapps with Tomcat, and I found 
>>the process of configuring the server rather confusing. I switched to 
>>Jetty back then and have used it ever since. I know it's been a while, 
>>and many things have probably changed, but I really have no desire to 
>>go back to Tomcat or a derivative as I have an extremely high comfort 
>>level with Jetty.
>>
>>I'll take a look at that source code - I'm fine cooking something up 
>>myself, but wasn't sure where to start from. Thank you!
>>
>>--
>>Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | 
>>Facebook.com/LobosStudios | @LobosStudios
>>Web Development - Mobile Development - Helpdesk/Tech Support - 
>>Computer Sales & Service
>>Acer Authorized Reseller - Computers, Windows and Android Tablets, 
>>Accessories
>>
>>Steve Sobol - CEO, Senior Developer and Server Jockey
>>steve@LobosStudios.com
>>
>>
>>
>>------ Original Message ------
>>From: "Romain Manni-Bucau" <rm...@gmail.com>
>>To: "user@openwebbeans.apache.org" <us...@openwebbeans.apache.org>; 
>>"Steve Sobol - Lobos Studios" <st...@lobosstudios.com>
>>Sent: 6/7/2016 10:09:37 AM
>>Subject: Re: OWB, Servlets and Jetty 9
>>
>>>Hi Steve,
>>>
>>>think we are very few to use jetty and with modern tooling (tomee 
>>>embedded, tomcat embedded etc) jetty request kind of decreased I 
>>>think.
>>>
>>>To make it work you would need to wrap the InstanceManager 
>>>instantiating servlets/filters of jetty to add CDI integration there. 
>>>This is pretty close of what tomcat integration does 
>>>(https://github.com/apache/openwebbeans/blob/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatInstanceManager.java).
>>>
>>>BTW out of curiosity: why didn't you choose tomee instead of 
>>>integrating it all yourself?
>>>
>>>
>>>
>>>Romain Manni-Bucau
>>>@rmannibucau |  Blog | Old Wordpress Blog | Github | LinkedIn | 
>>>Tomitriber | JavaEE Factory
>>>
>>>2016-06-07 19:04 GMT+02:00 Steve Sobol - Lobos Studios 
>>><st...@lobosstudios.com>:
>>>>Hey all,
>>>>
>>>>New to CDI - I'm working on switching my JEE webapps from JSF 
>>>>managed beans to CDI.
>>>>
>>>>I use Jetty, exclusively, and JSF works fine with Jetty and OWB, but 
>>>>@Inject in servlets (and presumably elsewhere) does not.
>>>>
>>>>I started out with JBoss Weld, which ships with Jetty 9, but trying 
>>>>to get Weld working in my IDE was a nightmare and I gave up. 
>>>>(IntelliJ IDEA Ultimate 2016.2 if anyone cares, but this morning I 
>>>>upgraded to 2016.3)
>>>>
>>>>So as an alternative to getting the bundled CDI functionality to 
>>>>work, I tried OpenWebBeans instead and now I'm good to go, except 
>>>>that I can't use DI in the servlets I'm creating.
>>>>
>>>>I have a workaround (query BeanManager through JNDI), so this is not 
>>>>a life-or-death urgent issue (not even close!) - but it would be 
>>>>nice if I could get it working. A mailing list search turned up
>>>>
>>>>http://markmail.org/search/?q=servlet+injection+jetty+list%3Aorg.apache.openwebbeans.user+order%3Adate-backward#query:servlet%20injection%20jetty%20list%3Aorg.apache.openwebbeans.user%20order%3Adate-backward+page:2+mid:gzti4hxxl76lqyhf+state:results
>>>>
>>>>That thread states that Jetty 8 is buggy and that the OWB team even 
>>>>gave up on working with Jetty and switched to Tomcat* - but the 
>>>>thread is from 2012, and Jetty 8 was EOL'd a while ago.
>>>>
>>>>So my questions are:
>>>>
>>>>** What is the current state of @Inject using OWB and Jetty?
>>>>** If it's not working, what would be required to *get* it working?
>>>>
>>>>Weld can do DI into Servlets and Filters in Jetty 7, 8 or 9, and 
>>>>into Servlet listeners in 9.1.1 or newer. (according to 
>>>>https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty)
>>>>
>>>>But I'd much rather use OWB.
>>>>
>>>>Thanks,
>>>>    Steve
>>>>
>>>>* OWB and Tomcat are both ASF projects. Weird that y'all didn't use 
>>>>Tomcat from the start.
>>>>
>>>>
>>>>--
>>>>Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | 
>>>>Facebook.com/LobosStudios | @LobosStudios
>>>>Web Development - Mobile Development - Helpdesk/Tech Support - 
>>>>Computer Sales & Service
>>>>Acer Authorized Reseller - Computers, Windows and Android Tablets, 
>>>>Accessories
>>>>
>>>>Steve Sobol - CEO, Senior Developer and Server Jockey
>>>>steve@LobosStudios.com
>>>>
>>>
>

Re: Re[2]: OWB, Servlets and Jetty 9

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Thanks for the explanations!

If you get it working and want to submit it as a new module to openwebbeans
it would be very welcomed!


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

2016-06-07 19:19 GMT+02:00 Steve Sobol - Lobos Studios <
steve@lobosstudios.com>:

> I've used Jetty for years. My impression is that it is used pretty heavily
> in an embedded role, but not very often at all as a standalone server. But
> I personally use it as a standalone server.
>
> The webapps I'm working on will be deployed to existing servers already
> running Jetty.
>
> Years ago I started working on Java webapps with Tomcat, and I found the
> process of configuring the server rather confusing. I switched to Jetty
> back then and have used it ever since. I know it's been a while, and many
> things have probably changed, but I really have no desire to go back to
> Tomcat or a derivative as I have an extremely high comfort level with Jetty.
>
> I'll take a look at that source code - I'm fine cooking something up
> myself, but wasn't sure where to start from. Thank you!
>
> --
> Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com |
> Facebook.com/LobosStudios | @LobosStudios
> Web Development - Mobile Development - Helpdesk/Tech Support - Computer
> Sales & Service
> Acer Authorized Reseller - Computers, Windows and Android Tablets,
> Accessories
>
> Steve Sobol - CEO, Senior Developer and Server Jockey
> steve@LobosStudios.com
>
>
>
> ------ Original Message ------
> From: "Romain Manni-Bucau" <rm...@gmail.com>
> To: "user@openwebbeans.apache.org" <us...@openwebbeans.apache.org>; "Steve
> Sobol - Lobos Studios" <st...@lobosstudios.com>
> Sent: 6/7/2016 10:09:37 AM
> Subject: Re: OWB, Servlets and Jetty 9
>
>
> Hi Steve,
>
> think we are very few to use jetty and with modern tooling (tomee
> embedded, tomcat embedded etc) jetty request kind of decreased I think.
>
> To make it work you would need to wrap the InstanceManager instantiating
> servlets/filters of jetty to add CDI integration there. This is pretty
> close of what tomcat integration does (
> https://github.com/apache/openwebbeans/blob/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatInstanceManager.java
> ).
>
> BTW out of curiosity: why didn't you choose tomee instead of integrating
> it all yourself?
>
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://blog-rmannibucau.rhcloud.com/> | Old Wordpress Blog
> <http://rmannibucau.wordpress.com/> | Github
> <https://github.com/rmannibucau> | LinkedIn
> <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com/> | JavaEE Factory
> <https://javaeefactory-rmannibucau.rhcloud.com/>
>
> 2016-06-07 19:04 GMT+02:00 Steve Sobol - Lobos Studios <
> steve@lobosstudios.com>:
>
>> Hey all,
>>
>> New to CDI - I'm working on switching my JEE webapps from JSF managed
>> beans to CDI.
>>
>> I use Jetty, exclusively, and JSF works fine with Jetty and OWB, but
>> @Inject in servlets (and presumably elsewhere) does not.
>>
>> I started out with JBoss Weld, which ships with Jetty 9, but trying to
>> get Weld working in my IDE was a nightmare and I gave up. (IntelliJ IDEA
>> Ultimate 2016.2 if anyone cares, but this morning I upgraded to 2016.3)
>>
>> So as an alternative to getting the bundled CDI functionality to work, I
>> tried OpenWebBeans instead and now I'm good to go, except that I can't use
>> DI in the servlets I'm creating.
>>
>> I have a workaround (query BeanManager through JNDI), so this is not a
>> life-or-death urgent issue (not even close!) - but it would be nice if I
>> could get it working. A mailing list search turned up
>>
>>
>> http://markmail.org/search/?q=servlet+injection+jetty+list%3Aorg.apache.openwebbeans.user+order%3Adate-backward#query:servlet%20injection%20jetty%20list%3Aorg.apache.openwebbeans.user%20order%3Adate-backward+page:2+mid:gzti4hxxl76lqyhf+state:results
>>
>> That thread states that Jetty 8 is buggy and that the OWB team even gave
>> up on working with Jetty and switched to Tomcat* - but the thread is from
>> 2012, and Jetty 8 was EOL'd a while ago.
>>
>> So my questions are:
>>
>> ** What is the current state of @Inject using OWB and Jetty?
>> ** If it's not working, what would be required to *get* it working?
>>
>> Weld can do DI into Servlets and Filters in Jetty 7, 8 or 9, and into
>> Servlet listeners in 9.1.1 or newer. (according to
>> https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty
>> )
>>
>> But I'd much rather use OWB.
>>
>> Thanks,
>>    Steve
>>
>> * OWB and Tomcat are both ASF projects. Weird that y'all didn't use
>> Tomcat from the start.
>>
>>
>> --
>> Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com |
>> Facebook.com/LobosStudios | @LobosStudios
>> Web Development - Mobile Development - Helpdesk/Tech Support - Computer
>> Sales & Service
>> Acer Authorized Reseller - Computers, Windows and Android Tablets,
>> Accessories
>>
>> Steve Sobol - CEO, Senior Developer and Server Jockey
>> steve@LobosStudios.com
>>
>>
>
>

Re[2]: OWB, Servlets and Jetty 9

Posted by Steve Sobol - Lobos Studios <st...@LobosStudios.com>.
I've used Jetty for years. My impression is that it is used pretty 
heavily in an embedded role, but not very often at all as a standalone 
server. But I personally use it as a standalone server.

The webapps I'm working on will be deployed to existing servers already 
running Jetty.

Years ago I started working on Java webapps with Tomcat, and I found the 
process of configuring the server rather confusing. I switched to Jetty 
back then and have used it ever since. I know it's been a while, and 
many things have probably changed, but I really have no desire to go 
back to Tomcat or a derivative as I have an extremely high comfort level 
with Jetty.

I'll take a look at that source code - I'm fine cooking something up 
myself, but wasn't sure where to start from. Thank you!

--
Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | 
Facebook.com/LobosStudios | @LobosStudios
Web Development - Mobile Development - Helpdesk/Tech Support - Computer 
Sales & Service
Acer Authorized Reseller - Computers, Windows and Android Tablets, 
Accessories

Steve Sobol - CEO, Senior Developer and Server Jockey
steve@LobosStudios.com



------ Original Message ------
From: "Romain Manni-Bucau" <rm...@gmail.com>
To: "user@openwebbeans.apache.org" <us...@openwebbeans.apache.org>; 
"Steve Sobol - Lobos Studios" <st...@lobosstudios.com>
Sent: 6/7/2016 10:09:37 AM
Subject: Re: OWB, Servlets and Jetty 9

>Hi Steve,
>
>think we are very few to use jetty and with modern tooling (tomee 
>embedded, tomcat embedded etc) jetty request kind of decreased I think.
>
>To make it work you would need to wrap the InstanceManager 
>instantiating servlets/filters of jetty to add CDI integration there. 
>This is pretty close of what tomcat integration does 
>(https://github.com/apache/openwebbeans/blob/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatInstanceManager.java).
>
>BTW out of curiosity: why didn't you choose tomee instead of 
>integrating it all yourself?
>
>
>
>Romain Manni-Bucau
>@rmannibucau |  Blog | Old Wordpress Blog | Github | LinkedIn | 
>Tomitriber | JavaEE Factory
>
>2016-06-07 19:04 GMT+02:00 Steve Sobol - Lobos Studios 
><st...@lobosstudios.com>:
>>Hey all,
>>
>>New to CDI - I'm working on switching my JEE webapps from JSF managed 
>>beans to CDI.
>>
>>I use Jetty, exclusively, and JSF works fine with Jetty and OWB, but 
>>@Inject in servlets (and presumably elsewhere) does not.
>>
>>I started out with JBoss Weld, which ships with Jetty 9, but trying to 
>>get Weld working in my IDE was a nightmare and I gave up. (IntelliJ 
>>IDEA Ultimate 2016.2 if anyone cares, but this morning I upgraded to 
>>2016.3)
>>
>>So as an alternative to getting the bundled CDI functionality to work, 
>>I tried OpenWebBeans instead and now I'm good to go, except that I 
>>can't use DI in the servlets I'm creating.
>>
>>I have a workaround (query BeanManager through JNDI), so this is not a 
>>life-or-death urgent issue (not even close!) - but it would be nice if 
>>I could get it working. A mailing list search turned up
>>
>>http://markmail.org/search/?q=servlet+injection+jetty+list%3Aorg.apache.openwebbeans.user+order%3Adate-backward#query:servlet%20injection%20jetty%20list%3Aorg.apache.openwebbeans.user%20order%3Adate-backward+page:2+mid:gzti4hxxl76lqyhf+state:results
>>
>>That thread states that Jetty 8 is buggy and that the OWB team even 
>>gave up on working with Jetty and switched to Tomcat* - but the thread 
>>is from 2012, and Jetty 8 was EOL'd a while ago.
>>
>>So my questions are:
>>
>>** What is the current state of @Inject using OWB and Jetty?
>>** If it's not working, what would be required to *get* it working?
>>
>>Weld can do DI into Servlets and Filters in Jetty 7, 8 or 9, and into 
>>Servlet listeners in 9.1.1 or newer. (according to 
>>https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty)
>>
>>But I'd much rather use OWB.
>>
>>Thanks,
>>    Steve
>>
>>* OWB and Tomcat are both ASF projects. Weird that y'all didn't use 
>>Tomcat from the start.
>>
>>
>>--
>>Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | 
>>Facebook.com/LobosStudios | @LobosStudios
>>Web Development - Mobile Development - Helpdesk/Tech Support - 
>>Computer Sales & Service
>>Acer Authorized Reseller - Computers, Windows and Android Tablets, 
>>Accessories
>>
>>Steve Sobol - CEO, Senior Developer and Server Jockey
>>steve@LobosStudios.com
>>
>

Re: OWB, Servlets and Jetty 9

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi Steve,

think we are very few to use jetty and with modern tooling (tomee embedded,
tomcat embedded etc) jetty request kind of decreased I think.

To make it work you would need to wrap the InstanceManager instantiating
servlets/filters of jetty to add CDI integration there. This is pretty
close of what tomcat integration does (
https://github.com/apache/openwebbeans/blob/trunk/webbeans-tomcat7/src/main/java/org/apache/webbeans/web/tomcat7/TomcatInstanceManager.java
).

BTW out of curiosity: why didn't you choose tomee instead of integrating it
all yourself?



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

2016-06-07 19:04 GMT+02:00 Steve Sobol - Lobos Studios <
steve@lobosstudios.com>:

> Hey all,
>
> New to CDI - I'm working on switching my JEE webapps from JSF managed
> beans to CDI.
>
> I use Jetty, exclusively, and JSF works fine with Jetty and OWB, but
> @Inject in servlets (and presumably elsewhere) does not.
>
> I started out with JBoss Weld, which ships with Jetty 9, but trying to get
> Weld working in my IDE was a nightmare and I gave up. (IntelliJ IDEA
> Ultimate 2016.2 if anyone cares, but this morning I upgraded to 2016.3)
>
> So as an alternative to getting the bundled CDI functionality to work, I
> tried OpenWebBeans instead and now I'm good to go, except that I can't use
> DI in the servlets I'm creating.
>
> I have a workaround (query BeanManager through JNDI), so this is not a
> life-or-death urgent issue (not even close!) - but it would be nice if I
> could get it working. A mailing list search turned up
>
>
> http://markmail.org/search/?q=servlet+injection+jetty+list%3Aorg.apache.openwebbeans.user+order%3Adate-backward#query:servlet%20injection%20jetty%20list%3Aorg.apache.openwebbeans.user%20order%3Adate-backward+page:2+mid:gzti4hxxl76lqyhf+state:results
>
> That thread states that Jetty 8 is buggy and that the OWB team even gave
> up on working with Jetty and switched to Tomcat* - but the thread is from
> 2012, and Jetty 8 was EOL'd a while ago.
>
> So my questions are:
>
> ** What is the current state of @Inject using OWB and Jetty?
> ** If it's not working, what would be required to *get* it working?
>
> Weld can do DI into Servlets and Filters in Jetty 7, 8 or 9, and into
> Servlet listeners in 9.1.1 or newer. (according to
> https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty
> )
>
> But I'd much rather use OWB.
>
> Thanks,
>    Steve
>
> * OWB and Tomcat are both ASF projects. Weird that y'all didn't use Tomcat
> from the start.
>
>
> --
> Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com |
> Facebook.com/LobosStudios | @LobosStudios
> Web Development - Mobile Development - Helpdesk/Tech Support - Computer
> Sales & Service
> Acer Authorized Reseller - Computers, Windows and Android Tablets,
> Accessories
>
> Steve Sobol - CEO, Senior Developer and Server Jockey
> steve@LobosStudios.com
>
>

Re[2]: OWB, Servlets and Jetty 9

Posted by Steve Sobol - Lobos Studios <st...@LobosStudios.com>.
Fair enough. It's just so much more elegant to use the annotation. :)

But I didn't know about this alternate method that doesn't require JNDI. 
Thank you...

--
Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | 
Facebook.com/LobosStudios | @LobosStudios
Web Development - Mobile Development - Helpdesk/Tech Support - Computer 
Sales & Service
Acer Authorized Reseller - Computers, Windows and Android Tablets, 
Accessories

Steve Sobol - CEO, Senior Developer and Server Jockey
steve@LobosStudios.com



------ Original Message ------
From: "Mark Struberg" <st...@yahoo.de>
To: "openwebbeans-user" <us...@openwebbeans.apache.org>; "Steve Sobol - 
Lobos Studios" <st...@LobosStudios.com>
Sent: 6/8/2016 12:02:35 AM
Subject: Re: OWB, Servlets and Jetty 9

>Hi Steve!
>
>Welcome to OWB ;)
>
>I didn’t use Jetty for quite a while to be honest.
>
>In my personal view Tomcat 8 is really as fast and small as it gets 
>(4MB stripped down) and tc-8.5 and tc-9.0 even provide HTTP2 support.
>Or course it’s a personal flavour and OWB should work with Jetty and 
>other servlet containers as well.
>
>Sadly for injecting into Servlets, Listeners and Filters we would need 
>an even deeper integration. This is chicken-egg problem. With pure 
>servlet functionality we cannot ‚create‘ parts of the servlet container 
>itself.
>Anyway, there is not much need anymore to do this nor to use JNDI for 
>the lookup. Just use
>
>YourBean instance = CDI.current().select(YourBean.class).get();
>
>You can even store away the ‚instance‘ in a member field in your 
>servlet (so you don’t have to look it up for each request). After all 
>it’s just a proxy anyway, so once the container is started it doesn’t 
>change anymore.
>Probably the best bet is to use the Servlet#init(ServletConfig) method 
>to resolve the proxy and store it in a member field inside the servlet.
>
>After all the injection into Servlets, Filters, Listeners, etc is not 
>much different from what this does anyway.
>
>On the benefit side: this solution works on each and every Servlet 
>container!
>
>If you need this for the EE6 version of OWB (OWB-1.2.x) then plz look 
>at Apache DeltaSpike BeanProvider [1].
>Side note: In case you don’t know it yet then take a look at 
>DeltaSpike. It contains a lot of great stuff, e.g. the ConfigResolver 
>stuff, conditional @Exclude, etc
>
>LieGrue,
>strub
>
>[1] http://deltaspike.apache.org/documentation/core.html
>
>
>
>>  Am 07.06.2016 um 19:04 schrieb Steve Sobol - Lobos Studios 
>><st...@LobosStudios.com>:
>>
>>  Hey all,
>>
>>  New to CDI - I'm working on switching my JEE webapps from JSF managed 
>>beans to CDI.
>>
>>  I use Jetty, exclusively, and JSF works fine with Jetty and OWB, but 
>>@Inject in servlets (and presumably elsewhere) does not.
>>
>>  I started out with JBoss Weld, which ships with Jetty 9, but trying 
>>to get Weld working in my IDE was a nightmare and I gave up. (IntelliJ 
>>IDEA Ultimate 2016.2 if anyone cares, but this morning I upgraded to 
>>2016.3)
>>
>>  So as an alternative to getting the bundled CDI functionality to 
>>work, I tried OpenWebBeans instead and now I'm good to go, except that 
>>I can't use DI in the servlets I'm creating.
>>
>>  I have a workaround (query BeanManager through JNDI), so this is not 
>>a life-or-death urgent issue (not even close!) - but it would be nice 
>>if I could get it working. A mailing list search turned up
>>
>>  
>>http://markmail.org/search/?q=servlet+injection+jetty+list%3Aorg.apache.openwebbeans.user+order%3Adate-backward#query:servlet%20injection%20jetty%20list%3Aorg.apache.openwebbeans.user%20order%3Adate-backward+page:2+mid:gzti4hxxl76lqyhf+state:results
>>
>>  That thread states that Jetty 8 is buggy and that the OWB team even 
>>gave up on working with Jetty and switched to Tomcat* - but the thread 
>>is from 2012, and Jetty 8 was EOL'd a while ago.
>>
>>  So my questions are:
>>
>>  ** What is the current state of @Inject using OWB and Jetty?
>>  ** If it's not working, what would be required to *get* it working?
>>
>>  Weld can do DI into Servlets and Filters in Jetty 7, 8 or 9, and into 
>>Servlet listeners in 9.1.1 or newer. (according to 
>>https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty)
>>
>>  But I'd much rather use OWB.
>>
>>  Thanks,
>>     Steve
>>
>>  * OWB and Tomcat are both ASF projects. Weird that y'all didn't use 
>>Tomcat from the start.
>>
>>
>>  --
>>  Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | 
>>Facebook.com/LobosStudios | @LobosStudios
>>  Web Development - Mobile Development - Helpdesk/Tech Support - 
>>Computer Sales & Service
>>  Acer Authorized Reseller - Computers, Windows and Android Tablets, 
>>Accessories
>>
>>  Steve Sobol - CEO, Senior Developer and Server Jockey
>>  steve@LobosStudios.com
>


Re: OWB, Servlets and Jetty 9

Posted by Mark Struberg <st...@yahoo.de>.
Hi Steve!

Welcome to OWB ;)

I didn’t use Jetty for quite a while to be honest. 

In my personal view Tomcat 8 is really as fast and small as it gets (4MB stripped down) and tc-8.5 and tc-9.0 even provide HTTP2 support. 
Or course it’s a personal flavour and OWB should work with Jetty and other servlet containers as well.

Sadly for injecting into Servlets, Listeners and Filters we would need an even deeper integration. This is chicken-egg problem. With pure servlet functionality we cannot ‚create‘ parts of the servlet container itself. 
Anyway, there is not much need anymore to do this nor to use JNDI for the lookup. Just use

YourBean instance = CDI.current().select(YourBean.class).get();

You can even store away the ‚instance‘ in a member field in your servlet (so you don’t have to look it up for each request). After all it’s just a proxy anyway, so once the container is started it doesn’t change anymore.
Probably the best bet is to use the Servlet#init(ServletConfig) method to resolve the proxy and store it in a member field inside the servlet. 

After all the injection into Servlets, Filters, Listeners, etc is not much different from what this does anyway.

On the benefit side: this solution works on each and every Servlet container!

If you need this for the EE6 version of OWB (OWB-1.2.x) then plz look at Apache DeltaSpike BeanProvider [1]. 
Side note: In case you don’t know it yet then take a look at DeltaSpike. It contains a lot of great stuff, e.g. the ConfigResolver stuff, conditional @Exclude, etc

LieGrue,
strub

[1] http://deltaspike.apache.org/documentation/core.html



> Am 07.06.2016 um 19:04 schrieb Steve Sobol - Lobos Studios <st...@LobosStudios.com>:
> 
> Hey all,
>  
> New to CDI - I'm working on switching my JEE webapps from JSF managed beans to CDI.
>  
> I use Jetty, exclusively, and JSF works fine with Jetty and OWB, but @Inject in servlets (and presumably elsewhere) does not.
>  
> I started out with JBoss Weld, which ships with Jetty 9, but trying to get Weld working in my IDE was a nightmare and I gave up. (IntelliJ IDEA Ultimate 2016.2 if anyone cares, but this morning I upgraded to 2016.3)
> 
> So as an alternative to getting the bundled CDI functionality to work, I tried OpenWebBeans instead and now I'm good to go, except that I can't use DI in the servlets I'm creating.
>  
> I have a workaround (query BeanManager through JNDI), so this is not a life-or-death urgent issue (not even close!) - but it would be nice if I could get it working. A mailing list search turned up
>  
> http://markmail.org/search/?q=servlet+injection+jetty+list%3Aorg.apache.openwebbeans.user+order%3Adate-backward#query:servlet%20injection%20jetty%20list%3Aorg.apache.openwebbeans.user%20order%3Adate-backward+page:2+mid:gzti4hxxl76lqyhf+state:results
>  
> That thread states that Jetty 8 is buggy and that the OWB team even gave up on working with Jetty and switched to Tomcat* - but the thread is from 2012, and Jetty 8 was EOL'd a while ago.
>  
> So my questions are:
>  
> ** What is the current state of @Inject using OWB and Jetty?
> ** If it's not working, what would be required to *get* it working? 
> 
> Weld can do DI into Servlets and Filters in Jetty 7, 8 or 9, and into Servlet listeners in 9.1.1 or newer. (according to https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty)
>  
> But I'd much rather use OWB.
>  
> Thanks,
>    Steve
>  
> * OWB and Tomcat are both ASF projects. Weird that y'all didn't use Tomcat from the start.
>  
>  
> -- 
> Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios
> Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service
> Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories
>  
> Steve Sobol - CEO, Senior Developer and Server Jockey
> steve@LobosStudios.com


Re: OWB, Servlets and Jetty 9

Posted by Mark Struberg <st...@yahoo.de>.
txs for the catch - fixed that now ;)

LieGrue,
strub

> Am 07.06.2016 um 19:07 schrieb Steve Sobol - Lobos Studios <st...@LobosStudios.com>:
> 
> And incidentally, the mailto link at http://openwebbeans.apache.org/community.html is a link to users [at] openwebbeans.apache.org - with an extra s at the end. Please fix that. Caused some confusion when I tried to send mail to that address and it bounced "user unknown"
>  
>  
> -- 
> Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios
> Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service
> Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories
>  
> Steve Sobol - CEO, Senior Developer and Server Jockey
> steve@LobosStudios.com
>  
>  
>  
> ------ Original Message ------
> From: "Steve Sobol - Lobos Studios" <st...@LobosStudios.com>
> To: user@openwebbeans.apache.org
> Sent: 6/7/2016 10:04:47 AM
> Subject: OWB, Servlets and Jetty 9
>  
>> Hey all,
>>  
>> New to CDI - I'm working on switching my JEE webapps from JSF managed beans to CDI.
>>  
>> I use Jetty, exclusively, and JSF works fine with Jetty and OWB, but @Inject in servlets (and presumably elsewhere) does not.
>>  
>> I started out with JBoss Weld, which ships with Jetty 9, but trying to get Weld working in my IDE was a nightmare and I gave up. (IntelliJ IDEA Ultimate 2016.2 if anyone cares, but this morning I upgraded to 2016.3)
>> 
>> So as an alternative to getting the bundled CDI functionality to work, I tried OpenWebBeans instead and now I'm good to go, except that I can't use DI in the servlets I'm creating.
>>  
>> I have a workaround (query BeanManager through JNDI), so this is not a life-or-death urgent issue (not even close!) - but it would be nice if I could get it working. A mailing list search turned up
>>  
>> http://markmail.org/search/?q=servlet+injection+jetty+list%3Aorg.apache.openwebbeans.user+order%3Adate-backward#query:servlet%20injection%20jetty%20list%3Aorg.apache.openwebbeans.user%20order%3Adate-backward+page:2+mid:gzti4hxxl76lqyhf+state:results
>>  
>> That thread states that Jetty 8 is buggy and that the OWB team even gave up on working with Jetty and switched to Tomcat* - but the thread is from 2012, and Jetty 8 was EOL'd a while ago.
>>  
>> So my questions are:
>>  
>> ** What is the current state of @Inject using OWB and Jetty?
>> ** If it's not working, what would be required to *get* it working? 
>> 
>> Weld can do DI into Servlets and Filters in Jetty 7, 8 or 9, and into Servlet listeners in 9.1.1 or newer. (according to https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty)
>>  
>> But I'd much rather use OWB.
>>  
>> Thanks,
>>    Steve
>>  
>> * OWB and Tomcat are both ASF projects. Weird that y'all didn't use Tomcat from the start.
>>  
>>  
>> -- 
>> Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios
>> Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service
>> Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories
>>  
>> Steve Sobol - CEO, Senior Developer and Server Jockey
>> steve@LobosStudios.com


Re: OWB, Servlets and Jetty 9

Posted by Steve Sobol - Lobos Studios <st...@LobosStudios.com>.
And incidentally, the mailto link at 
http://openwebbeans.apache.org/community.html is a link to users [at] 
openwebbeans.apache.org - with an extra s at the end. Please fix that. 
Caused some confusion when I tried to send mail to that address and it 
bounced "user unknown"


--
Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | 
Facebook.com/LobosStudios | @LobosStudios
Web Development - Mobile Development - Helpdesk/Tech Support - Computer 
Sales & Service
Acer Authorized Reseller - Computers, Windows and Android Tablets, 
Accessories

Steve Sobol - CEO, Senior Developer and Server Jockey
steve@LobosStudios.com



------ Original Message ------
From: "Steve Sobol - Lobos Studios" <st...@LobosStudios.com>
To: user@openwebbeans.apache.org
Sent: 6/7/2016 10:04:47 AM
Subject: OWB, Servlets and Jetty 9

>Hey all,
>
>New to CDI - I'm working on switching my JEE webapps from JSF managed 
>beans to CDI.
>
>I use Jetty, exclusively, and JSF works fine with Jetty and OWB, but 
>@Inject in servlets (and presumably elsewhere) does not.
>
>I started out with JBoss Weld, which ships with Jetty 9, but trying to 
>get Weld working in my IDE was a nightmare and I gave up. (IntelliJ 
>IDEA Ultimate 2016.2 if anyone cares, but this morning I upgraded to 
>2016.3)
>
>So as an alternative to getting the bundled CDI functionality to work, 
>I tried OpenWebBeans instead and now I'm good to go, except that I 
>can't use DI in the servlets I'm creating.
>
>I have a workaround (query BeanManager through JNDI), so this is not a 
>life-or-death urgent issue (not even close!) - but it would be nice if 
>I could get it working. A mailing list search turned up
>
>http://markmail.org/search/?q=servlet+injection+jetty+list%3Aorg.apache.openwebbeans.user+order%3Adate-backward#query:servlet%20injection%20jetty%20list%3Aorg.apache.openwebbeans.user%20order%3Adate-backward+page:2+mid:gzti4hxxl76lqyhf+state:results
>
>That thread states that Jetty 8 is buggy and that the OWB team even 
>gave up on working with Jetty and switched to Tomcat* - but the thread 
>is from 2012, and Jetty 8 was EOL'd a while ago.
>
>So my questions are:
>
>** What is the current state of @Inject using OWB and Jetty?
>** If it's not working, what would be required to *get* it working?
>
>Weld can do DI into Servlets and Filters in Jetty 7, 8 or 9, and into 
>Servlet listeners in 9.1.1 or newer. (according to 
>https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty)
>
>But I'd much rather use OWB.
>
>Thanks,
>    Steve
>
>* OWB and Tomcat are both ASF projects. Weird that y'all didn't use 
>Tomcat from the start.
>
>
>--
>Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | 
>Facebook.com/LobosStudios | @LobosStudios
>Web Development - Mobile Development - Helpdesk/Tech Support - Computer 
>Sales & Service
>Acer Authorized Reseller - Computers, Windows and Android Tablets, 
>Accessories
>
>Steve Sobol - CEO, Senior Developer and Server Jockey
>steve@LobosStudios.com
>