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

31

352

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.

Dacoity answered 8/8, 2013 at 9:22 Comment(5)
OK. I am sorry about that. The archetype is maven-archetype-webapp when I create the New Maven Project, and the Dynamic Web Module is 2.3 in the Project Facets after I created the project. I want to change the version of the Dynamic Web Module to 3.0, and I got 'Cannot change version of project facet Dynamic Web Module to 3.0'Dacoity
this worked for me: https://mcmap.net/q/94026/-dynamic-web-module-3-0-3-1Affect
In Eclipse Kepler, when I right-click on the 'Dynamic Web Module' facet, it displays an 'Unlock' option. After un-locking, I was able to change the facet version. for info only.Shovelboard
Is this a bug for eclipse ?Fernery
Possible duplicate of Cannot change version of project facet Dynamic Web Module to 2.5Estancia
S
323

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 ...

Sikes answered 21/8, 2013 at 15:34 Comment(8)
Update of the web.xml didn't work for me. The solution given by @Fluoro works: https://mcmap.net/q/92851/-cannot-change-version-of-project-facet-dynamic-web-module-to-3-0Celle
Here is a valid header for an 3.1 web.xml file <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="w3.org/2001/XMLSchema-instance" xmlns="xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="xmlns.jcp.org/xml/ns/javaee xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">Eyebrow
what about projects without web.xml ? :)Seton
the change of version attribute to 3.0 did not work for me eitherEggshaped
If none of the above and below solutions if not work kindly go through this link 100% it will work.Farflung
I hate Maven. this did not work for me either. Every time I touch Maven I get into trouble. I tried another solution, then it started complaining about facets. Why do they have to shove more and more stuff on Java developers (modules, facets etc). There's like layer upon layer upon layer of configs and "help tools" that end up getting in the way. I just wanna code.Examinant
Don't forget to remove .settings .classpatch .project and target before importing the maven project again (and then Maven -> update)Sob
\webapp\WEB-INF add new file web.xml works. for any version of web.xml, #11658604Occupational
F
614

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.

Fluoro answered 5/9, 2013 at 9:1 Comment(16)
Thank you. Actually I think we should do something else just like the above, change the version of the web module in the web.xml, if not, the 'Deployment Descriptor' version will not change to 3.0. And is that a bug in maven plugin?Dacoity
This appears to be the only way to resolve this issue when you are going without a web.xml in your project.Tingley
I already had 3.0 in the web.xml and STS still failed to update and mvn update didn't help either. This method works, however.Ozonide
Did something change in between? Seems like this should be the accepted answer.Syncom
This helped , actually go to -> org.eclipse.wst.common.project.facet.core.xml -> remove all entries -> maven update project.Forfend
what is the purpose of the xml file, and what does that jst.web mean?Rafter
The xml file defines a Eclipse Faceted project, see: help.eclipse.org/mars/… The jst.web is a reference to j2ee Standard Tools Project. eclipse.org/webtools/jst/main.phpFluoro
You can find org.eclipse.wst.common.project.facet.core.xml file in your application/project .settings folder.Toxoid
I created my project as a maven project in eclipse. But I don't have a .settings folder under my project. Anyone knows why?Ackack
This is the right answer, please if you have the same problem refer to the following link, it helped me fixing it. There you can find an step by step explanation on how to solve this issue. crunchify.com/…Chemistry
this works for me. thanks. but could u please give me a little more details of this error, and what is the meaning of these xml configurations?Billionaire
This way each and everyone working on the same code need to do the changes in their local. I prefer the version update in web.xml as it is a one time change and can be used by all other developers in the team.Pester
It worked for me. I am using STS 4, Java 8, servlet-api 2.5Measure
Somehow this solution works! Changing the version every where else doesn't work. + 1Outpoint
Guys I do change it to 3.0 but when I do maven update project it is put back to 4.0 why?Brokaw
Maven » Update Project will again set back version to 2.5.Stogner
S
323

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 ...

