0

I'm pretty new in Java World so I might not be that accurate in my question. I'm trying to create a simple maven project that supports jsf in Intellij.

The process I have followed is the following:

  1. Create New Project
  2. Maven with archetype maven-archetype-quickstart(maven 3), choosing GroupId and ArtifactId
  3. After the project has been created right click on the project->Add Framework Support
  4. I choose Java EE (Java EE 8)->Web Application (versions 4.0) ->JSF (1.2)->Icefaces,Openfaces,Primefaces,Richfaces
  5. Then Add Configuration->Create New Local Jboss Server (7.5.0.Final-redhat-21) and in Deployment add new artifact->myproject:war exploded

After all these I have the following structure:

General Structure

In index.xhtml I have:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
   <f:view>
      <h:outputLabel value="Hello, world"/>
   </f:view>
</html>

and in pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>mygroupid</groupId>
  <artifactId>artifactid</artifactId>
  <version>1.0-SNAPSHOT</version>

  <name>artifactid</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.0.0</version>
        </plugin>
        <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.7.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.20.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

and in web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_4_0.xsd"
         version="4.0">
    <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>*.xhtml</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
    </welcome-file-list>
</web-app>

When I run it what I would expect is an html page that has in body "Hello World" but what I get is the xhtml without the JSF having been rendered.

any help would be appreciated

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Symeon Mattes
  • 1,169
  • 16
  • 40
  • Most likely not related but tried adding an `` in the page? And tried without a faces-config and no faces servlet and corresponding mapping defined in the web.xml. – Kukeltje Sep 24 '18 at 11:33
  • And JBoss 6.4 is afaik, Java EE 6 and not 8 (https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/6.4/html/6.4.0_release_notes/index) and JSF-1.2? – Kukeltje Sep 24 '18 at 11:36
  • etc....doesn't solve anything. The jsf object do not translated into valid html code – Symeon Mattes Sep 24 '18 at 12:10
  • That's why I said 'most likely not related'... What about the other things in my comments – Kukeltje Sep 24 '18 at 12:12
  • I made a mistake. JBoss is 7.5.0 Final-redhat-21. Not sure if it's related. – Symeon Mattes Sep 24 '18 at 12:17
  • JBoss EAP 6.4 is the equivalent of JBoss AS version 7.5.0 Final, so still Java EE 6 and not 8 so your web.xml versions etc are all to new and your jsf namespaces for the wrong versions of JSF and hence not detected as JSF components but plain 'xml', leading to the page not being processed – Kukeltje Sep 24 '18 at 12:37
  • The namespace seemed to be incorrect...not sure though what it means. Thanks anyway – Symeon Mattes Sep 24 '18 at 12:42

1 Answers1

0

Just in case somebody else has the same issue. What solved is changing the namespace in html tag, i.e.xmlns:h="http://xmlns.jcp.org/jsf/html" to xmlns:h="http://java.sun.com/jsf/html" and xmlns:ui="http://xmlns.jcp.org/jsf/facelets" to xmlns:ui="http://java.sun.com/jsf/facelets"

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
   <f:view>
      <h:outputLabel value="Hello, world"/>
   </f:view>
</html>
Symeon Mattes
  • 1,169
  • 16
  • 40
  • Great **we** solved it. Two comments though. It is good practice that if others help you solve your problem, you allow (or even 'ask') them to write up an answer (or mark it as a duplicate of one, as yours is). And you still have a wrong namespace here, the one for core. And the web.xml one is most likely wrong too. – Kukeltje Sep 24 '18 at 13:10
  • ok...Thanks Kukeltje for your help – Symeon Mattes Sep 24 '18 at 13:12