arkhon
arkhon

Reputation: 765

maven project with jetty-maven-plugin and cdi not working

I have a maven project with dependencies for javaee7 jsf2.2 and cdi and jetty-maven-plugin.

The project works fine except for cdi. I cant figure out what configuration files are need and where to put them. The only example projects for this i could find where with jetty6 and jsf2.0 and even those would not work.

Here is my pom.xml and a screenshot of my filestructure.

<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
     http://maven.apache.org/maven-v4_0_0.xsd">
<!-- pom.xml specification version -->
<modelVersion>4.0.0</modelVersion>

<!-- project settings -->
<groupId>de.beans</groupId>
<artifactId>cdi-test</artifactId>
<version>0.1</version>
<name>test</name>
<packaging>war</packaging>

<!-- project module dependencies -->
<dependencies>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.6</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.2.6</version>
    </dependency>
    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.weld.servlet</groupId>
        <artifactId>weld-servlet</artifactId>
        <version>2.2.3.Final</version>
    </dependency>
</dependencies>

<!-- project maven plugins -->
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.0.v20140526</version>
            <configuration>
                <scanIntervalSeconds>1</scanIntervalSeconds>
                <webApp>
                    <contextPath>/</contextPath>
                </webApp>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.4</version>
            <configuration>
            </configuration>
        </plugin>
    </plugins>
</build>

file structure

Any help, or a working example project would be greatly appreciated.

Edit:

i have updated my files as described in this post: stackoverflow answer you can see the new file structure above.

Now i get the following error message:

INFO: WELD-000101: Transactional services not available. Injection of @Inject UserTransaction not available. Transactional observers will be invoked synchronously.
2014-07-21 09:15:40.682:WARN:oejuc.AbstractLifeCycle:main: FAILED org.eclipse.jetty.annotations.ServletContainerInitializersStarter@3278af54: java.lang.NoClassDefFoundError: org/apache/catalina/core/ApplicationContextFacade

I looked this error up and found that the missing class def is part of tomcat, which im not using.

a working example project would be really appreciated.

Edit2:

here is a github repository of my project.

github maven jetty cdi repo

Upvotes: 2

Views: 1468

Answers (2)

jansohn
jansohn

Reputation: 2326

Will be fixed in WELD 2.2.5.Final

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

Upvotes: 4

arkhon
arkhon

Reputation: 765

The error is caused by the combination of weld and the newest jetty. I changed jetty to 9.1.5 and everything works fine now. Thanks for all your suggestions.

Upvotes: 3

Related Questions