【问题标题】:Maven - error while deploying ear to jboss 6.x - ClassFormatErrorMaven - 将 ear 部署到 jboss 6.x 时出错 - ClassFormatError
【发布时间】:2013-10-24 15:57:21
【问题描述】:

我有一个 Maven 项目,我在其中打包到 EAR 文件,并在 /lib 文件夹中包含所有依赖项。但是在部署 EAR 文件时,我在 jboss 中遇到了 2 个以下错误。

 1)java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/jms/JMSException

对于上述错误,我了解到我需要删除 /lib 文件夹中的 j2ee 相关 jar 文件。

 2)java.lang.ClassCastException: com.xx.sms.ejb.ws.xxx.CoordinatorServiceBean cannot be cast to javax.servlet.Servlet

这个错误我相信我应该从 /lib 文件夹中删除与 javax.servlet 相关的 jar 文件。因为这可能已经由 jboss servletContainer 提供,你应该从 /lib 文件夹中排除。 我是 Maven 世界的新手,不知何故我设法创建了一个 EAR。

让我知道如何在打包 EAR 期间排除 j2ee 相关和 servlet 相关的 jar 文件。 下面是我的 pom.xml

<dependencies>
        <dependency>
            <groupId>com.xxx.sms</groupId> 
            <artifactId>CoordinatorBeans</artifactId> 
            <version>1.0-SNAPSHOT</version>             
        </dependency>
        <dependency>
            <groupId>com.xxx</groupId>
            <artifactId>CoordinatorWeb</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>war</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-ear-plugin</artifactId>
                <configuration>
                    <defaultLibBundleDir>lib</defaultLibBundleDir>
                    <earSourceDirectory>${basedir}</earSourceDirectory>
                    <earSourceIncludes>META-INF/*</earSourceIncludes>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                        </manifest>
                    </archive>
                    <generateApplicationXml>false</generateApplicationXml>
                    <applicationXML>${basedir}/META-INF/application.xml</applicationXML>
                    <modules>
                        <jarModule>
                            <groupId>com.xxx.sms</groupId> 
                            <artifactId>CoordinatorBeans</artifactId> 
                            <bundleDir>/</bundleDir>
                            <bundleFileName>CoordinatorBeans.jar</bundleFileName>
                        </jarModule>
                        <webModule>
                            <groupId>com.xxx</groupId>
                            <artifactId>CoordinatorWeb</artifactId>
                            <bundleDir>/</bundleDir>
                            <bundleFileName>CoordinatorWeb.war</bundleFileName>
                        </webModule>
                    </modules>
                </configuration>
            </plugin>
        </plugins>
        <finalName>CoordinatorApp</finalName>
    </build>

【问题讨论】:

    标签: maven maven-3 maven-plugin maven-ear-plugin


    【解决方案1】:

    为以下依赖项添加排除项后,它起作用了。

    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.2</version>
        <exclusions>
           <exclusion>
            <groupId>*</groupId>
            <artifactId>*</artifactId>
           </exclusion>
        </exclusions>   
    </dependency>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-28
      • 2013-05-26
      • 1970-01-01
      • 1970-01-01
      • 2012-03-17
      • 1970-01-01
      • 2015-08-18
      • 2019-01-29
      相关资源
      最近更新 更多