Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6060717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:51:26+00:00 2026-05-23T08:51:26+00:00

I’ve a web application configured with Maven which uses a library, also configured with

  • 0

I’ve a web application configured with Maven which uses a library, also configured with Maven and when I package geronimo-servlet_3.0_spec-1.0.jar is included in WEB-INF/lib and I don’t understand why.

I check the library with mvn dependency:tree

$ mvn dependency:tree | grep geronimo
[INFO] +- org.apache.geronimo.specs:geronimo-servlet_3.0_spec:jar:1.0:provided

I check my web app:

$ mvn dependency:tree | grep geronimo
$

However when I run mvn:package the file gets included in WEB-INF/lib.

When I run mvn tomcat:run I can see:

INFO: validateJarFile(/home/stivlo/workspace/private/src/main/webapp/WEB-INF/lib/geronimo-servlet_3.0_spec-1.0.jar) – jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class

Why and how to avoid? Thank you.

UPDATE 1: as requested I add the 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>org.obliquid</groupId>
    <artifactId>test-webapp</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>private webapp</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <repositories>
        <!-- For Jakarta ORO -->
        <repository>
            <id>mvnsearch</id>
            <name>Maven Search</name>
            <url>http://www.mvnsearch.org/maven2/</url>
        </repository>
    </repositories>

    <dependencies>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.obliquid.helpers</groupId>
            <artifactId>obliquid-helpers</artifactId>
            <version>0.9-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <build>
        <finalName>private</finalName>
    </build>

</project>

UPDATE 2: I followed the advice of Stephen C and modified the build section as follows:

<build>
    <finalName>private</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war</artifactId>
            <version>2.1</version>
            <configuration>
                <overlays>
                    <overlay>
                        <groupId>org.obliquid</groupId>
                        <artifactId>test-webapp</artifactId>
                        <excludes>
                            <exclude>WEB-INF/lib/geronimo-servlet_3.0_spec-1.0.jar</exclude>
                        </excludes>
                    </overlay>
                </overlays>
            </configuration>
        </plugin>
    </plugins>
</build>

However geronimo*.jar still gets included. I guess I’ve made a mistake in this configuration.

UPDATE 3: Stephen C. says that I should use

the groupId the artifactId of the WAR
file that contains the JAR file(s)
that you are trying to exclude.

I didn’t know that WAR files could have a groupId and artifactId, in fact in my pom.xml I don’t see any. My project builds a WAR file and has a groupId and an artifactId and those were the ones I tested above without success.

The dependency causing the problem is the following (is a JAR, not a WAR):

<dependency>
    <groupId>org.obliquid.helpers</groupId>
    <artifactId>obliquid-helpers</artifactId>
    <version>0.9-SNAPSHOT</version>
    <scope>compile</scope>
</dependency>

If I try to use the groupId and artifactId listed in this dependency I’ve the following error:

[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-war-plugin:2.1.1:war
(default-war) on project test-webapp:
overlay [ id
org.obliquid.helpers:obliquid-helpers]
is not a dependency of the project. ->
[Help 1]

If I try to use the groupId and artifactId of the JAR included by org.obliquid.helpers:

<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_3.0_spec</artifactId>)

I have the same error.

[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-war-plugin:2.1.1:war
(default-war) on project test-webapp:
overlay [ id
org.apache.geronimo.specs:geronimo-servlet_3.0_spec]
is not a dependency of the project. ->
[Help 1]

Reading the War plugin documentation, I found a section about creating skinny WARs. So I tried the following:

<build>
    <finalName>private</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
                <packagingExcludes>WEB-INF/lib/geronimo-servlet_3.0_spec-1.0.jar</packagingExcludes>
            </configuration>
        </plugin>
    </plugins>
</build>

Still without any success, geronimo-servlet_3.0_spec-1.0.jar is still there!

<groupId>org.obliquid.helpers</groupId>
<artifactId>obliquid-helpers</artifactId>

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project test-webapp: overlay [ id org.obliquid.helpers:obliquid-helpers] is not a dependency of the project. -> [Help 1]

<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_3.0_spec</artifactId>

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project test-webapp: overlay [ id org.apache.geronimo.specs:geronimo-servlet_3.0_spec] is not a dependency of the project. -> [Help 1]

UPDATE 4: I discovered that the target/private.war file is not a zip of target/private/ directory, but the exclusions are done at packaging time and not by deleting files in target/private/ — This means, I’ve to re-test all the things I did before.

  • Suggestion of gouki: doesn’t work, the JAR is still there also in the WAR file.
  • Suggestion of Stephen C., maybe mis-understood: actually I just noticed that the pom.xml is always invalid whatever groupId/artifactId I put of the three possibilities explained above. So they didn’t work for me.
  • What I found in the documentation (packagingExcludes), works.

Now, if I had to choose one of he answers I would choose Stephen C., because he helped me pointing at the documentation of the WAR plugin (I was reading in the wrong places). However I’d accept an answer that doesn’t work, at least in the way I tried (probably wrong). So I’m not going to accept any answer, and add a new answer myself with the final working configuration.

UPDATE 5: I post the relevant part of the pom.xml of obliquid-helpers, that mentions geronimo-servlet_3.0_spec. I’ve marked it optional and with scope provided, still it gets included by a web-app, unless I mark it as “packagingExclude” in the maven-war-plugin configuration.

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.obliquid.helpers</groupId>
  <artifactId>obliquid-helpers</artifactId>
  <version>0.9-SNAPSHOT</version>
  <packaging>jar</packaging>
  <name>obliquid-helpers</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <repositories>
    [...]
  </repositories>

  <dependencies>
    [...]

    <dependency>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-servlet_3.0_spec</artifactId>
      <version>1.0</version>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>

  </dependencies>

</project>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:51:26+00:00Added an answer on May 23, 2026 at 8:51 am

    First I want to thank gouki and Stephen C. for helping me. However their proposed solution didn’t work for me. I’m grateful to them, but I can’t accept their answer, because it would be misleading since it didn’t work for this problem. I’ve upvoted Stephen C. answer, because he pointed me to the right documentation, which was essential to solve the problem.

    Reading the WAR plugin documentation, especially the war:war mojo section, I’ve found an example on how to create Skinny WARs, which did the trick. So here is below the working configuration, to be added to the build section:

    <build>
        <finalName>private</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <packagingExcludes>WEB-INF/lib/geronimo-servlet_3.0_spec-1.0.jar</packagingExcludes>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    The archive part is probably not really needed, but I will find out when I deploy the WAR. The part that does the trick is the packagingExcludes tag, that can contain a comma separated list of tokens to exclude from the WAR before packaging.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.