Java EE 7, CDI 1.2, JSF 2.1, Weblogic 12.2.1 - Target Unreachable, identifier 'Controller' resolved to null [duplicate] - maven

This question already has answers here:
Identifying and solving javax.el.PropertyNotFoundException: Target Unreachable
(18 answers)
Closed 4 years ago.
I'm on the verge of going crazy.
My goal was to change JSF-Managed-Beans to CDI-Managed-Beans.
I thought it was just changing Annotations. It wasn't.
I've read a lot - and more. But I just can not find my mistake.
I get this Exception:
javax.faces.FacesException: javax.el.PropertyNotFoundException: //C:/01_java/ws_bsp/bsp/bsp-web/src/main/webapp/jsf/allgemein/login.xhtml #29,86 value="#{logInOutController.username}": Target Unreachable, identifier 'logInOutController' resolved to null
at com.sun.faces.context.PartialViewContextImpl.processPartial(PartialViewContextImpl.java:273)
at org.primefaces.context.PrimePartialViewContext.processPartial(PrimePartialViewContext.java:57)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1193)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
Truncated. see log file for complete stacktrace
Caused By: javax.el.PropertyNotFoundException: //C:/01_java/ws_bsp/bsp/bsp-web/src/main/webapp/jsf/allgemein/login.xhtml #29,86 value="#{logInOutController.username}": Target Unreachable, identifier 'logInOutController' resolved to null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at org.primefaces.util.ComponentUtils.getConverter(ComponentUtils.java:152)
at org.primefaces.renderkit.InputRenderer.getConvertedValue(InputRenderer.java:199)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1045)
at javax.faces.component.UIInput.validate(UIInput.java:975)
Truncated. see log file for complete stacktrace
Caused By: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'logInOutController' resolved to null
at com.sun.el.parser.AstValue.getTarget(AstValue.java:173)
at com.sun.el.parser.AstValue.getType(AstValue.java:85)
at com.sun.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:201)
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
at org.primefaces.util.ComponentUtils.getConverter(ComponentUtils.java:152)
Truncated. see log file for complete stacktrace
Environment:
WLS 12.2.1.3.0
Java EE 7
ejb-project & web-project -> ear-project -> parent project
parent project 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>xxx.yyy</groupId>
<artifactId>bsp</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>bsp</name>
<properties>
<application.name>bsp</application.name>
<application.ear.name>bsp-ear</application.ear.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<modules>
<module>bsp-ear</module>
<module>bsp-web</module>
<module>bsp-ejb</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.3.7.Final</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.12</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.2</version>
</dependency>
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId>
<version>6.2.10</version>
</dependency>
<dependency>
<groupId>com.oracle.weblogic</groupId>
<artifactId>wls-api</artifactId>
<version>12.2.1-0-0</version>
</dependency>
</dependencies>
ear project 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>
<parent>
<artifactId>bsp</artifactId>
<groupId>xxx.yyy</groupId>
<version>1.0</version>
</parent>
<artifactId>bsp-ear</artifactId>
<packaging>ear</packaging>
<name>bsp-ear</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.8</version>
<configuration>
<version>6</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<modules>
<webModule>
<groupId>xxx.yyy</groupId>
<artifactId>bsp-web</artifactId>
<contextRoot>/bsp</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>xxx.yyy</groupId>
<artifactId>bsp-ejb</artifactId>
<version>1.0</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>xxx.yyy</groupId>
<artifactId>bsp-web</artifactId>
<version>1.0</version>
<type>war</type>
</dependency>
</dependencies>
ejb project 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>
<parent>
<artifactId>bsp</artifactId>
<groupId>xxx.yyy</groupId>
<version>1.0</version>
</parent>
<artifactId>bsp-ejb</artifactId>
<packaging>ejb</packaging>
<name>bsp-ejb</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.3</version>
<configuration>
<ejbVersion>3.1</ejbVersion>
</configuration>
</plugin>
</plugins>
</build>
web project 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>
<parent>
<artifactId>bsp</artifactId>
<groupId>xxx.yyy</groupId>
<version>1.0</version>
</parent>
<artifactId>bsp-web</artifactId>
<packaging>war</packaging>
<name>bsp-web</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>xxx.yyy</groupId>
<artifactId>bsp-ejb</artifactId>
<version>1.0</version>
<type>ejb</type>
<scope>provided</scope>
</dependency>
</dependencies>
xhtml:
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<f:view contentType="text/html">
<h:head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="author"
content="ABC" />
<meta http-equiv="Cache-Control"
content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="expires" content="0" />
<title><ui:insert name="title">#{app['name']}</ui:insert></title>
<link type="text/css" rel="stylesheet"
href="#{facesContext.externalContext.requestContextPath}/layout/css/custom.css" />
</h:head>
<h:body>
<p:growl id="messages" sticky="true" showSummary="true" showDetail="true"/>
<h:panelGrid id="headerTopPanel" styleClass="zColumnTopAlign">
<h:panelGrid id="headlinePanel" columns="3"
columnClasses="zHeaderLinks, zHeaderMitte, zHeaderRechts">
<logo>bsp</logo>
<h:panelGrid id="topMenuPanel">
<ui:insert name="topMenu" />
</h:panelGrid>
<h:panelGrid id="iconMenuPanel">
<ui:insert name="iconMenu" />
</h:panelGrid>
</h:panelGrid>
</h:panelGrid>
<h:panelGrid id="headerBottomPanel">
<h:panelGrid id="breadcrumbPanel" columns="2"
columnClasses="zLeft, zRight">
<h:panelGrid>
<ui:insert name="breadcrumb" />
</h:panelGrid>
<h:panelGrid>
<p:ajaxStatus styleClass="zAjaxStatus">
<f:facet name="start">
<p:commandLink styleClass="iconLoading" />
</f:facet>
<f:facet name="complete">
<h:outputText value="" />
</f:facet>
</p:ajaxStatus>
</h:panelGrid>
</h:panelGrid>
</h:panelGrid>
<p:separator id="menuSeparator" />
<h:panelGrid id="middlePanel" styleClass="zColumnTopAlign">
<!-- <h:panelGrid id="messagesPanel">
<p:messages id="messages" showIcon="false"/>
</h:panelGrid> -->
<h:panelGrid id="sideMenuContentPanel" columns="2"
columnClasses="z12percentBreit zLeft, z88percentBreit zLeft zOverflowAuto">
<h:panelGrid id="sideMenuPanel">
<ui:insert name="sideMenu" />
</h:panelGrid>
<h:panelGrid id="contentPanel">
<ui:insert name="content" />
</h:panelGrid>
</h:panelGrid>
</h:panelGrid>
</h:body>
</f:view>
</html>
Controller:
package xxx.yyy.controller;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import xxx.yyy.util.MessageHelper;
import xxx.yyy.util.PropertiesUtil;
#Named
#RequestScoped
public class LogInOutController {
#Inject
private PropertiesUtil propertiesUtil;
private String username;
private String password;
private String test = "test";
public String login() {
if (username.equals("bsp") && password.equals("bsp")) {
MessageHelper.showInfoMessage(propertiesUtil.getAppProperty("halloTest"), this);
}
return null;
}
public String logout() {
return null;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getTest() {
return test;
}
public void setTest(String test) {
this.test = test;
}
}
If that is not enough or more is needed, please let me know.
I would be overjoyed if someone could help me.
Thanks in advance

I finally found the reason it didn't work.
I had to change the publishing mode of the WebLogic Server:
Right Click on Server -> Properties -> WebLogic -> Publishing -> Publish as an exploded archive

Related

I can't see any result with using thymeleaf

I get error like this when I used thymeleaf as view engine.
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Sat Feb 13 15:57:19 EET 2021
There was an unexpected error (type=Not Found, status=404).
No message available
My MainCotroller is like :
public class MainController {
#RequestMapping("/")
public ModelAndView homePage(){
ModelAndView homepage=new ModelAndView("homepage");
homepage.addObject("username","Ayberk");
return homepage;
}
}
My homepage.html file is like this:
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<!--/*#thymesVar id="username" type="String"*/-->
<p th:text="${username}"></p>
<br />
<p>GoodBye</p>
</body>
</html>
My pom.xml file is like this:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>newproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>newproject</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<filtering>false</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
</project>
My idea is Intellij 2020 and I have read this problem is related with intellij version. But i have not seen any solution. Is there any solution for it? What can i do?
EDIT AFTER RUDI'S ANSWER BUT STILL SAME ERROR.
#RequestMapping("/")
public String homePage(Model model){
model.addAttribute("username" , "ayberk");
return "src\\main\\resources\\templates\\homepage";
//return "homepage"; also tried like this.
}
My ModelAndView packages is org.springframework.web.servlet.ModelAndView

Spring Boot with Primefaces issues

Spring Boot 2.4.1
Primefaces 8
I have 2 issues:
The h:outputStylesheet does not render the link tag so I am not getting any styles in the browser.
The primefaces menubar is rendering a plain old ul list.
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.gca</groupId>
<artifactId>GCA-WEB</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>GCA-WEB</name>
<description>Website for Gleneagle Civic Association (HOA)</description>
<properties>
<java.version>11</java.version>
<primefaces.version>8.0</primefaces.version>
<jsf.ver>2.2.20</jsf.ver>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primefaces.version}</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${jsf.ver}</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${jsf.ver}</version>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
JSF Configuration:
package org.gca.config;
import com.sun.faces.config.ConfigureListener;
import java.util.Arrays;
import javax.faces.webapp.FacesServlet;
import javax.servlet.ServletContext;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
#Configuration
public class JsfConfig {
#Bean
ServletRegistrationBean jsfServletRegistration(ServletContext servletContext) {
//spring boot only works if this is set
servletContext.setInitParameter("com.sun.faces.forceLoadConfiguration", Boolean.TRUE.toString());
//registration
ServletRegistrationBean srb = new ServletRegistrationBean();
srb.setServlet(new FacesServlet());
srb.setUrlMappings(Arrays.asList("*.xhtml"));
srb.setLoadOnStartup(1);
return srb;
}
#Bean
public ServletListenerRegistrationBean<ConfigureListener> jsfConfigureListener() {
return new ServletListenerRegistrationBean<>(
new ConfigureListener());
}
#Bean
public ViewResolver getViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setSuffix(".xhtml");
return resolver;
}
}
I created the webapps/WEB-INF resources directories manually
<?xml version="1.0" encoding="UTF-8"?>
<faces-config 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/web-facesconfig_2_2.xsd"
version="2.2">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>
Template:
<?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">
<h.head>
<h:outputStylesheet library="css" name="gca.css"/>
<title>
<ui:insert name="title">GCA</ui:insert>
</title>
<ui:insert name="style"></ui:insert>
<ui:insert name="script"> </ui:insert>
</h.head>
<h.body>
<h:form id="bannerForm">
<ui:insert name="banner">
<h:panelGroup styleClass="bannerPanel" layout="block">
<h:panelGrid
id="bannerGrid"
columns="2" columnClasses="bannerColLeft, bannerColRight"
style="margin: 0px;padding: 0px;width:100%;">
<h:graphicImage
url="/resources/images/GleneagleSign.png"
style="height: 100px;width: 100px;"/>
<h:outputText value="Gleneagle Civic Association"/>
</h:panelGrid>
</h:panelGroup>
</ui:insert>
<ui:insert name="menu">
<ui:include id="mnuIncld" src="gcaMenu.xhtml"/>
</ui:insert>
</h:form>
<h:panelGroup id="workPanel" layout="block" styleClass="alignLeft" style="margin-top:100px;">
<h:panelGrid id="wrkPnlGrd" columns="1" styleClass="alignLeft" columnClasses="workColumnLeft" rowClasses="workRow">
<h:outputLabel id="ajaxErrMsg" styleClass="errorLeft"/>
<ui:insert name="work">
</ui:insert>
</h:panelGrid>
</h:panelGroup>
<ui:insert name="bottomScript">
</ui:insert>
</h.body>
</html>
MENU:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<ui:composition id="mnuComp">
<p:menubar>
<p:menuitem value="Home" url="#"/>
<p:submenu label="About GCA">
<p:menuitem value="Leadership" action="/about/leadership"/>
<p:menuitem value="Our History" action="/about/history"/>
<p:menuitem value="Map of GCA" action="/about/map"/>
<p:menuitem value="Surrounding HOAs" action="/about/hoas"/>
<p:menuitem value="Related Links" action="/about/links"/>
</p:submenu>
<p:submenu label="Documents">
<p:submenu label="Board Meetings">
<p:menuitem value="Board Meeting Agenda" action="/doc/board/agenda"/>
<p:menuitem value="Board Meeting Minutes" action="/doc/board/minutes"/>
</p:submenu>
<p:submenu label="Membership Meetings">
<p:menuitem value="Membership Meeting Minutes" action="/doc/member/minutes"/>
</p:submenu>
<p:submenu label="Architectural Control">
<p:menuitem value="Approval Process" action="/doc/archCtl/approval"/>
<p:menuitem value="Variance Process" action="/doc/archCtl/variance"/>
<p:menuitem value="House Color Standards" action="/doc/archCtl/houseColors"/>
<p:menuitem value="Mailbox Specifications" action="/doc/archCtl/mailbox"/>
</p:submenu>
<p:submenu label="Covenants">
<p:menuitem value="Covenants, Restrictions and Charges" action="/doc/covenant"/>
<p:menuitem value="Amendment One" action="/doc/covenant/ammendment1"/>
<p:menuitem value="Amendment Four" action="/doc/covenant/ammendment4"/>
<p:menuitem value="Rules & Regulations" action="/doc/covenant/ruleRegs"/>
<p:menuitem value="Fine Schedule" action="/doc/covenant/findSchedule"/>
</p:submenu>
</p:submenu>
<p:submenu label="Contact">
<p:menuitem value="Feedback" action="/contact/feedback"/>
<p:menuitem value="Join Mailing List" action="/contact/mailList"/>
</p:submenu>
</p:menubar>
<p:growl id="messages"/>
</ui:composition>
</html>
I also attempted to create the menu programatically but the Menu Managed Bean was not being instantiated:
package org.gca.mbeans;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.primefaces.model.menu.DefaultMenuItem;
import org.primefaces.model.menu.DefaultMenuModel;
import org.primefaces.model.menu.DefaultSubMenu;
import org.primefaces.model.menu.MenuModel;
import org.springframework.stereotype.Component;
#Slf4j
#Getter
#Component
#ManagedBean(name = "menuBean")
#ViewScoped
public class MenuMB {
private final MenuModel menuModel = new DefaultMenuModel();
#PostConstruct
public void postConstruct() {
addMenu("Home");
addMenu("About GCA", "Leadership", "Our History", "Map of GCA", "Surrounding HOAs", "Related Links");
addMenu("Documents");
addMenu("Contacts");
log.debug("Added 4 menu items");
}
public DefaultSubMenu addMenu(String label, String... items) {
return addMenu(null, label, items);
}
public DefaultSubMenu addMenu(DefaultSubMenu parentMenu,
String label, String... items) {
DefaultSubMenu theMenu = new DefaultSubMenu(label);
for (Object item : items) {
DefaultMenuItem mi = new DefaultMenuItem(item);
mi.setUrl("#");
theMenu.getElements().add(mi);
}
if (parentMenu == null) {
menuModel.addElement(theMenu);
} else {
parentMenu.getElements().add(theMenu);
}
return theMenu;
}
}
index.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<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://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<body>
<ui:composition template="/gcaMain.xhtml">
<ui:define name="work">
<p:menubar model="#{menuBean.menuModel}"/>[enter image description here][1]
</ui:define>
</ui:composition>
</body>
</html>
Following #Melloware suggestion:
pom.xml update
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>joinfaces-dependencies</artifactId>
<version>${joinfaces.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>overcast</artifactId>
<version>${primefaces-theme.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
........
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>primefaces-spring-boot-starter</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primefaces.version}</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${jsf.ver}</version>
</dependency>-->
Removed JmsConfig file and removed faces-config.xml
Corrected typo in template <h. to <h:

error 404 while run springBoot application on chrome browser

I want to use jsp with springboot, i add jasper dependency in my
pom.xml file, but when i run my springboot app it run corectly ,when i
type localhost:8080/home in my browser it show me this type of error.
i use getMapping annotation in palace of RequestMapping,I try it last
four days but it cannot shorout
this is my project file strcture
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.main</groupId>
<artifactId>SpringSecurityTutorial</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>SpringSecurityTutorial</name>
<description>Spring Security Service</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-jasper -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<version>8.0.28</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-jasper -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jasper</artifactId>
<version>8.5.35</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
HomeConteoller.java
package com.main.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
#Controller
public class HomeController {
#GetMapping("/home")
public String home() {
return "Home.jsp";
}
}
home.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Welcome to Security Protection
</body>
</html>
The string returned by the home() handler method in your controller should be the name of the JSP view, without the extension. i.e. return "home";.
Try by adding the following dependency
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
Try this :
return "/Home.jsp";

layout.js - PrimeFaces.widget.Avalon not invoked

i using Primefaces 8.0,Springboot 2.2.5.RELEASE
and Avalon 2.1.1.
after add layout.js in template.xml, layout.js not invoke the menu on the left hand side does not work anymore. When clicking on another element from the layout-tab-menu the CSS class active is not assigned to layout-tab-submenu. The menu-resize-btn does not work anymore.
my project
template.xhtml
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title><ui:insert name="title">PrimeFaces Avalon</ui:insert></title>
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="theme-color" content="#03A9F4"/>
</f:facet>
<f:facet name="last">
<h:outputScript name="js/nanoscroller.js" library="avalon-layout" />
<h:outputScript name="js/layout.js" library="avalon-layout" />
</f:facet>
<ui:insert name="head"/>
</h:head>
<h:body>
<div class="layout-wrapper menu-layout-static">
<ui:include src="./topbar.xhtml" />
<ui:include src="menu.xhtml" />
<div class="layout-main">
<div class="layout-main-content">
<ui:insert name="content"/>
</div>
</div>
<ui:include src="./footer.xhtml" />
</div>
<p:ajaxStatus style="width:32px;height:32px;position:fixed;right:7px;bottom:7px">
<f:facet name="start">
<i class="fa fa-circle-o-notch fa-spin ajax-loader" aria-hidden="true"></i>
</f:facet>
<f:facet name="complete">
<h:outputText value="" />
</f:facet>
</p:ajaxStatus>
<h:outputStylesheet name="css/nanoscroller.css" library="avalon-layout" />
<h:outputStylesheet name="css/animate.css" library="avalon-layout" />
<h:outputStylesheet name="css/layout-blue-v4.css" library="avalon-layout" />
</h:body>
Web.xml
<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>/*</url-pattern>
</servlet-mapping>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
faces-config.xml
<application>
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
<el-resolver>
org.primefaces.application.exceptionhandler.PrimeExceptionHandlerELResolver
</el-resolver>
</application>
<factory>
<exception-handler-factory>
org.primefaces.application.exceptionhandler.PrimeExceptionHandlerFactory
</exception-handler-factory>
</factory>
<lifecycle>
<phase-listener>org.springframework.web.jsf.DelegatingPhaseListenerMulticaster</phase-listener>
</lifecycle>
dependencies
<modelVersion>4.0.0</modelVersion>
<groupId>psa</groupId>
<artifactId>empower-web</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<name>empower-web</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.20</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.2.20</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>8.0</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>avalon</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>2.0.SP1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>model</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
ServletCustom
#Bean
public ServletRegistrationBean facesServletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean<>(new FacesServlet(), "*.xhtml");
registration.setLoadOnStartup(1);
return registration;
}
#Bean
public ServletContextInitializer servletContextInitializer() {
return servletContext -> {
servletContext.setInitParameter("com.sun.faces.forceLoadConfiguration", Boolean.TRUE.toString());
servletContext.setInitParameter("javax.faces.PROJECT_STAGE", "Development");
servletContext.setInitParameter("facelets.DEVELOPMENT", "true");
servletContext.setInitParameter("javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE", "true");
servletContext.setInitParameter("primefaces.CLIENT_SIDE_VALIDATION", "true");
servletContext.setInitParameter("primefaces.THEME", "avalon-blue-v4");
servletContext.setInitParameter("javax.faces.STATE_SAVING_METHOD", "client");
servletContext.setInitParameter("primefaces.FONT_AWESOME", "true");
servletContext.setInitParameter("primefaces.UPLOADER", "commons");
servletContext.setInitParameter("org.apache.myfaces.ERROR_HANDLING", "true");
};
}
#Bean
public ServletListenerRegistrationBean<ConfigureListener> jsfConfigureListener() {
return new ServletListenerRegistrationBean<>(new ConfigureListener());
}
Question: What am I missing to register or configure?

Facelets welcome page not found or redirected using Spring Boot [duplicate]

This question already has answers here:
Changing default welcome-page for spring-boot application deployed as a war
(4 answers)
how to specify welcome-file-list in WebApplicationInitializer.onStartup()
(4 answers)
Closed 3 years ago.
I am currently trying to move a java EE 8 project running on wildfly to the latest spring boot.
For this i will need primefaces, primefaces-extensions and omnifaces cause of it's
components i am already using and also designed (buyed) theme.
Starting with the latest spring boot in combination with joinfaces i currently try to
define the welcome page or redirect to the index.xhtml page
but anything i tried failed.
Here is my current sources:
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>
<!-- Project settings -->
<groupId>com.skf.ecocalcweb</groupId>
<artifactId>EcoCalcDD4Web</artifactId>
<version>2.0.0</version>
<packaging>jar</packaging>
<!-- Using spring boot as parent -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<!-- Project properties -->
<properties>
<!-- General settings -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<java.version>1.8</java.version>
<!-- Libraries versions -->
<lombok.version>1.18.12</lombok.version>
<joinfaces.version>4.1.4</joinfaces.version>
<primefaces.core.version>7.0.11</primefaces.core.version>
<primefaces.extensions.version>7.0.3</primefaces.extensions.version>
<omnifaces.version>3.4.1</omnifaces.version>
<fontawesome.version>5.12.0</fontawesome.version>
</properties>
<!-- Use joinfaces for jsf starters -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>joinfaces-dependencies</artifactId>
<version>${joinfaces.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- JAR-Dependencies -->
<dependencies>
<!-- Spring boot starters -->
<!-- Exclude mojarra, so use myfaces instead -->
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>primefaces-spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.joinfaces</groupId>
<artifactId>mojarra-spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>myfaces-spring-boot-starter</artifactId>
</dependency>
<!-- Also use omnifaces3, so latest jsf version must be used -->
<dependency>
<groupId>org.joinfaces</groupId>
<artifactId>omnifaces3-spring-boot-starter</artifactId>
</dependency>
<!-- Java Enterprise API for using primefaces in JSF -->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- OmniFaces -->
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>${omnifaces.version}</version>
</dependency>
<!-- Primefaces core -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>${primefaces.core.version}-SNAPSHOT</version>
</dependency>
<!-- Primefaces extensions -->
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId>
<version>${primefaces.extensions.version}</version>
</dependency>
<!-- Primefaces theme -->
<dependency>
<groupId>com.skf.ecocalcweb</groupId>
<artifactId>PrimefacesTheme</artifactId>
<version>1.0.0</version>
</dependency>
<!-- Font Awesome -->
<dependency>
<groupId>org.webjars</groupId>
<artifactId>font-awesome</artifactId>
<version>${fontawesome.version}</version>
</dependency>
<!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!-- Package as an executable jar -->
<build>
<!-- Final name of war-file -->
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
/src/main/java/com/test/Application.java
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication app = new SpringApplication(Application.class);
app.run(args);
}
#Bean
public ServletRegistrationBean facesServletRegistration() {
FacesServlet servlet = new FacesServlet();
ServletRegistrationBean registration = new ServletRegistrationBean(servlet, new String[]{"*.xhtml"});
registration.setName("Faces Servlet");
registration.setLoadOnStartup(1);
registration.setEnabled(true);
registration.setOrder(1);
return registration;
}
#Bean
public ServletContextInitializer servletContextInitializer() {
return servletContext -> {
// MyFaces
servletContext.setInitParameter("org.apache.myfaces.LOG_WEB_CONTEXT_PARAMS", Boolean.FALSE.toString());
// Primefaces
servletContext.setInitParameter("primefaces.THEME", "harmony-fate");
servletContext.setInitParameter("primefaces.MOVE_SCRIPTS_TO_BOTTOM", Boolean.FALSE.toString());
servletContext.setInitParameter("primefaces.FONT_AWESOME", Boolean.TRUE.toString());
// Omnifaces
servletContext.setInitParameter("org.omnifaces.SOCKET_ENDPOINT_ENABLED", Boolean.TRUE.toString());
// JavaX
servletContext.setInitParameter("javax.faces.PROJECT_STAGE", "Production");
servletContext.setInitParameter("javax.faces.DEFAULT_SUFFIX", ".xhtml");
servletContext.setInitParameter("com.sun.faces.enableRestoreView11Compatibility", Boolean.TRUE.toString());
servletContext.setInitParameter("javax.faces.FACELETS_SKIP_COMMENTS", Boolean.TRUE.toString());
servletContext.setInitParameter("javax.faces.STATE_SAVING_METHOD", "server");
servletContext.setInitParameter("com.sun.faces.compressViewState", Boolean.FALSE.toString());
servletContext.setInitParameter("com.sun.face.serializeServerState", Boolean.FALSE.toString());
servletContext.setInitParameter("javax.faces.FACELETS_REFRESH_PERIOD", "-1");
servletContext.setInitParameter("javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL", Boolean.TRUE.toString());
servletContext.setInitParameter("javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE", Boolean.TRUE.toString());
servletContext.setInitParameter("javax.faces.ENABLE_CDI_RESOLVER_CHAIN", Boolean.TRUE.toString());
};
}
}
/src/main/java/com/test/controllers/Index.java
#Getter
#Setter
#RequestScope
#Named
public class Index {
private String firstName = "John";
private String lastName = "Doe";
public String showGreeting() {
return "Hello " + firstName + " " + lastName + "!";
}
}
/src/main/resources/META-INF/resources/index.xhtml
<?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:p="http://primefaces.org/ui">
<h:head>
<title>PrimeFaces Hello World Example</title>
</h:head>
<h:body>
<h:form id="helloworld-form">
<p:panel header="PrimeFaces Hello World Example">
<h:panelGrid columns="2" cellpadding="4">
<h:outputText value="First Name: " />
<p:inputText id="first-name" value="#{index.firstName}" />
<h:outputText value="Last Name: " />
<p:inputText id="last-name" value="#{index.lastName}" />
<p:commandButton id="submit" value="Submit"
update="greeting-panel"
oncomplete="PF('greetingDialog').show()" />
</h:panelGrid>
</p:panel>
<p:dialog header="Greeting" widgetVar="greetingDialog"
modal="true" resizable="false">
<h:panelGrid id="greeting-panel" columns="1" cellpadding="4">
<h:outputText value="#{index.showGreeting()}" />
</h:panelGrid>
</p:dialog>
</h:form>
</h:body>
</html>
/src/main/resources/META-INF/resources/application.properties
# the embedded application server config
server.port=80
server.servlet.context-path=/
# thymeleaf templating engine config
spring.thymeleaf.enabled=false
So what's needed here to set the welcome-page for a jsf application right ?
When i directly called
http://localhost/index.xhtml
the primefaces page will be rendered right,
but when i enter
http://localhost/
no redirect to the index.xhtml will be made
and i currently found nothing which is working as a "redirect" ...
I think i currently found the solution :
So i post it for all others which are start using spring boot and primefaces together:
Adding this dependency will fix my problem with the welcome page as xhtml :
<!-- Add spring boot web needed for navigation -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Then i can use the following class file to set my welcome-page:
/src/main/java/com/test/navigation/WelcomePageRedirect.java
#Configuration
public class WelcomePageRedirect implements WebMvcConfigurer {
#Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/")
.setViewName("forward:/index.xhtml");
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
}
}
Now the following technologies are working together:
Java 8 (And also Java 11 !)
Primefaces 7.0.11 + Primefaces Extensions
Omnifaces 3.4.1
Latest FontAwesome 5.12.0 in combination with Primefaces "old" FontAwesome
Spring Boot 2.2.4
JoinFaces 4.1.4
MyFaces 2.3

Resources