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

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).

Related

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.

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

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

java.lang.IllegalAccessError: tried to access class com.sun.faces.context.ApplicationMap

i ve a jsf application which works fine on eclipse with tomcat 7. The problem happened when i packaged it (with mvn package..) and put the .war file in the tomcat webapps directory to deploy it.
in the tomcat console i got :
SEVERE: Error listenerStart
Nov 2, 2012 12:38:09 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/jsf_prime_ldap] startup failed due to previous errors
Nov 2, 2012 12:38:09 AM org.apache.catalina.loader.WebappClassLoader checkThread
LocalMapForLeaks
SEVERE: The web application [/jsf_prime_ldap] created a ThreadLocal with key of
type [com.sun.faces.config.ConfigureListener$1] (value [com.sun.faces.config.Con
figureListener$1#6972f1]) and a value of type [com.sun.faces.config.ConfigureLis
tener.ServletContextAdapter] (value [com.sun.faces.config.ConfigureListener$Serv
letContextAdapter#18fee4f]) but failed to remove it when the web application was
stopped. Threads are going to be renewed over time to try and avoid a probable
memory leak.
for more details about this problem, in the localhost's tomcat log file i have :
SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.IllegalAccessError: tried to access class com.sun.faces.context.ApplicationMap from class com.sun.faces.config.InitFacesContext$ServletContextAdapter
at com.sun.faces.config.InitFacesContext$ServletContextAdapter.getApplicationMap(InitFacesContext.java:331)
at javax.faces.FactoryFinder$FactoryManagerCacheKey.<init>(FactoryFinder.java:850)
at javax.faces.FactoryFinder$FactoryManagerCache.getApplicationFactoryManager(FactoryFinder.java:719)
at javax.faces.FactoryFinder$FactoryManagerCache.access$100(FactoryFinder.java:691)
at javax.faces.FactoryFinder.setFactory(FactoryFinder.java:373)
at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:666)
at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:417)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:348)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Nov 2, 2012 12:38:09 AM org.apache.catalina.core.StandardContext listenerStop
SEVERE: Exception sending context destroyed event to listener instance of class com.sun.faces.config.ConfigureListener
java.lang.IllegalAccessError: com/sun/faces/context/ApplicationMap
at com.sun.faces.config.InitFacesContext$ServletContextAdapter.getApplicationMap(InitFacesContext.java:331)
at javax.faces.FactoryFinder$FactoryManagerCacheKey.<init>(FactoryFinder.java:850)
at javax.faces.FactoryFinder$FactoryManagerCache.removeApplicationFactoryManager(FactoryFinder.java:810)
at javax.faces.FactoryFinder.releaseFactories(FactoryFinder.java:395)
at com.sun.faces.config.ConfigureListener.contextDestroyed(ConfigureListener.java:378)
at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4831)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5478)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
in the tomcat lib directory i have added these jars :
commons-beanutils-1.8.3/
commons-collections-3.2.1/
commons-digester-1.5/
commons-logging-1.1.1/
el-impl-2.2/
jsf-api-2.1.11/
jsf-impl-2.1.11/
jsp-api-2.1/jstl-1.2/
primefaces-3.4.1
The application's pom file :
<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.jsfprimeldap</groupId>
<artifactId>jsf_prime_ldap</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>jsf_prime_ldap 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>
<!-- PrimeFaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.4.1</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>
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>1.1_02</version>
</dependency>
<!-- Tomcat 6 need this <dependency> <groupId>com.sun.el</groupId> <artifactId>el-ri</artifactId>
<version>1.0</version> </dependency> -->
</dependencies>
<build>
<finalName>jsf_prime_ldap</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>
</project>
and 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" 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" id="WebApp_ID" version="3.0">
<display-name>jsf_prime_ldap</display-name>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
</web-app>
i didn't find any similar problem in google.. i wish to find the solution for this problem here.
thanks for help
in the tomcat lib directory i have added these jars : commons-beanutils-1.8.3/ commons-collections-3.2.1/ commons-digester-1.5/ commons-logging-1.1.1/ el-impl-2.2/ jsf-api-2.1.11/ jsf-impl-2.1.11/ jsp-api-2.1/jstl-1.2/ primefaces-3.4.1
Undo this step. Reinstall Tomcat altogether if you're uncertain. Do not ever touch it unless you really understand what you're doing. This is the cause of the whole problem. The classpath has become a messup and the duplicate JARs/classes are conflicting each other.
Webapp-specific JARs doesn't belong in there. They belong in /WEB-INF/lib, expect of the EL and JSP JARs; Tomcat has as being a JSP/Servlet/EL container already its own implementations for this. You should not put JSP/Servlet/EL libraries of a different container make/version in the classpath at all.
Technically, at least the both JSF JARs, the JSTL JAR and the PrimeFaces JAR should be in /WEB-INF/lib. However, as you're using Maven, it should already have taken care about this. You don't need to do anything regard this. So all you need to do is to free Tomcat from illegal JARs/classes.

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.

JSF2 on Jetty gives randomly 'zip file closed' but works when running from maven jetty plugin (jetty:run)

my JSF web app is giving randomly error: "zip file closed" when accessing files (like images, css, js). It is deployed on Jetty 7. It looks like some of those files are not loaded (some images are missing on a page).
java.lang.IllegalStateException: zip file closed
at java.util.zip.ZipFile.ensureOpen(ZipFile.java:403)
at java.util.zip.ZipFile.entries(ZipFile.java:298)
at java.util.jar.JarFile.entries(JarFile.java:217)
at org.eclipse.jetty.util.resource.JarFileResource.list(JarFileResource.java:261)
at org.eclipse.jetty.util.resource.ResourceCollection.list(ResourceCollection.java:421)
at org.eclipse.jetty.util.resource.Resource.getListHTML(Resource.java:509)
at org.eclipse.jetty.servlet.DefaultServlet.sendDirectory(DefaultServlet.java:741)
at org.eclipse.jetty.servlet.DefaultServlet.doGet(DefaultServlet.java:564)
When I run it from maven plugin (7.x) with jetty:run or jetty:run-war then I do not get any error.
What's more, accessing root path of web context gives that "zip file closed" error only when running on standalone jetty, but no such error when running from maven pluging, then is those directory view.
My 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>/faces/*</url-pattern>
</servlet-mapping>
pom.xml:
....
<dependencies>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
....
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.5.1.v20110908</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.3</version>
</dependency>
</dependencies>
</plugin>
Any idea what could it be?
This issue has been fixed in jetty-7.6.0.RC2. The bug is caused by the JVM caching jar url connection streams.
According to the bug report, you will need to also add the following to the jetty.xml:
<Set class="org.eclipse.jetty.util.resource.Resource" name="defaultUseCaches">false</Set>
Jetty looks for your resources in the jar files in WEB-INF/lib. When it searches jsf-impl.jar it is somehow closed, probably by a JSF request. Perhaps jsf does its own resource handling and messes about with the files itself.
Anyway, the solution seems to be to move the jsf jars out of the war-file. Set your jsf dependency scope to provided so maven does not package them in the war file, and get them on the server, probably in the lib folder in jetty standalone.
I had the same issue and managed to solve it by going to etc\webdefault.xml and changing this param to false:
<init-param>
<param-name>gzip</param-name>
<param-value>true</param-value>
</init-param>

Resources