0
votes

In our company, we are adding Maven to a Project than never had it, but we need our Project to use the Dynamic Web Module 2.5 Facet because we will deploy it on a Tomcat 6 Server, and we are not allowed to replace it with a Tomcat 7 Server.

I can manually set the Facet to 2.5, but the thing is, that when I update the project on Eclipse using the Maven tools, it automatically changes it to 3.0.

I've tried dozens of solutions, like changing the web.xml header, changing the Facets and updating the projects on a certain order, adding some thing to the pom.xml file, but none of them worked, and on most of the places I have been looking, people had a problem in the other way.

Here is 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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>Stofi</groupId>
  <artifactId>Stofi</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <properties>
        <src.dir>src</src.dir>
        <basedir></basedir>
    </properties>
  <build>
    <directory>${project.basedir}/target</directory>
    <outputDirectory>target/classes</outputDirectory>
    <finalName>${project.artifactId}</finalName>
    <testOutputDirectory>target/test-classes</testOutputDirectory>
    <sourceDirectory>${src.dir}</sourceDirectory>
    <testSourceDirectory>src/test/java</testSourceDirectory>
    <resources>
            <resource> 
                <directory>src/Idiomas</directory>
<!--                <excludes> -->
<!--                 <exclude>**/*.properties</exclude> -->
<!--                 </excludes> -->
            </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
      </testResource>
    </testResources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <version>3.1</version>
            <excludes>
            <exclude>src/Idiomas</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-eclipse-plugin</artifactId>
        <version>2.10</version>
      </plugin>
         <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-war-plugin</artifactId>
         <configuration>
               <webappDirectory>WebContent</webappDirectory>
               <packagingExcludes>src\Idiomas</packagingExcludes>
               <packagingExcludes>WEB-INF\classes\*.properties</packagingExcludes>
               <packagingExcludes>WEB-INF\classes\**\*.java</packagingExcludes>
<!--           <outputDirectory>C:\Desarrollo\ServersPruebas\tomcat_stofi\webapps</outputDirectory> -->
                <webResources>
                 <resource>
                 <targetPath>WEB-INF\classes\Idiomas\</targetPath>
                 <filtering>false</filtering>
                 <directory>src\Idiomas</directory>
                 <includes>
                 <include>**\*.*</include>
                 </includes>
                 <excludes>
                 <exclude>**\*.git</exclude>
                 </excludes>
                 </resource>
                 </webResources>
         </configuration>
      </plugin>
    </plugins>
  </build>
    <dependencies>
      <!-- <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
      </dependency>
      <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>4.1.6.RELEASE</version>
            <scope>test</scope>
    </dependency> -->
<!--    LOCAL LIBRARIES -->
   </dependencies>
    <packaging>war</packaging>
</project>

Here is the WEB.XML header

<web-app xmlns="http://java.sun.com/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

Here is the org.eclipse.wst.common.project.facet.core.xml

<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
  <fixed facet="jst.java"/>
  <installed facet="jst.java" version="1.6"/>
  <installed facet="wst.jsdt.web" version="1.0"/>
  <installed facet="jst.web" version="2.5"/>
</faceted-project>

Thank you all for your replies.

1
edit the pom.yml file into the main question, then we can help youFerrybig
Why, oh why, are you using maven-eclipse-plugin? Remove this and install M2Eclipse.Tunaki
I've removed the maven-eclipse-plugin form pom.xml but it keeps doing the same.Aitor Gonzalez

1 Answers

0
votes

I think I've solved the problem.

I've just set the following tags to the 'maven-war-plugin' configuration:

<warSourceDirectory>WebContent</warSourceDirectory> 
<webappDirectory>WebContent</webappDirectory>

By default, Maven was looking for the web.xml file on src/main/webapp,but it wasn't there, it was on WebContent/WEB-INF

Thanks for all your replies.