Home » Java » Cannot change version of project facet Dynamic Web Module to 3.0?

Cannot change version of project facet Dynamic Web Module to 3.0?

Posted by: admin November 2, 2017 Leave a comment

Questions:

I am using maven to create a dynamic webapp in Eclipse. I added some folders like src/test/java and src/test/resources. Also I changed the library in Java Build Path to obtain the JavaSE-1.7. It’s all OK up to here.

When I tried to change the Projects Facet Dynamic Web Module something went wrong. I had change the Java to 1.7 in the same place. And it still told me, cannot change version of project facet Dynamic Web Module to 3.0.

I have changed everything that would effect the changing I think.

Answers:

I updated my web.xml

<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_3_0.xsd"
    version="3.0">
    <display-name>Servlet 3.0 Web Application</display-name>
</web-app>

and then just Maven -> Update Project …

Questions:
Answers:

Another way is to edit the project facet configuration file itself: org.eclipse.wst.common.project.facet.core.xml

Change the dynamic web module version in this line to 3.0 – <installed facet="jst.web" version="2.5"/>

And then:

  1. Right-click on the project (in the Project Explorer panel).
  2. Select Maven » Update Project (or press Alt+F5)

You’ll find this file in the .settings directory within the Eclipse project.

Questions:
Answers:

I think I had the same problem as you. my web.xml had version 2.5 while the project had the (right-click on Project-> Properties-> Progect Facets->) Dynamic Web Module 2.3.
Although I tried to change the version from 2.3 to 2.5 ECLIPSE did not permit it.
Solution: I removed the check mark under the heading Dynamic Web Module, I saved and I had Update Project. Automatically re-awakening is entering the box with the correct version. I use Eclipse Kepler.

Hope that useful.

p.s.

look at the comments of Jonathan just below, very useful.

Questions:
Answers:

I had the same issue and I even tried to remove the project and add it again. What did the trick was to remove the .settings directory.

Questions:
Answers:

Delete

.settings 
.classpatch 
.projejct 
target

and import again the maven project.

Questions:
Answers:

Right click the projectProperties; in Project Facets, deselect Dynamic Web Module (version should be 3.1) and deselect JavaServer Faces (version is 2.2).

Change this:

<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">

to this:

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

Then remove the prefix before param-name and the like.

Finally, Maven -> Update project.

Questions:
Answers:

What worked for me:

  1. Change the Java to 1.8 (or 1.7)

In your POM – you have to set compiler plugin to version 1.8 (or 1.7) in <build> section:

  <build>
    ...
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.6.0</version>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
          </configuration>
        </plugin>  
      </plugins>    
  </build>

Ensure that change Java Build shows 1.8. If it does not – click EDIT and select what it should be.

enter image description here

  1. Modify web.xml so 3.0 is referenced in version and in the link

enter image description here

  1. Ensure you have Java set to 1.8 in Project Facets

enter image description here

  1. At this stage I still could not change Dynamic Web Module;

Instead of changing it:

a) uncheck the Dynamic Web Module

b) apply

c) check it again. New version 3.0 should be set.**

enter image description here

After applying and checking it again:

enter image description here

Hope this helps.

Questions:
Answers:
  1. Click on your project folder.
  2. Go to Window > Show View > Navigator
  3. Go to Navigator and expand the .settings folder
  4. Open org.eclipse.wst.common.project.facet.core.xml file

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

  5. Change the version like this <installed facet="jst.web" version="3.1"/>

  6. Save
  7. Just update your project. Right Click on The Project Folder > Maven > Update Project > Select the Project and click ‘Ok’

Just this worked to me.

Questions:
Answers:

you please open the Navigator view and following step

  1. (Window > Show View > Other > General) and find that there is a .settings folder under your project, expand it and then open the file “org.eclipse.wst.common.project.facet.core.xml”, make the below changes and save the file.
  2. Change the dynamic web module version in this line to 2.5 –
  3. Change the Java version in this line to 1.5 or higher – .
Questions:
Answers:

Open web.xml from project structure
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd”
version=”3.0″>
Servlet 3.0 Web Application

and update web.xml file
for example change version = “2.5”

Also change the org.eclipse.wst.common.project.facet.core.xml file from your project .settings file
Follow the steps
1. Window > Show View > Other > General > Navigator

  1. There is a .settings folder under your project directory

  2. Change the dynamic web module version in this line to 2.5
    4.Change the Java version in this line to 1.5 or higher

Now refresh your project and get set to run on your server.

Do follow the blog for the solution
http://scrapillars.blogspot.in/2014/02/how-to-change-project-facet-in-eclipse.html

The solution is produced with image illustrations

Questions:
Answers:

Best and simple steps solved this problem for me is
1) Properties -> Project Facets -> Deselect/unmark the check box of Dynamic Web Module -> Apply
2)Now change to the desired version Apply
3)Check the Dynamic web Module check box..
–Now your are done

Questions:
Answers:

Their is one more way to resolve this problem (check it out hope it will help you to solve your problem)

PROBLEM

Cannot change version of project facet dynamic web module 2.3 to 3.0

SOLUTION

  1. Go to your project location (ex.-D:/maven/todo)
  2. go to .setting folder
  3. check for this file: org.eclipse.wst.common.project.facet.core.xml
  4. open the file and change “jst.web” property from 2.3 to 3.0, and save
  5. Right click on project refresh the project and update maven
  6. Done!!!….
