Eclipse 3.4和Jboss部署问题:

时间:2021-06-04 00:04:29

I have a problem when trying to deploy my project in JBoss. The generated war file contains the servlet.jar that are part of my dependencies but conflicts with the servlet classes of JBoss.

尝试在JBoss中部署项目时遇到问题。生成的war文件包含servlet.jar,它是我的依赖项的一部分,但与JBoss的servlet类冲突。

Error ...servlet.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class 

I can remove the servlet.jar from the war file when running an ant build. It deploys and work fine.

运行ant build时,我可以从war文件中删除servlet.jar。它部署和工作正常。

What I would like to do is to tell eclipse to do not deploy the servlet.jar in the war file. How do I do that?

我想做的是告诉eclipse不要在war文件中部署servlet.jar。我怎么做?

Versions: Eclipse 3.4 Jboss 4.2

版本:Eclipse 3.4 Jboss 4.2

Thanks in advance.

提前致谢。

2 个解决方案

#1


To answer the primary question on how to avoid the Servlet.jar from being bundled in the WAR file, you should uncheck the Web library dependency on the servlet.jar file. This can be done from the Project Properties -> Java EE Module Dependencies -> Web libraries; unchecking dependencies in this page prevents them from appearing in the WEB-INF\lib directory of the WAR file.

要回答有关如何避免将Servlet.jar捆绑在WAR文件中的主要问题,您应该取消选中servlet.jar文件上的Web库依赖项。这可以通过Project Properties - > Java EE Module Dependencies - > Web库来完成。取消选中此页面中的依赖项可防止它们出现在WAR文件的WEB-INF \ lib目录中。

On a side note, I would recommend usage of the JBoss runtime library to be included as a Server Runtime, rather than embed the servlet.jar and other Java EE JARs in the Java build and class path. Although I havent used it, the JBoss Tools is likely to make your experience easier in this regard.

另外,我建议将JBoss运行时库用作服务器运行时,而不是在Java构建和类路径中嵌入servlet.jar和其他Java EE JAR。虽然我没有使用它,但JBoss Tools可能会让您在这方面的体验更轻松。

#2


Where are you including the servlet.jar? It should only be a dependency to an external location inside your project. Then it would only be used at build time.

你在哪里包括servlet.jar?它应该只是对项目内部外部位置的依赖。然后它只会在构建时使用。

You also should make sure that you do NOT export this jar from the Order and Export tab in the build configuration.

您还应该确保不从构建配置中的“订购和导出”选项卡导出此jar。

#1


To answer the primary question on how to avoid the Servlet.jar from being bundled in the WAR file, you should uncheck the Web library dependency on the servlet.jar file. This can be done from the Project Properties -> Java EE Module Dependencies -> Web libraries; unchecking dependencies in this page prevents them from appearing in the WEB-INF\lib directory of the WAR file.

要回答有关如何避免将Servlet.jar捆绑在WAR文件中的主要问题,您应该取消选中servlet.jar文件上的Web库依赖项。这可以通过Project Properties - > Java EE Module Dependencies - > Web库来完成。取消选中此页面中的依赖项可防止它们出现在WAR文件的WEB-INF \ lib目录中。

On a side note, I would recommend usage of the JBoss runtime library to be included as a Server Runtime, rather than embed the servlet.jar and other Java EE JARs in the Java build and class path. Although I havent used it, the JBoss Tools is likely to make your experience easier in this regard.

另外,我建议将JBoss运行时库用作服务器运行时,而不是在Java构建和类路径中嵌入servlet.jar和其他Java EE JAR。虽然我没有使用它,但JBoss Tools可能会让您在这方面的体验更轻松。

#2


Where are you including the servlet.jar? It should only be a dependency to an external location inside your project. Then it would only be used at build time.

你在哪里包括servlet.jar?它应该只是对项目内部外部位置的依赖。然后它只会在构建时使用。

You also should make sure that you do NOT export this jar from the Order and Export tab in the build configuration.

您还应该确保不从构建配置中的“订购和导出”选项卡导出此jar。