Maven - 将 ear 部署到 jboss 6.x 时出错 - ClassFormatError



我有一个 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 文件。下面是我的绒球.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>

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

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

相关内容

  • 没有找到相关文章

最新更新