【问题标题】:Maven - CDI error when deploying on Glassfish Web ProfileMaven - 在 Glassfish Web Profile 上部署时出现 CDI 错误
【发布时间】:2013-09-06 14:53:28
【问题描述】:

我是 Maven 新手。

尝试在 Glassfish Server 3.1.2.2 Web Profile 上部署 WAR 应用程序时,在 Linux 上使用 maven 3.0.4 构建时出现以下错误:“org.jboss.weld.exceptions.DeploymentException : WELD-001408 类型 [...]" 的不满足依赖关系。

CDI 在该错误引起的类上没有任何问题。证据是:相同的构建适用于 Glassfish Server 3.1.2.2 Full Profile。该项目在 main/webapp/WEB-INF 上有 beans.xml

一个有趣的细节是,当我从依赖项中删除“provided”范围时,错误消失并且部署工作正常。

生成的具有默认范围“编译”的 WAR 给了我一个 24MB 文件。生成的具有“已提供”范围的 WAR 给了我一个 11MB 文件。

如果我错了,请纠正我,但我认为没有必要将库放在由应用程序服务器提供的战争中。我在这里错过了什么?

该应用程序使用 JSF 2.1、EJB 3.1、CDI 1.0、JPA 2.0 和 JTA 规范。

这是我的 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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>alfabr</groupId>
    <artifactId>AlfaBR</artifactId>
    <packaging>war</packaging>
  <version>1.2.0-SNAPSHOT</version>
  <name>AlfaBR Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <repositories>
    <repository>
        <id>prime-repo</id>
        <name>PrimeFaces Maven Repository</name>
        <url>http://repository.primefaces.org</url>
        <layout>default</layout>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>maven.java.net</id>
      <name>Java.net Maven2 Repository</name>
      <url>http://download.java.net/maven/2</url>
    </pluginRepository>
  </pluginRepositories>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>javax.persistence</artifactId>
        <version>2.1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.inject</groupId>
        <artifactId>javax.inject</artifactId>
        <version>1</version>
            <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>3.4</version>
    </dependency>
    <dependency>
        <groupId>javax.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.1</version>
            <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <type>maven-plugin</type>
    </dependency>
    <dependency>
        <groupId>com.itextpdf</groupId>
        <artifactId>itextpdf</artifactId>
        <version>5.4.3</version>
    </dependency>
    <dependency>
        <groupId>javax.ejb</groupId>
        <artifactId>javax.ejb-api</artifactId>
        <version>3.2</version>
            <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.1</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
            <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.el</groupId>
        <artifactId>javax.el-api</artifactId>
        <version>3.0.0</version>
            <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <version>1.0</version>
            <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>org.eclipse.persistence.jpa</artifactId>
        <version>2.4.2</version>
            <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.directory.studio</groupId>
        <artifactId>org.apache.commons.codec</artifactId>
        <version>1.8</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.rpc</groupId>
        <artifactId>javax.xml.rpc-api</artifactId>
        <version>1.1</version>
            <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>persistence-api</artifactId>
        <version>1.0.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish.main</groupId>
        <artifactId>javax.transaction</artifactId>
        <version>4.0-b33</version>
            <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.primefaces.themes</groupId>
        <artifactId>bootstrap</artifactId>
        <version>1.0.9</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-io</artifactId>
        <version>1.3.2</version>
    </dependency>
    <dependency>
        <groupId>commons-fileupload</groupId>
        <artifactId>commons-fileupload</artifactId>
        <version>1.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis</artifactId>
        <version>1.4</version>
    </dependency>
  </dependencies>
  <build>
      <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArguments>
                    <verbose />
                    <bootclasspath>${java.home}/lib/rt.jar${path.separator}${java.home}/lib/jce.jar</bootclasspath>
                </compilerArguments>
            </configuration>
        </plugin>       
       </plugins>
    <finalName>AlfaBR</finalName>
  </build>
</project>

【问题讨论】:

  • 请提供完整的堆栈跟踪。
  • 还有有问题的类代码 - 您可能正在注入一些不属于 Java EE Web Profile 的内容。此外,这极不可能与 maven 有任何关系。
  • 你是对的。谢谢,给您带来的不便敬请谅解。

标签: java maven jakarta-ee glassfish cdi


【解决方案1】:

@rdcrng 是对的。这与maven无关。

我们正在将应用程序从 Glassfish Full Profile 转移到 Web Profile 并开始使用 maven。

所以我在一个注入的依赖项中找到了一个 JAX-WS 2.2 注释。正如here 所说,JAX-WS 不包含在 Glassfish 3.1.2.2 Web Profile 中。

我删除它,构建成功部署。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-18
    • 2015-05-27
    • 1970-01-01
    • 2023-03-06
    • 1970-01-01
    相关资源
    最近更新 更多