|By Ken Fogel||
|January 3, 2014 02:15 PM EST||
Create a project based on my blog “UPDATED Setting up a JEE 6 Web Profile Maven Project in Eclipse using TomEE”.
Eclipse reveals its special capabilities such as specialized editors based on the project’s facet. As it now stands the project you just created will allow you to create Servlet/JSP applications. You need to add the JavaServer Faces facet to the project.
Right-mouse click on the project and select Properties and then select Project Facets. You will see:
You now need to add the JavaServer Faces facet version 2.1, change the Java version to 1.7 and uncheck JAX-RS. It should now look like:
The version of TomEE, 1.6.0, that I am using does not yet have JSF 2.2 in its library. Its current version is 2.1. If you need to use 2.2 then there is a beta version of the library available as of this writing.
Do not click on OK yet.
Notice the link just above the buttons that reads “Further configuration required…”. Click on it and you will see:
Pull down the combo box at the top labeled “Type:” and select Disable Library Configuration to replace User Library. This is necessary because the JSF libraries are already in the lib folder of TomEE and Maven knows what libraries are required.
It should now look like:
While it is possible to create a JSF application without the JSF servlet deployment descriptor the Eclipse tools use it in some instances. The checkbox must be checked and the values that show in the textboxes can be left as they appear.
Click OK and then OK again.
Save all your files. Right mouse click on the project and select Maven -> Update Project. When this is complete you will have errors such as:
The solution was found by entering the first of the Maven Java EE Configuration Problems into Google. “Type Cannot change version of project facet Dynamic Web Module to 2.5.” led me to a Stack Overflow question that pointed out that the <web-app> attributes in the web.xml file needed to be changed. The generated web.xml read:
<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <display-name>JSFExample01</display-name> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>/faces/*</url-pattern> </servlet-mapping> </web-app>
The <web-app> needed to read:
<web-app xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns="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" version="3.0">
Simply put, you need to replace the 2_5 with 3_0 and the 2.5 with 3_0.
Save files and do another Maven->Update Project and the errors all disappear.
The errors are gone but a mysterious entry in Markers appears:
Searching for this revealed two solutions. One was to go into Windows -> Preferences -> Java -> Debug and un-select “Suspend execution on uncaught exceptions”. I did this and it made no difference.
The second solution was to right mouse click on the two Unknown descriptions, right mouse click and delete. You are warned that they may come back but in my case after a Maven -> Update Project and a Run -> Maven Build the markers did not return.
You are now ready to create a JavaServer Faces application. Projects created this way will open and execute successfully in NetBeans when the project is saved to a Subversion repository.
May. 29, 2016 01:00 PM EDT Reads: 1,971
May. 29, 2016 12:45 PM EDT Reads: 1,665
May. 29, 2016 10:30 AM EDT Reads: 1,291
May. 29, 2016 10:30 AM EDT Reads: 1,264
May. 29, 2016 10:00 AM EDT Reads: 2,499
May. 29, 2016 09:45 AM EDT Reads: 2,023
May. 29, 2016 09:30 AM EDT Reads: 2,304
May. 29, 2016 08:15 AM EDT Reads: 2,739
May. 29, 2016 07:00 AM EDT Reads: 2,298
May. 29, 2016 06:45 AM EDT Reads: 2,949
May. 29, 2016 06:00 AM EDT Reads: 2,169
May. 29, 2016 06:00 AM EDT Reads: 1,347
May. 29, 2016 05:15 AM EDT Reads: 3,274
May. 29, 2016 04:30 AM EDT Reads: 3,254
May. 29, 2016 03:30 AM EDT Reads: 991
May. 29, 2016 02:45 AM EDT Reads: 1,499
May. 29, 2016 02:00 AM EDT Reads: 1,340
May. 29, 2016 01:30 AM EDT Reads: 2,488
May. 29, 2016 01:00 AM EDT Reads: 1,429
May. 29, 2016 12:45 AM EDT Reads: 2,058