Sikes answered 21/8, 2013 at 15:34 Comment(8)
Update of the web.xml didn't work for me. The solution given by @Fluoro works: https://mcmap.net/q/92851/-cannot-change-version-of-project-facet-dynamic-web-module-to-3-0Celle
Here is a valid header for an 3.1 web.xml file <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="w3.org/2001/XMLSchema-instance" xmlns="xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="xmlns.jcp.org/xml/ns/javaee xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">Eyebrow
what about projects without web.xml ? :)Seton
the change of version attribute to 3.0 did not work for me eitherEggshaped
If none of the above and below solutions if not work kindly go through this link 100% it will work.Farflung
I hate Maven. this did not work for me either. Every time I touch Maven I get into trouble. I tried another solution, then it started complaining about facets. Why do they have to shove more and more stuff on Java developers (modules, facets etc). There's like layer upon layer upon layer of configs and "help tools" that end up getting in the way. I just wanna code.Examinant
Don't forget to remove .settings .classpatch .project and target before importing the maven project again (and then Maven -> update)Sob
\webapp\WEB-INF add new file web.xml works. for any version of web.xml, #11658604Occupational
Z
183

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-> Project 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.

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

Zootomy answered 4/2, 2014 at 8:57 Comment(6)
Great!it resolved my problem but can you tell me why it was not permitting initially to set the dynamic module.Pester
@Suresh, I think the problem why it was not permitting to change the version is because it's locked. If you right-click on the 'Dynamic Web Module' facet, it will display the 'Unlock' option. After un-locking, un-checking the DWM facet, re-applying the facet, and do project maven update, the error went away.Shovelboard
+1. Without this extremely important point others answers here are for nothing. Only I think Jonathan't comment should be included into the answer.Crusted
+1 @Shovelboard Your tip did the work. You must publish this as an answer and we should also raise this to Eclipse!Neomaneomah
In my case this works why in the web module pom there was setted another version for Dnamic web module, so this conflicts whit project configurationPierrette
Also, our project had Java Server Faces facet included which was not necessary and unchecking it helped add flexibility to the version dependency for the Dynamic Web Module. Unlocking per @Shovelboard (above) was also required.Unrestrained
M
54
  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.

Manville answered 21/1, 2017 at 11:32 Comment(0)
B
45

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.

Briar answered 22/11, 2013 at 13:47 Comment(5)
I also had to do this. I was using a Spring web project with a Java-based configuration, so updating a web.xml wasn't possible for me.Threepiece
Why it worked after deleting the .setting can you please exaplainAutobus
That .settings directory contains a lot of stuff and maybe some of them changed over time. I don't know exactly what part influenced this behavior, but this was like a reset. None of the other answers worked for me, but this one. And it seems I wasn't the only one in this situation.Briar
Worked for me, I had this error: "Cannot change version of project facet EAR to 1.3."Headwards
Worked for me! I had the error: "Cannot change version of project facet Dynamic Web Module to 3.0"Deceit
S
27

Delete

.settings 
.classpatch 
.projejct 
target

and import again the maven project.

Spavined answered 3/9, 2014 at 7:23 Comment(1)
How do I import again the Maven Project. I'm new to this.Derk
C
24

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.

Clarey answered 23/12, 2016 at 7:41 Comment(0)
W
16

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.

Winch answered 2/5, 2015 at 1:57 Comment(0)
A
8

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 - .
Anyway answered 28/11, 2013 at 9:30 Comment(1)
You forgot to tell what view you should select under the "General" folder in the "Show View" dialog. Is it the "Navigator" view?Nari
F
6

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

Fionafionna answered 24/2, 2014 at 6:29 Comment(2)
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.Aculeate
I've made changes in pom.xml file as shown in crunchify.com/…. However that was not enough. I also had to follow the recommendation to open the .settings folder and edit file or.eclipse.wst.common.project.facet.core.xml file.Techno
V
6

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--

Variegation answered 31/3, 2016 at 5:34 Comment(1)
Worked well but What is the consequence of this?Arica
B
4

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!!!....
Barney answered 29/11, 2016 at 9:19 Comment(0)
A
3

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.

Askari answered 14/2, 2014 at 13:28 Comment(0)
S
3

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.

Stinson answered 22/1, 2015 at 12:54 Comment(0)
Q
2

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.

Quinsy answered 22/11, 2013 at 10:41 Comment(0)
B
2

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

Beggary answered 28/7, 2016 at 15:24 Comment(0)
O
2

I got this error when I try to convert a general Java Project to Maven Project.

What I did was to determine the Java compiler version which is required by my project. For my project, the minimum Java version is 1.8.

By lowering the version to anything lower than 1.8 my IDE will start complaining that it does not recognize a bunch of imported libraries, hence I determine mine minimum Java version as 1.8

1. Right click your project
2. Go to Properties
3. Left hand-side panel, click "Project Facets"
4. For Java, set the version according to your minimum version

