Strange problem with CDI/Weld

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

Strange problem with CDI/Weld

Bernhard Donaubauer
Hello,


I encountered a strange problem with CDI on jetty.

I installed the jetty CDI module with


java -jar start.jar --add-to-start=cdi

that gives me some additinal libs and CDI support

ls  lib/cdi | cat
javax.enterprise.cdi-api-1.2.jar
javax.inject-1.0.jar
javax.interceptor-api-1.2.jar
jboss-classfilewriter-1.1.2.Final.jar
jboss-logging-3.2.1.Final.jar
weld-api-2.4.SP1.jar
weld-core-impl-2.4.3.Final.jar
weld-core-jsf-2.4.8.Final.jar
weld-environment-common-2.4.3.Final.jar
weld-servlet-core-2.4.3.Final.jar
weld-spi-2.4.SP1.jar

Then I build a very basic test application with CDI, JSF and JPA.
Everthing worked fine till I accidentally copied my app.war to app1.war
in the webapp directory.

Suddenly I got the exception

Caused by: org.jboss.weld.context.ContextNotActiveException:
WELD-001303: No active contexts for scope type
javax.enterprise.context.SessionScoped

I found out that jetty creates two contexts app and app1 but CDI only
works in one of those contexts. If I copy app.war to app2.war I have 3
Contexts but CDI works only in one.

I found this bug report regarding "WELD-2497 Weld API - make it possible
to propagate built-in contexts"

https://issues.jboss.org/browse/WELD-2497

So I have 3 questions at the moment:

a) Could somebody explain what's going on here. There are some threads
on stackoverflow but I don't understand what the real problem is.

b) Is WELD-2497 the fix for my problem?

c) I ist possible to use Weld3.1 with jetty?


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

Re: Strange problem with CDI/Weld

Joakim Erdfelt-8




On Tue, Apr 23, 2019 at 4:46 AM Bernhard Donaubauer <[hidden email]> wrote:
I installed the jetty CDI module with

java -jar start.jar --add-to-start=cdi

This is an experimental module for server side initiated CDI support using Weld.
In other words, CDI forced to load at the server side, not initiated by a WebApp.

Everthing worked fine till I accidentally copied my app.war to app1.war
in the webapp directory.

Suddenly I got the exception

Caused by: org.jboss.weld.context.ContextNotActiveException:
WELD-001303: No active contexts for scope type
javax.enterprise.context.SessionScoped

I found out that jetty creates two contexts app and app1 but CDI only
works in one of those contexts. If I copy app.war to app2.war I have 3
Contexts but CDI works only in one.

I found this bug report regarding "WELD-2497 Weld API - make it possible
to propagate built-in contexts"

https://issues.jboss.org/browse/WELD-2497

So I have 3 questions at the moment:

a) Could somebody explain what's going on here. There are some threads
on stackoverflow but I don't understand what the real problem is.

This is a Weld community question, sorry, we cannot help here.
 
b) Is WELD-2497 the fix for my problem?

This also is a Weld community question.
 
c) I ist possible to use Weld3.1 with jetty?

Yes, but not by using the Server provided CDI.
You'll have to use the webapp provided CDI, by including the Weld libs in your webapp and also configuring your webapp based on the weld documentation.

- Joakim Erdfelt

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