0

Trying to set up a maven web project with CDI 2.0 which should run on Tomcat 8.5. So I have to install the jboss WELD 3.

What is the relation between Weld, CDI and Java EE versions?

With the POM declaration out of here (only "weld-servlet-core")...

WELD - POM declaration (docs.jboss.org)

I get an Error with the "WeldTerminalListener", declared in the web.xml like that:

<!-- This listener should always be the last registered listener -->
<listener>
    <listener-class>org.jboss.weld.servlet.WeldTerminalListener</listener-class>
</listener>

ERROR: java.lang.ClassNotFoundException: org.jboss.weld.servlet.WeldTerminalListener


If I use the following POM declaration it works fine:

<dependency>
  <groupId>org.jboss.weld.servlet</groupId>
  <artifactId>weld-servlet</artifactId>
  <version>2.3.5.Final</version>
</dependency>

weld-servlet (without "-core") 3 is only available as alpha. The Version 2 is not CDI 2.0 able.

So which dependency in the POM do I need, to get it run?

Jens Fuchs
  • 65
  • 1
  • 9

2 Answers2

0

Regarding the version 3.x of the weld-servlet-core library, it seems that the actual location of the class is different. After exploring the library jar file, I've found that the full name of the class is as follows:

<listener>
    <listener-class>org.jboss.weld.module.web.servlet.WeldTerminalListener</listener-class>
</listener>
Eugene K.
  • 117
  • 6
0

Weld 3 has changed some artifacts names. It's the shaded artifacts which have changed, see this part of documentation.

Namely, in Weld 2 weld-servlet was the shaded version of this JAR so the equivalent in Weld 3 is weld-servlet-shaded.

In your case you can be using either this shaded version (org.jboss.weld.servlet:weld-servlet-shaded) or the core version (org.jboss.weld.servlet:weld-servlet-core).

As for the class of the listener, you can check yourself on GH, but the story is it was altered as well (say hello to package clash in JDK 9+). It is now:

<listener>
    <listener-class>org.jboss.weld.module.web.servlet.WeldTerminalListener</listener-class>
</listener>

Weld documentation (for 3.0.3.Final) has faulty information on this. I'll make sure it's corrected for next version (thanks for pointing this out).

Siliarus
  • 6,393
  • 1
  • 14
  • 30