Questions:
Answers:

In my case the web.xml was referenced by a dtd. After I changed this to xsd reference like the one posted by Sydney it worked.

Questions:
Answers:

The web.xml trick works because you’re now explicitly telling WTP that you are using that specific servlet version, regardless of what the container supports.

In my case, I am using the annotation config within a Maven project and I do not have a web.xml file. It turns out that in the absence of a web.xml, WTP looks at your Maven dependencies to determine what Servlet version to use. In my case, I had defined the following:

<dependency>
  <groupId>javax</groupId>
  <artifactId>javaee-api</artifactId>
  <version>7.0</version>
  <scope>provided</scope>
</dependency>

Changing it to 6.0 fixed the problem and it’s now using Servlet 3.0 instead of 3.1, which is the default for JavaEE 7. Since I had to go from Tomcat 8 to Tomcat 7, Tomcat 7 only supports the JavaEE 6 Web profile. Now things work wonderfully.

Questions:
Answers:

I had the same issue ,deleting the .settings folder resolved the issue

Questions:
Answers:

My solution to the problem that didn’t allowed me to change the version of project facet Dynamic Web Module in Eclipse (Mars) was:

  • Disable Maven Nature
  • Ensure that the web.xml namespaces point to right version
  • Re-enable Maven Nature
  • Maven » Update Project (or press Alt+F5)
Questions:
Answers:

I tried many of the answers here, but none of them worked for me.
Then I found an article about my problem here. I thought of sharing it here too.

Below are the steps taken in brief.

  1. Set Compiler compliance level.
  2. Update project facet
  3. Update installed JRE from preferences
  4. Adding configuration in pom.xml to use java 1.7 and finally
  5. updating project from Maven.
Questions:
Answers:

For a maven eclipse web project, changing dynamic web module version needs to check three places. If one uses eclipse, and after you have checked the following:
1) web.xml

<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_3_0.xsd"
    version="3.0">

2) maven:

<dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.0.1</version>
      <scope>provided</scope>   ## ensure you have tomcat 7 not other version
</dependency>

<plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.0</version>
      <configuration>
            <source>1.7</source> ## at least 6
            <target>1.7</target>
      </configuration>
</plugin>

3) eclipse build path and compiler version is 1.7

you still have an error marker at maven:

cannot change version of project facet dynamic web module to 3.0 one or more constrants have not been satisfied

Then you can:
uncheck the dynamic web module, and recheck it.
I think it is because .settings of eclipse file is corrupted somehow. About the second tip tomcat which version is a good note.

Questions:
Answers:

Doing maven update or reimporting the project did not help. @Sydney’s answer is right; in addition I have to recreate the project in different workspace as said in JavaServer Faces 2.2 requires Dynamic Web Module 2.5 or newer

Questions:
Answers:

I had the same issue, editing web.xml as well as changing file in .settings folder alone didn’t help. My solution was to directly point maven compiler plugin to use the desired java version by editing pom.xml:

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

Now run Maven->Update project and after that you can change servlets version in properties->project facets->Dynamic Web module version or, as written earlier, by manually editing org.eclipse.wst.common.project.facet.core.xml in .settings folder of your project.

Questions:
Answers:

Open the org.eclipse.wst.common.project.facet.core.xml file and change the jst.web version to 3.0. Also update the web.xml to version 3.0. Save and update the project. Hope this helps. I am using Eclipse Juno

Questions:
Answers:

This is a variation on pagurix’s answer, but using Eclipse Mars.

Change your web.xml file to web.bak

Ignore the errors, we’ll regenerate it next.

Go into project properties -> project facets and set the Dynamic Web Module version to what you need. Eclipse now allows you to save.

Now right-click on the project. Choose Java EE Tools -> Generate Deployment Descriptor Stub.

This creates a new web.xml with the required version.

Open the new web.xml and copy across the XML header and the complete web-app opening tag to your original web.bak, delete the new web.xml and rename web.bak back to web.xml.

Done.

Questions:
Answers:

Mine was Web Module 3.0 in web.xml, but in properties>Dynamic Web Module It was on 3.1

I changed the web.xml to this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">

after this change, do: right click on project>Maven>Update Project...

Questions:
Answers:

If answer by Sydney still doesn’t help then try below.
After following Sydney’s answer, goto Properties > Projects Facets deselect Dynamic Web Module and then change the version to match your web.config and then select again. Apply > Save
Then Maven Update.

web.xml

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:web="http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="Web_App_1" version="3.1">

<display-name>JavaServerFaces</display-name>

<!-- Change to "Production" when you are ready to deploy -->
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>

<!-- Welcome page -->
<welcome-file-list>
    <welcome-file>jsfs/hello.xhtml</welcome-file>
</welcome-file-list>

<!-- JSF mapping -->
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<!-- Map these files with JSF -->
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>jsfs/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

Questions:
Answers:

This Problem With version right click on the project->properties->Project Facets->right click on Dynamic Web Module->unlock it-> uncheck->select 2.5 version->Apply->Update the maven

Questions:
Answers:

I resolved the issue by modifying web.xml with correct version,xsd locations and modifying org.eclipse.wst.common.project.facet.core.xml with correct version and doing maven update.

Questions:
Answers:

updating maven worked for me

select project then press ALT+F5 then select project click ok

Leave a Reply

Your email address will not be published. Required fields are marked *