Hej,
od jakiegoś czasu walczę z JSF. Przy próbie stworzenia nowego projektu mam jednak problem ze skonfigurowaniem go, aby poprawnie współpracował z jBossem i działał. Mógłby mi ktoś wskazać, gdzie popełniam błąd/błędy?
IDE - Eclipse Mars
serwer - jBoss Wildfly 9.1
File -> New -> Other -> Maven Project
Archetype - maven-archetype-webapp (Group Id - org.apache.maven.archetypes, version 1.0)
Ustawiam group id, artifact id -> finish
Następnie prawym na projekt -> Properties -> Java Build Path
JRE System Library -> ustawiam opcję Workspace default JRE (jdk1.8.0_51).
Properties -> Java Compiler ustawiam na 1.8.
Properties -> Project Facets -> Dynamic Web Module 3.1, JavaServer Faces 2.2
W runtimes ustawiam skonfigurowanego wcześniej Wildfly 9.1
Ponadto do pom.xml dorzucam
<build>
<finalName>webapp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>1.8.0</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Bez tego Maven Update zmienia mi ustawienia projektu na Javę 1.5 - tego nie chcę, bo pojawia się sprzeczność z wersjami Dynamic Web Module i JSF.
Swoją drogą, to dziwne, bo mvn -v wyrzuca:
Maven home: C:\Program Files\apache-maven-3.3.3
Java version: 1.8.0_51, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_51\jre
Czyli jakby było ok...
Do tego prosty plik index.xhtml
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
i web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee">
<display-name>Archetype Created Web Application</display-name>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<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>
<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>
</web-app>
Oznaczam projekt "as deployable", uruchamiam Wildfly.
16:26:35,214 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) WFLYSRV0027: Starting deployment of "webapp" (runtime-name: "webapp")
16:26:35,320 INFO [org.jboss.ws.common.management] (MSC service thread 1-6) JBWS022052: Starting JBoss Web Services - Stack CXF Server 5.0.0.Final
16:26:35,467 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "webapp" (runtime-name : "webapp")
I teraz... Zarówno localhost:8080/webapp/ jak i localhost:8080/webapp/index.jsf jak i localhost:8080/webapp/index.xhtml pokazują 404...
Natomiast wydaje mi się, że samo localhost:8080/webapp/ powinno przekierować mnie na localhost:8080/webapp/index.xhtml i działać - tak jest ustawiony welcome-file.
Pełen 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jsf</groupId>
<artifactId>webapp</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>webapp Maven Webapp</name>
<a href="http://maven.apache.org">http://maven.apache.org</a>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.12</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.12</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<finalName>webapp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>1.8.0</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
No i ogromna prośba - jeśli coś mieszam/robię źle - poprawcie mnie/podeślijcie jakieś inne źródła, bo przejrzałem całe mnóstwo stron jak i innych projektów i dalej tkwię w tym punkcie..
Wzorowałem się na http://qussay.com/2013/09/14/create-jsf-2-2-maven-project-with-primefaces-3-5-using-eclipse/
Tak na prawdę mam tylko 3 znaczące pliki - pom.xml, web.xml i index.xhtml.
EDIT:
ofc jboss działa poprawnie, strona localhost:8080 wyrzuca "Welcome to WildFly 9" i wszystkie pozostałe opcje...