【发布时间】:2014-09-11 14:48:24
【问题描述】:
我有一个依赖 javaee7 jsf2.2 和 cdi 以及 jetty-maven-plugin 的 maven 项目。
除了 cdi 之外,该项目运行良好。我无法弄清楚需要哪些配置文件以及将它们放在哪里。唯一的示例项目我可以找到 jetty6 和 jsf2.0 的地方,甚至那些都行不通。
这是我的 pom.xml 和我的文件结构的屏幕截图。
<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>
任何帮助或工作示例项目将不胜感激。
编辑:
我已按照本文所述更新了我的文件:stackoverflow answer 你可以在上面看到新的文件结构。
现在我收到以下错误消息:
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
我查看了这个错误,发现缺少的类 def 是我没有使用的 tomcat 的一部分。
非常感谢一个工作示例项目。
编辑2:
这是我项目的 github 存储库。
【问题讨论】:
-
beans.xml 就足够了。定义“不工作”。注射没有发生?如果是这样,请显示一些代码。 PS:我至少在 jee7 API 依赖项上缺少一些“提供”范围。
-
我在该帖子中添加了文件并收到新错误。 java.lang.NoClassDefFoundError: org/apache/catalina/core/ApplicationContextFacade
-
在我的帖子中添加了 github repo