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 6678771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:16:54+00:00 2026-05-26T04:16:54+00:00

I have an EAR file which I create with maven, it’s made up of

  • 0

I have an EAR file which I create with maven, it’s made up of several projects including one war file project. I need to have the build create two ear files which are identical except that one has the kerberos settings disabled in the war file. To disable these settings, I just need to have a section of the web.xml commented out.

What is the best way to do this with Maven? I’d prefer not to create a whole new project which is a duplicate but with the different web.xml file. I’d prefer to have some way to have two web.xml files in the war file project and have the build select which one to use for which ear file. Can anyone suggest how to do this?

  • 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-26T04:16:55+00:00Added an answer on May 26, 2026 at 4:16 am

    Solution 1

    You could use a combination of profiles and maven-war-plugin configuration. In the WAR project’s POM, define a default-activated profile and one explicitly activated, they’ll be mutually exclusive this way (unless you have other profiles defined, but then you’ll only have to remember yourself to activate one or the other):

    <profiles>
        <profile>
            <id>security</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <web.xml.properties>security.properties</web.xml.properties>
            </properties>
        </profile>
        <profile>
            <id>no-security</id>
            <properties>
                <web.xml.properties>no-security.properties</web.xml.properties>
            </properties>
        </profile>
    </profiles>
    

    Then, in the build section, define appropriate filtering:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <filters>
                        <filter>${web.xml.filter}</filter>
                    </filters>
                    <webResources>
                        <resource>
                            <directory>WebContent/WEB-INF</directory>
                            <filtering>true</filtering>
                            <targetPath>WEB-INF</targetPath>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    Change your web.xml so that in the variable place you have a template marker, like ${security.fragment}. Finally, add two property filessecurity.propertiesandno-security.properties`:

    # file: security.properties
    security.fragment=<your_security_config>...</your_security_config>
    
    # file: no-security.properties
    security.fragment=
    

    Invoke Maven either with -P no-security or -P security, or without -P. The end.

    Solution 2

    This does not use filtering, but 2 separate web.xmls. It’s a bit worse then, as it repeats code.

    Define profiles like in solution 1, but set a different property: location of the web.xml in your project. Use this property in the <build> section to indicate it to the maven-war-plugin:

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webXml>${web.xml.location}</webXml>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    In fact, I was struggling with it in my project as I was writing this. I went for the 2nd solution, as the method with resource filtering does not work well with m2eclipse plugin.

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

Sidebar

Related Questions

I have an .ear file which contains multiple war files. I am moving the
I have an EAR file with a nested EJB project, a .war dynamic web
I have a J2EE app deployed as an EAR file, which in turn contains
I have an EAR file with a bunch of JARs in it, and one
I have multiple (8) WAR files and 1 EAR file that I want to
I have a web application which deploys fine as an ear file. But when
I have an EAR file built by maven and currently I have a commons
Is it possible to create a maven plugin, which would package my project using
I have an ear file that is generated through Maven EAR plugin. The ear
I have an ear file, containing a war file. The war contains a number

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.