Uncaught ReferenceError: $ is not defined in JSF Primefaces [duplicate] - jsf-2

This question already has an answer here:
PrimeFaces CSS look'n'feel missing and JS "Uncaught Reference Error: PrimeFaces is not defined"
(1 answer)
Closed 7 years ago.
I'm doing a Primefaces project using Maven and Glassfish. I am following this tutorial by mkyong. I have followed all the steps but when I run my project, I get this error in my browser console.
Uncaught ReferenceError: $ is not defined
(anonymous function)
Here is part of the htmls that is generated:
<form id="j_idt6" name="j_idt6" method="post" action="/jsfTest/faces/hello.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="j_idt6" value="j_idt6" />
<div id="j_idt6:j_idt7" style="visibility:hidden"><textarea id="j_idt6:j_idt7_input" name="j_idt6:j_idt7_input">This editor is provided by PrimeFaces dfsdf</textarea></div><script id="j_idt6:j_idt7_s" type="text/javascript">$(function() {PrimeFaces.cw('Editor','widget_j_idt6_j_idt7',{id:'j_idt6:j_idt7'},'editor');});</script>
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="2416258137569200952:-2734382740508742283" autocomplete="off" />
And no primefaces editor is shown up.
But there is no error in the server log.
Here are my files:
hello.xhtml(the welcome file)
<?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:p="http://primefaces.org/ui"
>
<h:body>
<h:form>
<p:editor value="#{editor.value}" />
</h:form>
</h:body>
</html>
my web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<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>/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>
<!-- Welcome page -->
<welcome-file-list>
<welcome-file>faces/hello.xhtml</welcome-file>
</welcome-file-list>
</web-app>
my glassfish-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server
3.1 Servlet 3.0//EN"
"http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
<parameter-encoding default-charset="UTF-8"/>
</glassfish-web-app>
my managed bean:
import javax.faces.bean.ManagedBean;
#ManagedBean(name = "editor")
public class EditorBean {
private String value = "This editor is provided by PrimeFaces";
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
finally, my pom.xml looks like:
<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>com.anixtech.jsf</groupId>
<artifactId>jsfTest</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>jsfTest Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>prime-repo</id>
<name>Prime Repo</name>
<url>http://repository.primefaces.org</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.3</version>
</dependency>
<!-- JSF 2 -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.11</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.11</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
<!-- EL -->
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
<build>
<finalName>jsfTest</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
I don't know what am I doing wrong.
Any idea?
Thanks in advance.

This question had no answer and is not marked as answered, but BalusC solution worked form me and the person who asked the question, So I'll put hear and please mark the question as answered:
You should add : <h:head> in the XHTML file

Related

NullPointerException during initFaces of a MyFaces 2.0 application while migrating from WLS to Tomcat

I'm new to JSF and have been entrusted with the task of migrating what appears to me as an old MyFaces 2.0 webapp from WebLogic Server 12.1.3 to Tomcat (I chose Tomcat 9 and OpenWebBeans 2.0.20).
I followed the instructions at BalusC's page to integrate OpenWebBeans with Tomcat/webapp since just cdi-api-1.0.jar didn't do the trick.
I am seeing the following exception (please see the full stack trace further down).
20-Jun-2022 19:46:25.718 INFO [main] org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces ServletContext 'C:\apache-tomcat-9.0.63\webapps\app1\' initialized.
20-Jun-2022 19:46:25.767 INFO [main] org.primefaces.webapp.PostConstructApplicationEventListener.processEvent Running on PrimeFaces 4.0
20-Jun-2022 19:46:25.802 INFO [main] org.apache.myfaces.config.annotation.DefaultLifecycleProviderFactory.getLifecycleProvider Using LifecycleProvider org.apache.myfaces.config.annotation.AllAnnotationLifecycleProvider
20-Jun-2022 19:46:25.808 SEVERE [main] org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces An error occured while initializing MyFaces: null
java.lang.NullPointerException
at org.apache.myfaces.application.DefaultResourceHandlerSupport.calculateFacesServletMapping(DefaultResourceHandlerSupport.java:211)
Update #1:
After #tandraschko's suggestion to upgrade MyFaces from 2.0.0 to 2.0.25 & OpenWebBeans from 2.0.20 to 2.0.27, the above exception has evolved as follows:
28-Jun-2022 11:02:58.128 SEVERE [main] org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces An error occured while initializing MyFaces: null
java.lang.NullPointerException
at org.apache.webbeans.container.BeanManagerImpl.wrapExpressionFactory(BeanManagerImpl.java:1288)
Update #2:
After #tandraschko's suggestion to upgrade MyFaces from 2.0.0 to 2.3.10 and add StartupServletContextListener in web.xml, the latest exception is similar to the one above:
28-Jun-2022 12:20:17.674 SEVERE [main] org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces An error occured while initializing MyFaces: null
java.lang.NullPointerException
at org.apache.webbeans.container.BeanManagerImpl.wrapExpressionFactory(BeanManagerImpl.java:1288)
Update #3:
After #tandraschko's suggestion to match my pom.xml with that of the sample project, primefaces-test, there's no exception anymore!
However, launching the app on the browser resulted in the following exceptions being thrown (not related to the original question though):
30-Jun-2022 18:52:23.743 INFO [http-nio-8080-exec-6] org.apache.myfaces.extensions.cdi.jpa.impl.JpaModuleStartupObserver.logJpaModuleConfiguration [Started] MyFaces CODI JPA-Module v1.0.5
30-Jun-2022 18:52:23.781 INFO [http-nio-8080-exec-6] org.apache.myfaces.extensions.cdi.jsf2.impl.Jsf2ModuleStartupObserver.logJsfModuleConfiguration [Started] MyFaces CODI JSF-Module v1.0.5 for JSF 2.0
Used JSF implementation: MyFaces Core v2.3.10
config implementation: org.apache.myfaces.extensions.cdi.jsf.api.config.JsfModuleConfig$$OwbNormalScopeProxy0
config implementation: org.apache.myfaces.extensions.cdi.jsf.api.config.JsfModuleConfig
method: isInitialRedirectEnabled
value: true
method: isAlwaysKeepMessages
value: true
method: isUseViewConfigsAsNavigationCasesEnabled
value: true
method: isInvalidValueAwareMessageInterpolatorEnabled
value: true
config implementation: org.apache.myfaces.extensions.cdi.core.api.scope.conversation.config.WindowContextConfig$$OwbNormalScopeProxy0
config implementation: org.apache.myfaces.extensions.cdi.core.api.scope.conversation.config.WindowContextConfig
method: getWindowContextTimeoutInMinutes
value: 60
method: isUnknownWindowIdsAllowed
value: false
method: isCloseWindowContextEventEnabled
value: false
method: getMaxWindowContextCount
value: 64
method: isUrlParameterSupported
value: true
method: isAddWindowIdToActionUrlsEnabled
value: false
method: isCreateWindowContextEventEnabled
value: false
method: isEagerWindowContextDetectionEnabled
value: true
method: isCloseEmptyWindowContextsEnabled
value: false
config implementation: org.apache.myfaces.extensions.cdi.core.api.scope.conversation.config.ConversationConfig$$OwbNormalScopeProxy0
config implementation: org.apache.myfaces.extensions.cdi.core.api.scope.conversation.config.ConversationConfig
method: isStartConversationEventEnabled
value: false
method: isConversationRequiredEnabled
value: true
method: isCloseConversationEventEnabled
value: false
method: getConversationTimeoutInMinutes
value: 30
method: isAccessBeanEventEnabled
value: false
method: isUnscopeBeanEventEnabled
value: false
method: isScopeBeanEventEnabled
value: false
method: isRestartConversationEventEnabled
value: false
MessageContextConfig class: org.apache.myfaces.extensions.cdi.message.impl.DefaultMessageContextConfig
MessageInterpolator class: class org.apache.myfaces.extensions.cdi.jsf.impl.message.FacesMessageInterpolator
MessageResolver class: class org.apache.myfaces.extensions.cdi.jsf.impl.message.JsfAwareApplicationMessagesMessageResolver
MessageHandler class: class org.apache.myfaces.extensions.cdi.jsf.impl.message.JsfAwareMessageHandler
LocaleResolver class: class org.apache.myfaces.extensions.cdi.jsf.impl.message.JsfAwareLocaleResolver
FormatterFactory class: class org.apache.myfaces.extensions.cdi.message.impl.DefaultFormatterFactory
18:52:25.189 [http-nio-8080-exec-6] ERROR com.company.app1.enterprise.exception.app1ExceptionHandler - ExpHandler: current exception:class javax.faces.FacesException
18:52:25.190 [http-nio-8080-exec-6] ERROR com.company.app1.enterprise.exception.app1ExceptionHandler - ExpHandler: current exception component:null
18:52:25.192 [http-nio-8080-exec-6] ERROR com.company.app1.enterprise.exception.app1ExceptionHandler - ExpHandler: current exception phaseid:RENDER_RESPONSE(6)
18:52:25.200 [http-nio-8080-exec-6] ERROR com.company.app1.enterprise.exception.app1ExceptionHandler - ExpHandler: current exception: attributes{}
After scouring through post after post in SO, I wasn't able to find a similar issue nor any clue to crack my issue.
After decompiling myfaces-impl-2.0.0.jar, it seems that externalContext.getRequestServletPath() is returning null.
The webapp has extension mapping in web.xml (kindly see snippet further down) but I'm not sure if I'm looking at the right suspect.
Exception (Full Stack Trace after Update #2)
28-Jun-2022 12:20:17.674 SEVERE [main] org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces An error occured while initializing MyFaces: null
java.lang.NullPointerException
at org.apache.webbeans.container.BeanManagerImpl.wrapExpressionFactory(BeanManagerImpl.java:1288)
at org.apache.webbeans.jsf.OwbApplication.getExpressionFactory(OwbApplication.java:48)
at org.apache.myfaces.config.ManagedBeanBuilder.coerceToType(ManagedBeanBuilder.java:364)
at org.apache.myfaces.config.ManagedBeanBuilder.initializeProperties(ManagedBeanBuilder.java:347)
at org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:163)
at org.apache.myfaces.webapp.AbstractFacesInitializer._createEagerBeans(AbstractFacesInitializer.java:339)
at org.apache.myfaces.webapp.AbstractFacesInitializer.initFaces(AbstractFacesInitializer.java:218)
at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:103)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4768)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5230)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:698)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1024)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1911)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:825)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:475)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1618)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:319)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:946)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:835)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1396)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1386)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:919)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:263)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:432)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:927)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:772)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:476)
Configuration (as deduced & set up accordingly)
MyFaces 2.0
CODI 1.0.5
PrimeFaces 4.0
OpenWebBeans 2.0.20 (CDI 2.0 but beans_1_0 in beans.xml)
Tomcat 9
Java 8
Update 3: No jars were added to Tomcat's lib.
Update 3: The webapp's lib has the following 13 manually-added jars (with my notes against them):
Interestingly, everything works only if the 13 jars are placed in the webapp's lib (WEB-INF\lib) and not in Tomcat's lib!
Are there any recommendations or best practices on how to manage these 13 dependent jars?
commons-digester-1.8.jar
javax.ejb-api-3.2.2.jar
javax.persistence-api-2.2.jar
javax.ws.rs-api-2.0.1.jar
jersey-client-1.18.jar
jersey-core-1.18.jar (provided scope)
jersey-multipart-1.18.jar (provided scope)
jersey-server-1.18.jar (provided scope)
jersey-servlet-1.18.jar (provided scope)
myfaces-api-2.3.10.jar (one of the profile dependencies; should it be added to the POM as mentioned [here][2])
myfaces-impl-2.3.10.jar (one of the profile dependencies; should it be added to the POM as mentioned [here][2])
weblogic.jaxrs.internal.common_1.2.0.0.jar (need to be replaced with another JAX-RS provider?)
weblogic.jaxrs.server_3.0.0.0.jar (need to be replaced with another JAX-RS provider?)
pom.xml (abridged; modified now after years for Update #3)
<?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>TMapp1</groupId>
<artifactId>app1</artifactId>
<version>5.0</version>
<packaging>war</packaging>
<name>TM app1 Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<owb.version>2.0.27</owb.version>
</properties>
<dependencies>
<!-- app1 uses PrimeFaces 4.0 instead of 11.0.0 as primefaces-test 11.0.0 does. -->
<!-- <dependency> -->
<!-- <groupId>org.primefaces</groupId> -->
<!-- <artifactId>primefaces</artifactId> -->
<!-- <version>11.0.0</version> -->
<!-- </dependency> -->
<!-- javax.* APIs -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-atinject_1.0_spec</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jcdi_2.0_spec</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-interceptor_1.2_spec</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.3_spec</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-validation_2.0_spec</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.6</version>
</dependency>
<!-- app1 uses 3.1.0 instead of 4.0.1 as primefaces-test 11.0.0 does. -->
<!-- <dependency> -->
<!-- <groupId>javax.servlet</groupId> -->
<!-- <artifactId>javax.servlet-api</artifactId> -->
<!-- <version>4.0.1</version> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- app1 uses 2.2.4 instead of 3.0.0 as primefaces-test 11.0.0 does. -->
<!-- <dependency> -->
<!-- <groupId>javax.el</groupId> -->
<!-- <artifactId>javax.el-api</artifactId> -->
<!-- <version>3.0.0</version> -->
<!-- <scope>provided</scope> -->
<!-- </dependency> -->
<!-- OpenWebBeans -->
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-impl</artifactId>
<version>${owb.version}</version>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-jsf</artifactId>
<version>${owb.version}</version>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-web</artifactId>
<version>${owb.version}</version>
</dependency>
<dependency>
<groupId>org.apache.openwebbeans</groupId>
<artifactId>openwebbeans-el22</artifactId>
<version>${owb.version}</version>
</dependency>
<dependency>
<groupId>org.apache.bval</groupId>
<artifactId>bval-jsr</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
</dependency>
<!-- start of apache-commons -->
<!-- Used by: app1 -->
<dependency>
<groupId<!-- ... -->
</dependency>
<!-- end of apache-commons -->
<dependency>
<!-- Used by: TODO: app1 -->
<groupId>org.apache.myfaces.extensions.cdi.bundles</groupId>
<artifactId>myfaces-extcdi-bundle-jsf20</artifactId>
<version>1.0.5</version>
</dependency>
<!-- primefaces? -->
<!-- Used by: app1 -->
<dependency> <!-- not used at compile time -->
<groupId>org.atmosphere</groupId>
<!-- ... -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>4.0</version>
</dependency>
<!-- Used by: app1 -->
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.4</version>
</dependency>
<!-- start of jersey libs -->
<dependency>
<!-- ... -->
</dependency>
<!-- end of jersey libs -->
<dependency>
<!-- Used by: app1 -->
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>primefaces</id>
<name>PrimeFaces Maven Repository</name>
<url>https://repository.primefaces.org</url>
<layout>default</layout>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<build>
<finalName>app1</finalName>
<plugins>
<!-- ... -->
</plugins>
<resources>
<!-- ... -->
</resources>
</build>
<profiles>
<profile>
<id>myfaces22</id>
<!-- ... -->
</profile>
<profile>
<id>myfaces23</id>
<!-- ... -->
</profile>
<profile>
<id>myfaces23next</id>
<!-- ... -->
</profile>
<profile>
<id>coverage</id>
<!-- ... -->
</profile>
</profiles>
</project>
web.xml
I removed what seems to be an old Mojarra remnant (following an error reported during startup):
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
from the web.xml below leaving me with only the 2 newly added listeners, WebBeansConfigurationListener (for OWB) and StartupServletContextListener (since Update #2: explicitly demanded it), in that order. Finally, cleaned it up to match the sample project, primefaces-test (Update #3).
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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_3_0.xsd" >
<display-name>app1</display-name>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>casablanca</param-value>
</context-param>
<!-- Enable PostConstruct on JSF ManagedBeans on Jetty (and Tomcat as well?) -->
<context-param>
<param-name>org.apache.myfaces.config.annotation.LifecycleProvider</param-name>
<param-value>org.apache.myfaces.config.annotation.NoInjectionAnnotationLifecycleProvider</param-value>
</context-param>
<listener>
<listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class>
</listener>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.company.app1.enterprise.service.health</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/health/*</url-pattern>
</servlet-mapping>
<session-config> <!-- set the default session time out to 60 minutes -->
<session-timeout>60</session-timeout>
<!-- set the Session Cookie as httpOnly -->
<!-- <cookie-config>
<http-only>true</http-only>
</cookie-config> -->
<!-- Added this for SPR HCSDM00273622 - Links to sign up new users not working properly -->
<tracking-mode>COOKIE</tracking-mode>
</session-config>
<filter>
<filter-name>ParameterEscapeFilter</filter-name>
<filter-class>com.company.app1.enterprise.filter.ParameterEscapeFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>ParameterEscapeFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>primeFacesFileUploadFilter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>primeFacesFileUploadFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<filter>
<filter-name>GzipFilter</filter-name>
<filter-class>com.axeda.qpublic.filter.GZipServletFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>GzipFilter</filter-name>
<url-pattern>*.js</url-pattern>
</filter-mapping>
<filter-mapping>
<!-- ... -->
</filter-mapping>
<resource-env-ref>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
<resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type>
</resource-env-ref>
<mime-mapping>
<extension>xhtml</extension>
<mime-type>text/xhtml</mime-type>
</mime-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
beans.xml (untouched for years)
<?xml version="1.0" encoding="UTF-8"?>
<beans 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/beans_1_0.xsd">
<interceptors>
<class>org.apache.myfaces.extensions.cdi.jsf.impl.security.SecurityInterceptor</class>
<class>org.apache.myfaces.extensions.cdi.jsf.impl.listener.phase.ViewControllerInterceptor</class>
<class>org.apache.myfaces.extensions.cdi.jsf.impl.scope.conversation.CloseConversationGroupInterceptor</class>
<class>org.apache.myfaces.extensions.cdi.jsf.impl.config.view.PageParameterInterceptor</class>
<class>org.apache.myfaces.extensions.cdi.jsf.impl.config.view.PageParameterListInterceptor</class>
<class>org.apache.myfaces.extensions.cdi.jpa.impl.transaction.TransactionalInterceptor</class>
</interceptors>
</beans>
Why not use the latest MyFaces version? There is even a 2.0.24...
EDIT #1 - from the comments
I'd perform the following more steps based on the instructions from user #tandraschko in the comment thread below.
Side Note: I'm grateful to #tandraschko for the timely response & clear instructions.
Upgraded MyFaces version initially from 2.0.20 --> 2.0.24 but later to 2.3.10.
Upgraded OpenWebBeans version from 2.0.20 to 2.0.27.
Added the MyFaces listener StartupServletContextListener AFTER the OpenWebBeans one.
Cleaned up Maven dependencies to include all dependencies in the webapp's WEB-INF\lib (in contrast to a few at the sample which are of scope provided).

Spring Security not working over RestServices

I have a RestController working and I want to learn how to enable Basic Auth with Spring Security.
I've created a class that extends WebSecurityConfigurerAdapter and for what I understand, it should be enough. Sadly I can call the resources without providing credentials.
Here is my code:
Configurer Adapter
package es.ieci.test.security;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
#Configuration
#EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
public static final String REALM = "TEST_REALM";
#Override
protected void configure(HttpSecurity http) throws Exception{
http
.csrf().disable()
.authorizeRequests().antMatchers("/services/**").hasRole("ADMIN").and()
.httpBasic().realmName(REALM).authenticationEntryPoint(getBasicAuthEntryPoint()).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}
#Bean
public CustomBasicAuthenticationEntryPoint getBasicAuthEntryPoint(){
return new CustomBasicAuthenticationEntryPoint();
}
}
Spring Config file
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="es.ieci.test.security, es.ieci.test.controller, es.ieci.test.services, es.ieci.test.utils" />
</beans>
web.xml
<?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_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">
<display-name>TestRestSpring</display-name>
<servlet>
<servlet-name>springrest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springrest</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>
And my pom file
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.3.RELEASE</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-web</artifactId>
<version>2.7</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
I'm using a Tomcat v6.0m and the server logs looks good:
nov 17, 2016 2:00:32 PM
org.springframework.security.web.DefaultSecurityFilterChain
INFORMACIÓN: Creating filter chain:
org.springframework.security.web.util.matcher.AnyRequestMatcher#1,
[org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#f671723,
org.springframework.security.web.context.SecurityContextPersistenceFilter#2b8af779,
org.springframework.security.web.header.HeaderWriterFilter#49d0b86,
org.springframework.security.web.authentication.logout.LogoutFilter#6f7b847c,
org.springframework.security.web.authentication.www.BasicAuthenticationFilter#3b022cae,
org.springframework.security.web.savedrequest.RequestCacheAwareFilter#1eebd4a2,
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter#4cb106be,
org.springframework.security.web.authentication.AnonymousAuthenticationFilter#392002bb,
org.springframework.security.web.session.SessionManagementFilter#e13b2fb,
org.springframework.security.web.access.ExceptionTranslationFilter#6b4187ba,
org.springframework.security.web.access.intercept.FilterSecurityInterceptor#241377b6]
But if I call to
http://localhost:8383/TestRestSpring/services/echo
Without providing user credentials the server response is 200 instead of the expected Auth error
I've been able to get 401 code adding a filter to web.xml
<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>
But I'm not sure if this is the right way.
It seems you missed to add context config file in your web.xml,so component scanning of security configuration is not done.
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-dispatcher-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

org.jboss.as.server.deployment.DeploymentUnitProcessingException: Failed to parse "/WEB-INF/web.xml" at [6,1]

I create simple app with PrimeFaces 3.4 and JSF 2.1. When I deploy the application in my JBoss AS 7.0, I encounter the following error
18:55:27,684 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) Starting deployment of "Getting-started-with-Primefaces.war"
18:55:29,480 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.deployment.unit."Getting-started-with-Primefaces.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."Getting-started-with-Primefaces.war".PARSE: Failed to process phase PARSE of deployment "Getting-started-with-Primefaces.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:121) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1824) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1759) [jboss-msc-1.0.1.GA.jar:1.0.1.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [:1.7.0_79]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [:1.7.0_79]
at java.lang.Thread.run(Thread.java:745) [:1.7.0_79]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Failed to parse "/C:/Users/marcos/Downloads/jboss-as-web-7.0.2.Final/jboss-as-web-7.0.2.Final/standalone/deployments/Getting-started-with-Primefaces.war/WEB-INF/web.xml" at [6,1]
at org.jboss.as.web.deployment.WebParsingDeploymentProcessor.deploy(WebParsingDeploymentProcessor.java:70)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:115) [jboss-as-server-7.0.2.Final.jar:7.0.2.Final]
... 5 more
My 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>com.itcuties.examples.webapps.simplejsf</groupId>
<artifactId>simple-jsf2-with-primefaces</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>simple-jsf2</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- Primefaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.4</version>
</dependency>
<!-- JSF 2 API -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.0-m07</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>primefaces-repository</id>
<name>Primefaces repository</name>
<url>http://repository.primefaces.org</url>
</repository>
</repositories>
<build>
<finalName>jsf2</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Update: on request, 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">
<web-app>
<display-name>Simple JSF2 Application with Primefaces</display-name>
<!--
Current project stage. When it is set to 'Development' Primefaces give a lot of debug information on the screen.
-->
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<!-- Staring JSF -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- JSF URL mapping -->
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
The problem in cause by, is in line [6,1] in the tag "web-app", but I do not understand.
Any idea what could be the problem?
In case you're getting exceptions, always head to the bottommost "Caused by" part for the root cause of all the trouble.
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: Failed to parse "/C:/Users/marcos/Downloads/jboss-as-web-7.0.2.Final/jboss-as-web-7.0.2.Final/standalone/deployments/Getting-started-with-Primefaces.war/WEB-INF/web.xml" at [6,1]
You see, a good exception and message is usually already the whole answer at its own. The server choked while parsing the webapp's web.xml file at line 6 and character 1.
Your web.xml look like this:
1 <web-app xmlns="http://java.sun.com/xml/ns/javaee"
2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
4 http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
5 version="3.0">
6 <web-app>
7 <display-name>Simple JSF2 Application with Primefaces</display-name>
.
. ...
.
. </web-app>
At line 6 there's a duplicate <web-app> declaration. Get rid of it.

warning when using primefaces (no taglib found)

I am using pimefaces in my project and I get the following message when the page is displayed in the browser:
Warning: This page calls for XML namespace http://primefaces.org/ui declared with prefix p but no taglibrary exists for that namespace.
In my POM:
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.5</version>
</dependency>
In my xhtml files:
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/templates/default_template.xhtml">
<ui:define name="content">
<h1>My Stuff</h1>
<h:form>
<p:dataTable value="#{edb.actions}" var="action">
<p:column>
<p:commandButton actionListener="#{acontroller.doDelete(aktion)}" icon="ui-icon-close" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="name" />
</f:facet>
<h:outputText value="#{action.name}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="goal" />
</f:facet>
<h:outputText value="#{action.goals}">
<f:convertNumber type="currency" currencyCode="EUR" />
</h:outputText>
</p:column>
.. and so on
I am using Glassfish 4.0 and EclipseEE Version: 4.3.2.
What do I need to change?
Thanks for help and tips!
EDIT:
I removed primefaces completely and now JSF tags are not displayed. I read that this may be linked to the Faces Servlet not kicking in. My web.xml:
<?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"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>MyProject</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>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
</web-app>
My webapp folder structure:
webapp
- content
--- .xhtml files
- index.xhtml
- resources
--- css
------ screen.css
- WEB-INF
- web.xml
- beans.xml (empty)
- faces.config.xml (empty)
- glassfish.web.xml (empty)
- templates
--- default_template.xhtml
In my POM:
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.2.8</version>
</dependency>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>javax.faces-api</artifactId>
<version>2.2</version>
<scope>provided</scope>
</dependency>
... and so on:
What's the problem now then?? I dont understand this. It worked perfectly until a couple of days ago...

JSF 2 doesn't work on WebSphere 7 - Redirecting to JSP

I have a application that runs very well on JBoss using JSF 2. I saw the problems related with the JSF 2, WebSphere and Class Loader. At this time, I see the message "Initializing Mojarra 2.1.7 for the context '/medicao-web'". Then, I think that the class loader is loading the correct JSF classes.
I have a index.jsp that is used to redirect to index.jsf. When I tried to request index.jsf, it makes a infinite loop and a lot of exceptions. In the stacktrace, there's a "at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)", then I think that it's using the FacesServlet at some time. But I also see in the log that the problem related to the JSF is that it's trying to read a JSP.
I also tried to request a different page, that there's no JSP with the same name. After requesting arquivo.jsf, I get:
java.io.FileNotFoundException: JSPG0036E: Failed to find resource /arquivo.jsp
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.findWrapper(AbstractJSPExtensionProcessor.java:360)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionProcessor.handleRequest(AbstractJSPExtensionProcessor.java:331)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:325)
at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:415)
at com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:491)
at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:159)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1443)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1384)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:131)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:188)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:116)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:77)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:852)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:785)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:443)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:175)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3610)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:274)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:926)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1557)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:173)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:455)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:384)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:272)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:202)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:766)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:896)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
This is my web.xml:
<?xml version="1.0"?>
<web-app version="2.5" 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_2_5.xsd">
<display-name>MedicaoCNI</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>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>medicao</param-value>
</context-param>
<filter>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>PrimeFaces FileUpload Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
</web-app>
And this is my faces-config.xml:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude" 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-facesconfig_2_0.xsd">
<!-- <lifecycle>
<phase-listener>org.cni.medicao.util.AuthenticationListener</phase-listener>
</lifecycle> -->
<navigation-rule>
<from-view-id>/*</from-view-id>
<navigation-case>
<from-outcome>loginSucesso</from-outcome>
<to-view-id>/usuario.jsf</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>loginFail</from-outcome>
<to-view-id>/index.jsf</to-view-id>
<redirect />
</navigation-case>
<navigation-case>
<from-outcome>logoutSucesso</from-outcome>
<to-view-id>/index.jsf</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
</faces-config>
All my pages are in XHTML format. I also added a facelets dependency to my project. And I'm using maven.
I made some configurations to try making the class loader to load PARENT_LAST. I don't know if it's correct, but while the log says that it's load the Mojarra 2.1.7, I think it's ok.
I found a post related with mine, but it isn't solved: JSF 2 Mojarra and Primefaces in WebSphere 7+
Thanks in advance.
UPDATE:
I tried to add the javax.faces.DEFAULT_SUFFIX context param to .xhtml. The result is that when I tried to open the arquivo.jsf, I see the source of the XHTML. Although the log is saying it's initializing the Mojarra 2.1.7, I am feeling that there's some conflict here.
This is my ear-plugin configuration of the ear's maven module:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.6</version>
<configuration>
<version>5</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
<earSourceDirectory>${basedir}\src\main\application\META-INF\ibmconfig</earSourceDirectory>
</configuration>
</plugin>
At \src\main\application\META-INF\ibmconfig, there's the deployment.xml:
<appdeployment:Deployment xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:appdeployment="http://www.ibm.com/websphere/appserver/schemas/5.0/appdeployment.xmi" xmi:id="Deployment_1241112964096">
<deployedObject xmi:type="appdeployment:ApplicationDeployment" xmi:id="ApplicationDeployment_1241112964096" startingWeight="1" warClassLoaderPolicy="SINGLE">
<classloader xmi:id="Classloader_1241112964096" mode="PARENT_LAST"/>
<modules xmi:type="appdeployment:WebModuleDeployment" xmi:id="WebModuleDeployment_1241112964096" startingWeight="10000" uri="medicao-web.war">
<classloader xmi:id="Classloader_1241112964097" mode="PARENT_LAST"/>
</modules>
</deployedObject>
</appdeployment:Deployment>
And in my web's maven module, I have this dependencies:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>com.sun.facelets</groupId>
<artifactId>jsf-facelets</artifactId>
<version>1.1.14</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.2</version>
<scope>compile</scope>
</dependency>
Is there something wrong? I'm new on WebSphere and I need to use it with JSF 2.
UPDATE:
I removed the jsf-facelets dependency, but it's not working yet.
I exported an EAR to see if the deployment.xml is there, but it's not being packaged within the EAR. Is there something wrong?
UPDATE:
Now, I'm following this tutorial: http://www.webspheretools.com/sites/webspheretools.nsf/docs/How%20to%20set%20the%20class%20loading%20policy%20to%20parent%20last%20using%20configuration%20files%20shipped%20within%20the%20EAR
My deployment.xml is under \META-INF\ibmconfig\cells\defaultCell\applications\
defaultApp\deployments\defaultApp, and my ear plugin's configuration is:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>2.6</version>
<configuration>
<version>5</version>
<defaultLibBundleDir>lib</defaultLibBundleDir>
</configuration>
</plugin>
This way, the deployment.xml is being packaged when I export the EAR. My deployment.xml is the same as shown in the tutorial.
Anyway, when I deploy my application on WebSphere, it generates a new deployment.xml, ignoring mine. Then, it still loading parent first.
Well, all my configuration was ok.
I tried installing the EAR using the console of WebSphere, and it read my deployment.xml. I think that there's something wrong with the WebSphere 7 plugin developed by IBM. It's not installing properly the application, then it's ignoring the deployment.xml.
Now my problem is related with IDE, since it's terrible to manually install the application every time I change it, but this question is not about it.
I think that websphere 7 doesn't support JSF 2 without a bridge.

Resources