2014-07-21 33 views
1

我有一個maven項目,具有javaee7 jsf2.2和cdi和jetty-maven-plugin的依賴關係。與jetty maven-plugin和cdi不工作的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> 

file structure

任何幫助,或工作示例項目將不勝感激。

編輯: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 or[email protected]3278af54: java.lang.NoClassDefFoundError: org/apache/catalina/core/ApplicationContextFacade 

我望去這個錯誤,發現缺少類DEF是tomcat的,這林不使用的部分。

一個工作示例項目將非常感激。

編輯2:

這裏是我的項目的github存儲庫。

github maven jetty cdi repo

+0

的beans.xml文件就足夠了。定義「不工作」。注射沒有發生?如果是這樣,請顯示一些代碼。 PS:我至少在jee7 API依賴項上缺少一些「提供」範圍。 – Gimby

+0

這已經得到解決 - http://stackoverflow.com/questions/20483186/deploying-a-war-to-jetty-with-cdi/20505983#20505983 –

+0

我添加了該文章中的文件,並得到一個新的錯誤。 java.lang.NoClassDefFoundError:org/apache/catalina/core/ApplicationContextFacade – arkhon

回答

3

該錯誤是由焊接的組合和最新的碼頭引起的。我改變了碼頭到9.1.5,現在一切正常。感謝您的所有建議。