Maven Java EE Configuration
Asked Answered
O

12

19

In my maven project, I have this Effective POM:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>spring</groupId>
  <artifactId>example</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>example</name>
  <url>http://maven.apache.org</url>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>4.0.3.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.ws</groupId>
      <artifactId>spring-ws-core</artifactId>
      <version>2.1.4.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-web</artifactId>
      <version>3.2.3.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-config</artifactId>
      <version>3.2.3.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>4.3.5.Final</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
      <version>5.1.0.Final</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-orm</artifactId>
      <version>4.0.3.RELEASE</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
      <version>4.0.3.RELEASE</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>http://repo.maven.apache.org/maven2</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>central</id>
      <name>Central Repository</name>
      <url>http://repo.maven.apache.org/maven2</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <sourceDirectory>C:\Users\Kleber\Downloads\Projetos\example\src\main\java</sourceDirectory>
    <scriptSourceDirectory>C:\Users\Kleber\Downloads\Projetos\example\src\main\scripts</scriptSourceDirectory>
    <testSourceDirectory>C:\Users\Kleber\Downloads\Projetos\example\src\test\java</testSourceDirectory>
    <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\classes</outputDirectory>
    <testOutputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\test-classes</testOutputDirectory>
    <resources>
      <resource>
        <directory>C:\Users\Kleber\Downloads\Projetos\example\src\main\resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>C:\Users\Kleber\Downloads\Projetos\example\src\test\resources</directory>
      </testResource>
    </testResources>
    <directory>C:\Users\Kleber\Downloads\Projetos\example\target</directory>
    <finalName>example-0.0.1-SNAPSHOT</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.2-beta-5</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.0</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat7-maven-plugin</artifactId>
        <version>2.2</version>
        <configuration>
          <url>http://localhost:8080/manager/text</url>
          <server>TomcatServer</server>
          <path>/webappExample</path>
          <username>user001</username>
          <password>123</password>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>2.4.1</version>
        <executions>
          <execution>
            <id>default-clean</id>
            <phase>clean</phase>
            <goals>
              <goal>clean</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.3.1</version>
        <executions>
          <execution>
            <id>default-install</id>
            <phase>install</phase>
            <goals>
              <goal>install</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.5</version>
        <executions>
          <execution>
            <id>default-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>resources</goal>
            </goals>
          </execution>
          <execution>
            <id>default-testResources</id>
            <phase>process-test-resources</phase>
            <goals>
              <goal>testResources</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.10</version>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <executions>
          <execution>
            <id>default-testCompile</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
          <execution>
            <id>default-compile</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1.1</version>
        <executions>
          <execution>
            <id>default-war</id>
            <phase>package</phase>
            <goals>
              <goal>war</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.7</version>
        <executions>
          <execution>
            <id>default-deploy</id>
            <phase>deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.0</version>
        <executions>
          <execution>
            <id>default-site</id>
            <phase>site</phase>
            <goals>
              <goal>site</goal>
            </goals>
            <configuration>
              <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
          <execution>
            <id>default-deploy</id>
            <phase>site-deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
            <configuration>
              <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\site</outputDirectory>
              <reportPlugins>
                <reportPlugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-project-info-reports-plugin</artifactId>
                </reportPlugin>
              </reportPlugins>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\site</outputDirectory>
          <reportPlugins>
            <reportPlugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-project-info-reports-plugin</artifactId>
            </reportPlugin>
          </reportPlugins>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <reporting>
    <outputDirectory>C:\Users\Kleber\Downloads\Projetos\example\target\site</outputDirectory>
  </reporting>
</project>

In this moment, in the Markers tab on my Eclipse IDE, this error is being presented:

Description Resource    Path    Location    Type
Dynamic Web Module 3.0 requires Java 1.6 or newer.  example     line 1  Maven Java EE Configuration Problem
One or more constraints have not been satisfied.    example     line 1  Maven Java EE Configuration Problem

I try fix this configuration in the Build path from my project (In Properties/Java Build Path), but when I run Maven > Update Project, the value for this option returned to the previous one.

Where I should change this option to fix this error?

Omar answered 20/4, 2014 at 15:5 Comment(2)
possible duplicate of Error abotut dynamic web module version reported by STSFilar
I did what was suggest on this topic, and an NullPointerException was triggered.Omar
H
46
  1. Go to project Build Path and change the Java Library version to 1.7
  2. Go to Eclipse Preferences -> Java -> Compiler -> Change compliance level to 1.7
  3. Right click on project -> Properties -> Project Facets
  4. Uncheck Dynamic Web Module and click Apply (also uncheck JavaServer Faces if you had that)
  5. Change the Java facet version to 1.7 and click Apply
  6. Add the Dyanmic Web Module v3.0, apply.

Eclipse's facets configuration is buggy. Make sure you keep hitting Apply between checking and unchecking of facets.

