views:

1005

answers:

2

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.

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.

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?

Versions: Eclipse 3.4 Jboss 4.2

Thanks in advance.

A: 

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.

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

Robin
+2  A: 

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.

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.

Vineet Reynolds
Thank you Vineet, problem solved.
pribeiro
You're welcome :)
Vineet Reynolds