enter image description here

Now make sure the Java compiler version uses the same Java version as what you have set in Project Facets.

1. Right click your project
2. Go to Porperties
3. Left hand-side panel, click "Java Compiler"
4. Make sure Java Compiler version is the same. 
5. If it is not the same, change the version. (Uncheck "Use compliance from execution environment' if needed to make the changes.

enter image description here

After the changes, the error should be resolved. If the error is still there, right-click project -> Maven -> Update Project

Outpoint answered 25/7, 2019 at 12:17 Comment(0)
L
1

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)
Lipsey answered 13/1, 2016 at 16:21 Comment(0)
F
1

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>

Frizzy answered 22/2, 2016 at 12:44 Comment(0)
G
1

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.
Garwin answered 29/2, 2016 at 13:29 Comment(0)
F
1

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.

Forefather answered 26/10, 2016 at 1:56 Comment(0)
W
1

Just want to share my own experience, I find that my Dynamic Web Module is locked, it is solved with the following steps:

First

  • Right click project > Properties > Project Facets > Right click Dynamic Web Module > Unlock > Apply and close

Second

  • Right click project > Maven > Update Project > OK
Wallen answered 21/8, 2020 at 8:48 Comment(0)
E
0

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

Excoriate answered 12/3, 2014 at 22:7 Comment(0)
T
0

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

Toughen answered 18/5, 2015 at 12:53 Comment(0)
B
0

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.

Byerly answered 26/1, 2016 at 10:45 Comment(0)
C
0

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

Cashmere answered 15/2, 2016 at 6:21 Comment(0)
D
0

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...

Dada answered 21/2, 2016 at 17:38 Comment(0)
S
0

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.

Seine answered 24/6, 2017 at 9:56 Comment(0)
C
0

updating maven worked for me

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

Catmint answered 5/8, 2017 at 9:47 Comment(0)
N
0

I had the same symptom with a different cure. I was trying to upgrade my JSF 2.2.4/Spring 3.0 webapp to JSF 2.3 in order to enjoy the new JSF websocket hooks there and Eclipse (actually STS) would not cooperate. In Eclipse's Project Facets, JSF 2.3 never became available until I edited directly the org.eclipse.wst.common.project.facet.core.xml file as directed in previous answers - the highest it would go was 2.2.

Here are the hoops I jumped through. I don't know that all of these were necessary because I fundamentally don't understand all this configuration.

In Eclipse I frequently got a scary warning, "Modifying a faceted project when implementations of one or more installed facets are not available can potentially result in a corrupted project. Are you sure you want to proceed?" This prompted me to do more frequent commits but no corruption occurred.

  1. Upgrade JDK from 1.7 to 1.8 in POM, Eclipse compiler, and Eclipse Project Facets.
  2. Update the following Maven dependencies:

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

    ... to:

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

... and ...

    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.4</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.2.4</version>
    </dependency>

... to:

    <dependency>
        <groupId>javax.faces</groupId>
        <artifactId>javax.faces-api</artifactId>
        <version>2.3</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.faces</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>javax.enterprise</groupId>
        <artifactId>cdi-api</artifactId>
        <version>2.0</version>
    </dependency>

I had to update my web.xml namespace declarations from:

<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_2_5.xsd" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">

... to:

<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" 
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">

I had to update Project Facets -> Dynamic Web Module from 2.5 to 3.0. I tried 3.1 but got errors.

In this process I frequently got the error in the title of this post, "Cannot change version of project facet Dynamic Web Module to 3.0" and Eclipse refused to compile the project or offer JSF 2.3 in the Project Facets. When I edited the org.eclipse.wst.common.project.facet.core.xml file as directed the errors disappeared, Eclipse offered JSF 2.3 in Project Facets, and the project compiled and ran fine on Tomcat 9.0.8. However, Project Facets still warned "Implementation of version 2.3 of project facet jst.jsf could not be found. Functionality will be limited." I suspect this simply means that autocomplete and other Eclipse conveniences will not be available because it cannot find the JSF 2.3 implementation declared in my POM.

Hope this helps someone. Google searches yielded only this post by Ali Bassam and indirectly BalusC which helped.

Nightwear answered 10/5, 2018 at 16:16 Comment(0)
C
-1

I had the same problem - I just removed the project from my workspace, then cleaned up the "eclipse files/folders, for example: .project, .settings, etc) then imported the maven project again, it worked.

Congregation answered 8/2, 2019 at 10:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.