Links:

  • Cannot change version of project facet Dynamic Web Module to 3.0?
  • Change version of project facet Dynamic Web Module to 2.5
  • Hubsher answered 20/4, 2014 at 15:51 Comment(2)
    Thanks,I did what you mentioned here, could change it to version 3.0 but even after closing, opening, cleaning and building the project the error messages did not go. So I just right clicked on them to remove them manually. Now the project works ! thanks to buggy Eclipse this bug wasted 3 hours of my time!Filthy
    I had 1 and 2 above in place. The only change I made was the Java facet version and that seems to have done it for me. The Dynamic Web Module seemed to be taking over from Maven so I left it out. All good now, thanks.Fabaceous
    C
    29

    GGrec's solution doesn't work for me. I manage to fixed this issue by adding to pom.xml this:

    <build>
         <finalName>finalName</finalName>
         <plugins>
    
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source> <!-- yours Java version -->
                    <target>1.8</target> <!-- yours Java version -->
                </configuration>
            </plugin>
    
        </plugins>
    </build>
    

    UPDATE: In addition I figured out that everytime you run mvn install command on this pom.xml it overrides previous configuration. The right solution is either remove this version from pom.xml and set it up in eclipse options or just use configuration from pom.xml.

    Concealment answered 16/3, 2015 at 20:16 Comment(2)
    This works for me after doing the "right click on Project > Maven > Update Project"Shana
    Only adding this line: <version>3.1</version> worked for me; the workspace built automatically after saving pom.xml and then the error disappeared.Rozanna
    S
    7

    After following above troubleshooting steps. Update your maven project.

    Right click on your project--> Maven--> Update Project

    Or simply Alt+f5.

    Hope this might help someone.

    Sosa answered 8/12, 2016 at 7:11 Comment(0)
    C
    5

    Also as Kefas I am specify java version to 1.7 and it works!

     <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
             <source>1.7</source> 
             <target>1.7</target> 
        </configuration>
    </plugin>
    
    Cleo answered 31/3, 2015 at 8:9 Comment(0)
    U
    2

    This might sound silly but I just did Project->Clean and then Maven->Update.

    Solved the problem.

    Utopianism answered 28/2, 2017 at 20:8 Comment(0)
    D
    2

    The above suggests is helpful for me! Right click on project -> Properties -> Project Facets, then change the Java facets version to 1.7.

    If it doesn't work, add the following code to pom.xml:

    <build>
        <finalName>finalName</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source> <!-- yours Java version -->
                    <target>1.7</target> <!-- yours Java version -->
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    Save pom.xml.

    And then, right click on project-->Maven-->Update Project.

    Denby answered 8/3, 2017 at 9:37 Comment(0)
    I
    1

    Changed version to 3.1 and the tags and to 1.7

     <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
         <source>1.7</source> 
         <target>1.7</target> 
    </configuration>
    

    Ironwork answered 12/6, 2018 at 1:31 Comment(0)
    G
    0

    I am using java 1.8. Fixed doing the following.

    Remove from pom:

    <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
    

    It will complain that pom is not up to date. Used quick fix to update then you get a whole bunch of errors.

    RE-ADD to pom:

    <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
    

    Updated maven and all errors are cleared.

    Garrett answered 26/9, 2016 at 9:5 Comment(0)
    E
    0

    This works for me:

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.6</version>
                    <configuration>
                        <warSourceDirectory>src/main/webapp</warSourceDirectory>
                        <warName>mfp</warName>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <finalName>myprojectname</finalName>
    </build>
    
    Empurple answered 4/12, 2016 at 6:17 Comment(0)
    C
    0

    I had to reset maven settings in Window->Preferences->Maven-> User Settings to "C:\Development\apache-maven-3.5.3\conf\settings.xml".

    Clavius answered 20/6, 2018 at 16:22 Comment(0)
    F
    0

    The Right Answer is : - Just a Simple thing Most of times you cant change the Dynamic Web Module Version to 3.0 .. it must be default set to 2.3 or 2.4 or else. Its not gonna work right click on project-> preference -> project facet -> uncheck dynamic web module and change the version to 3.0 then check it. and i think you have to change the latest version for ( i.e: 1.7 or higher ) that . after that click apply and close button.

    then update the maven project.. right click on project select maven -> update project. still the error will continue for 80% of us..

    The Real Solution is here 1> go to you work space folder 2> then go to your project folder 3> check for .settings file (sometimes it may be hidden then unhide it..(so rare chance ) 4> Go into that .settings file then check for org.eclipse.wst.common.project.facet.core.xml file and edit with notepad++ or some thing like that..enter code here 5>this is the code inside that

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

    change the jst.web version to 3.0 like this

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

    then finally update the maven .. then restart the eclipse or another IDE

    Filippa answered 25/5, 2019 at 4:52 Comment(0)
    M
    0

    I have added below line of code in pom.xml and it worked.

    <properties>
            <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
    </properties>
    
    Miss answered 7/8, 2019 at 6:12 Comment(1)
    You can see github.com/spring-projects/spring-boot/issues/16846Miss

    © 2022 - 2024 — McMap. All rights reserved.