Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Strange problem with CDI/Weld





On Tue, Apr 23, 2019 at 4:46 AM Bernhard Donaubauer <bdonauba@xxxxxxxxx> 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

Back to the top