0

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>
halfer
  • 19,824
  • 17
  • 99
  • 186
UserB
  • 25
  • 5

1 Answers1

0

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).
lepsch
  • 8,927
  • 5
  • 24
  • 44
tandraschko
  • 2,291
  • 13
  • 13
  • Firstly, thank you for your response. I thought about it but I wasn't sure if it would help address my present issue. Anyway, I'll attempt to do this patch version upgrade 2.0.20 --> 2.0.24 and post the result here. – UserB Jun 27 '22 at 07:06
  • you can even try 2.3.x - there is actually no reason to stay on 2.0 – tandraschko Jun 27 '22 at 08:21
  • 1. So, based on your suggestion, I upgraded the 2 myfaces-* jars from 2.0.0 to 2.0.25 & 4 openwebbeans-* jars from 2.0.20 to 2.0.27 in Tomcat\lib. Interestingly, the exception has evolved as follows: 27-Jun-2022 16:53:00.957 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) ... As I decompile the jar, any thoughts on this interesting development, @tandraschko? – UserB Jun 27 '22 at 12:27
  • 2. Regarding your other suggestion of upgrading to 2.3.x directly instead, is JSF 2.3.x backward compatible with my seemingly MyFaces 2.0 webapp? If yes, apart from the 2 myfaces-* jars & 4 openwebbeans-* jars, are there other dependencies that need to be upgraded as well, @tandraschko? – UserB Jun 27 '22 at 13:03
  • Update to #1 above. The line "return elAdaptor.getOwbWrappedExpressionFactory(expressionFactory);" in method wrapExpressionFactory() of the OWB implementation throws an NPE. Is this helpful? BTW, after upgrading the patch versions of MyFaces & OWB, I'd to add the dependency commons-codec-1.10.jar to Tomcat's lib (though already part of webapp\lib) before encountering the latest NPE. – UserB Jun 27 '22 at 14:42
  • AFAIR a 2.0 application should work perfectly fine on 2.3. Just try it :) 2.0 is very old, not sure if it works OOTB with such new OWB versions and so on. Normally you dont need to add commons-* manually, its a transitive dependency of MF – tandraschko Jun 28 '22 at 06:07
  • Sure. :) I'll upgrade the 2 MyFaces jars alone from 2.0.0 to 2.3.10 and share my findings. Thanks for the inputs, @tandraschko. – UserB Jun 28 '22 at 06:15
  • Another quick question. I only have the newly added OWB listener, WebBeansConfigurationListener, in web.xml (kindly view the updated problem summary above for more details). Is that normal? – UserB Jun 28 '22 at 06:18
  • you also need the myfaces listener AFTER the OWB listener. here you can find a sample project with OWB, working with mojarra and myfaces. if you do a mvn package with the right profile, can you also deploy it on tomcat: https://github.com/primefaces/primefaces-test/ – tandraschko Jun 28 '22 at 06:33
  • Update to #2 above. I upgraded the 2 MyFaces jars from 2.0.0 to 2.3.10 and Catalina threw an error saying `No Spring WebApplicationInitializer types detected on classpath` and so, as you'd suggested, I added `StartupServletContextListener` in web.xml (please see updated web.xml above). Finally, I landed on the same exception thrown during the previous attempt at migrating MyFaces from 2.0.0 to 2.0.25 (kindly see updated problem summary above). As I explore primefaces-test, am I missing something here, @tandraschko? – UserB Jun 28 '22 at 07:36
  • i would cleanup your dependencies; you dont need el-api in your project - or use scope provided. Just check our sample project linked above – tandraschko Jun 28 '22 at 09:06
  • a. Regarding `el-api`, I see `import javax.el.ELContext; import javax.el.ExpressionFactory;` in this legacy application. b. Sure, I'll start cleaning up the dependencies & eliminate scope `provided` based on primefaces-test, @tandraschko. – UserB Jun 28 '22 at 09:20
  • 3. After matching both web.xml & pom.xml with those of primefaces-test (I also added 13 dependent jars manually to WEB-INF\lib), there are no further exceptions (please see updated summary for the full details). However, when I launch the app on the browser, errors/exceptions are being thrown which are not very helpful but not related to this thread (kindly see updated summary above). Can you please review and share your final thoughts before I accept your answer, @tandraschko? – UserB Jun 29 '22 at 18:02
  • It would be helpful if this answer were edited to include a summary of the solutions proposed in this comment thread – Ryan M Jul 08 '22 at 00:53
  • I'll do just that, thank you, @RyanM. – UserB Jul 08 '22 at 04:20