Myfaces ServletContext 'null' 已初始化

Myfaces ServletContext 'null' initialized

我正在将应用程序从 websphere 8.5.5.x 环境迁移到 liberty 20.0.0.3。除了 JSF 部分,我大部分都在工作。初始化有问题,我不知道它是什么,也不知道如何调试它。由于这个库是由 liberty 提供的,我不能只设置断点进行调试。

我可以给出以下比较

Websphere

[3/04/20 12:42:32:848 CEST] 00000081 DefaultFacesC I   Reading standard config META-INF/standard-faces-config.xml
[3/04/20 12:42:32:961 CEST] 00000081 DefaultFacesC I   Reading config /WEB-INF/faces-config.xml
[3/04/20 12:42:35:590 CEST] 00000081 DefaultFacesC I   Reading config : wsjar:file:/C:/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/WDL0000002Node01Cell/identiteiten-rollen-web-ear_ear.ear/identiteiten-rollen-war.war/WEB-INF/lib/primefaces-5.0.jar!/META-INF/faces-config.xml
[3/04/20 12:42:35:903 CEST] 00000081 ApplicationIm I   Couldn't discover the current project stage, using Production
[3/04/20 12:42:35:903 CEST] 00000081 FacesConfigur I   Serialization provider : class org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory
[3/04/20 12:42:35:904 CEST] 00000081 AbstractFaces I   ServletContext 'C:\IBM\WebSphere\AppServer\profiles\AppSrv01\installedApps\WDL0000002Node01Cell\identiteiten-rollen-web-ear_ear.ear\identiteiten-rollen-war.war' initialized.
[3/04/20 12:42:35:906 CEST] 00000081 PostConstruct I   Running on PrimeFaces 5.0

自由

[3/04/20 12:32:38:839 CEST] 0000002c org.apache.myfaces.config.DefaultFacesConfigurationProvider  I Reading standard config META-INF/standard-faces-config.xml
[3/04/20 12:32:38:941 CEST] 0000002c org.apache.myfaces.config.DefaultFacesConfigurationProvider  I Reading config /WEB-INF/faces-config.xml
[3/04/20 12:32:39:157 CEST] 0000002c org.apache.myfaces.config.DefaultFacesConfigurationProvider  I Reading config : jar:file:/C:/Liberty/identiteiten-rollen-web-ear/wlp/usr/servers/wlp-identiteiten-rollen-web/workarea/org.eclipse.osgi/57/data/cache/com.ibm.ws.app.manager_77/.cache/.cache/identiteiten-rollen-war.war/WEB-INF/lib/primefaces-5.0.jar!/META-INF/faces-config.xml
[3/04/20 12:32:39:167 CEST] 0000002c org.apache.myfaces.config.DefaultFacesConfigurationProvider  I Reading config : jar:file:/C:/Liberty/identiteiten-rollen-web-ear/wlp/usr/servers/wlp-identiteiten-rollen-web/workarea/org.eclipse.osgi/57/data/cache/com.ibm.ws.app.manager_77/.cache/.cache/identiteiten-rollen-war.war/WEB-INF/lib/primefaces-5.0.jar!/META-INF/faces-config.xml
[3/04/20 12:32:39:575 CEST] 0000002c org.apache.myfaces.application.ApplicationImpl               I Couldn't discover the current project stage, using Production
[3/04/20 12:32:39:576 CEST] 0000002c org.apache.myfaces.config.FacesConfigurator                  I Serialization provider : class org.apache.myfaces.shared_impl.util.serial.DefaultSerialFactory
[3/04/20 12:32:39:609 CEST] 0000002c org.apache.myfaces.webapp.AbstractFacesInitializer           I ServletContext 'null' initialized.
[3/04/20 12:32:39:612 CEST] 0000002c org.primefaces.webapp.PostConstructApplicationEventListener  I Running on PrimeFaces 5.0
[3/04/20 12:32:39:612 CEST] 0000002c org.primefaces.webapp.PostConstructApplicationEventListener  I Running on PrimeFaces 5.0

首先奇怪的是他在 liberty 设置上做了两次,第二件事是 ServletContext 是 'null'。

也许我在 web.xml 中遗漏了一个设置,或者 faces-config.xml 是错误的。我不确定,websphere 可能比 liberty 更宽松一些,并为我修复了一些东西。

有没有人有加载 myfaces 的经验?

更新信息

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<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"
        id="identiteitenRollenWarId" 
        version="3.0" >
    <display-name>identiteiten-rollen-war</display-name>

    <context-param>  
        <param-name>primefaces.THEME</param-name>  
        <param-value>b2e</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>
        <description>
            The location where state information is saved.
            Valid values are 'server' (typically saved in HttpSession) and 'client' (typically
            saved as a hidden field in the form.
            Default is server.
        </description>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <!-- krijg hier altijd warning voor:  /WEB-INF/faces-config.xml has been specified in the javax.faces.CONFIG_FILES context parameter of the deployment descriptor. This will automatically be removed, if we wouldn't do this, it would be loaded twice.  See JSF spec 1.1, 10.3.2 
    <context-param>
        <description>
            Comma-delimited list of context-relative resource paths under which the JSF implementation
            will look for application configuration resources, before loading a configuration resource
            named /WEB-INF/faces-config.xml (if such a resource exists).
        </description>
        <param-name>javax.faces.CONFIG_FILES</param-name>
        <param-value>/WEB-INF/faces-config.xml</param-value>
    </context-param>
     -->    
    <context-param>
        <description>
            The default suffix for extension-mapped resources that contain JSF components.
            Default is '.jsp'.
        </description>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>    
    <context-param>
        <description>
            Monitors Faces JSP files for modifications and synchronizes a running server with
            the changes without restarting the server. If this parameter is set to false or
            removed from the deployment descriptor, any changes made to Faces JSP files may
            not be seen by the server until it is restarted. This parameter is usually set
            to true while the Faces JSP files are being developed and debugged in order to
            improve the performance of the development environment.
        </description>
        <param-name>com.ibm.ws.jsf.JSP_UPDATE_CHECK</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>
            Load JSF runtime when the application server starts up. If this parameter is set to false or removed,
            JSF runtime will be loaded and initialized when the first JSF request is processed.
            This may disable custom JSF extensions, such as factories defined in the project.
        </description>
        <param-name>com.ibm.ws.jsf.LOAD_FACES_CONFIG_AT_STARTUP</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>facelets.LIBRARIES</param-name>
        <param-value>/WEB-INF/retibo-taglib.xml</param-value>
    </context-param>
    <context-param>
        <param-name>facelets.SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>

    <filter>
        <filter-name>UserFilter</filter-name>
        <filter-class>be.delijn.retibo.identiteitenrollen.common.view.filter.IdentiteitenUserFilter</filter-class>
    </filter>
    <filter>
        <filter-name>Log4JAdminFilter</filter-name>
        <filter-class>be.delijn.retibo.view.filter.Log4JAdminFilter</filter-class>
    </filter>
    <filter>
        <filter-name>IE9Filter</filter-name>
        <filter-class>be.delijn.retibo.view.filter.IE9Filter</filter-class>
    </filter>
    <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>
    <filter-mapping>
        <filter-name>IE9Filter</filter-name>
        <url-pattern>*.faces</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>Log4JAdminFilter</filter-name>
        <url-pattern>/pages/log4jAdmin.jsp</url-pattern>
    </filter-mapping>
    <filter-mapping>
        <filter-name>UserFilter</filter-name>
        <url-pattern>*.faces</url-pattern>
    </filter-mapping>   

    <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>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>  

    <welcome-file-list>
        <welcome-file>/index.jsp</welcome-file>
    </welcome-file-list>

    <security-constraint>
        <display-name>securityConstraint</display-name>
        <web-resource-collection>
            <web-resource-name>AllesBeveiligd</web-resource-name>
            <description>Alle beveiligde pagina's</description>
            <url-pattern>/pages/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <description/>
            <role-name>MedewerkerPersoneel</role-name>
        </auth-constraint>
    </security-constraint>
    <login-config>
        <auth-method>FORM</auth-method>
        <form-login-config>
            <form-login-page>/login.faces</form-login-page>
            <form-error-page>/login.faces?error=true</form-error-page>
        </form-login-config>
    </login-config>
    <security-role>
        <description/>
        <role-name>MedewerkerPersoneel</role-name>
    </security-role>

    <servlet>
        <servlet-name>Happy Servlet</servlet-name>
        <servlet-class>be.delijn.retibo.identiteitenrollen.common.view.IamHappyServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Happy Servlet</servlet-name>
        <url-pattern>happy*</url-pattern>
    </servlet-mapping>

    <resource-ref>
        <description />
        <res-ref-name>identiteitenDataSource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Application</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    <resource-ref>
        <res-ref-name>log4j_identiteiten_rollen</res-ref-name>
        <res-type>java.net.URL</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
    <resource-ref>
        <description />
        <res-ref-name>url/biztalkRolToekenningMeldingServiceHost</res-ref-name>
        <res-type>java.net.URL</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    <resource-ref>
        <description />
        <res-ref-name>identiteitenCacheConfig</res-ref-name>
        <res-type>java.net.URL</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>

    <resource-env-ref>
        <description>identiteiten_rollen_webservices</description>
        <resource-env-ref-name>properties/identiteiten_rollen_webservices</resource-env-ref-name>
        <resource-env-ref-type>java.util.Properties</resource-env-ref-type>
    </resource-env-ref>

    <resource-env-ref>
        <description>identiteiten_rollen_webservices 2</description>
        <resource-env-ref-name>properties/webservices</resource-env-ref-name>
        <resource-env-ref-type>java.util.Properties</resource-env-ref-type>
    </resource-env-ref>

    <resource-env-ref>
        <description>properties voor ldapB2E</description>
        <resource-env-ref-name>properties/ldapB2E</resource-env-ref-name>
        <resource-env-ref-type>java.util.Properties</resource-env-ref-type>
    </resource-env-ref>

    <resource-env-ref>
        <description>properties voor identiteiten_rollen</description>
        <resource-env-ref-name>properties/identiteiten_rollen</resource-env-ref-name>
        <resource-env-ref-type>java.util.Properties</resource-env-ref-type>
    </resource-env-ref>

    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/expired.faces</location>
    </error-page>

    <error-page>
        <error-code>403</error-code>
        <location>/onvoldoendeRechten.faces</location>
    </error-page>

</web-app>

server.xml

<?xml version="1.0" encoding="UTF-8"?><!--Generated by IBM TransformationAdvisor
Thu Mar 07 10:07:55 UTC 2019-->
<server>
    <!--These elements have been identified from this application's configuration.-->
    <featureManager>
        <feature>cdi-1.0</feature>
        <feature>ejbLite-3.1</feature>
        <feature>jdbc-4.0</feature>
        <feature>jndi-1.0</feature>
        <feature>jpa-2.0</feature>
        <feature>localConnector-1.0</feature>
        <feature>ssl-1.0</feature>
        <feature>transportSecurity-1.0</feature>
        <feature>jaxrs-1.1</feature>
        <feature>jaxws-2.2</feature>
        <feature>javaMail-1.5</feature>
        <feature>jsf-2.0</feature>
    </featureManager>

    <basicRegistry id="basic" realm="ibm/api">
        <user name="wasadmin" password="wasadmin"/>
    </basicRegistry>

    <library id="sqlserverJdbcLib">
        <fileset dir="${server.config.dir}/resources/lib/sqlserverJdbc" includes="sqljdbc4-4.0.jar" />
    </library>

    <dataSource id="jdbcIdentiteitenRollen"
            jndiName="jdbc/identiteiten_2"
            type="javax.sql.ConnectionPoolDataSource"
            isolationLevel="TRANSACTION_READ_COMMITTED">
        <connectionManager maxPoolSize="10" minPoolSize="0" />
        <jdbcDriver libraryRef="sqlserverJdbcLib" />
        <properties.microsoft.sqlserver
                serverName="${datasource.server.name}"
                portNumber="${datasource.server.port}"
                databaseName="${datasource.database.name}"
                user="${datasource.user}"
                password="${datasource.password}" />
    </dataSource>
    <transaction totalTranLifetimeTimeout="3000s" />

    <library id="propertyProviderLib">
        <fileset dir="${server.config.dir}/resources/lib/propertyProvider" includes="property-provider-1.1.jar"/>
    </library>

    <jndiObjectFactory
            id="propertyProvider"
            libraryRef="propertyProviderLib"
            className="be.delijn.propertyprovider.ResourceFactory"
            objectClassName="java.util.Properties"/>

    <jndiReferenceEntry id="propertiesIdentiteitenRollen" jndiName="properties/identiteiten_rollen"
                        factoryRef="propertyProvider">
        <properties mobielplatform.applicatie.id="${mobielplatform.applicatie.id}"/>
        <properties identiteiten.exploitantensync.instructies.maximum="${identiteiten.exploitantensync.instructies.maximum}"/>
        <properties identiteiten.applicatie.id="${identiteiten.applicatie.id}"/>
        <properties identiteiten.sync.mail.to="${identiteiten.sync.mail.to}"/>
        <properties identiteiten.sync.mail.from="${identiteiten.sync.mail.from}"/>
        <properties base.distinguishedName="${base.distinguishedName}"/>
        <properties ldapUser="${ldapUser}"/>
        <properties ldapPassword="${ldapPassword}"/>
        <properties job.timelimit="${job.timelimit}"/>
        <properties scheduling.rolRelatiesPush="${scheduling.rolRelatiesPush}"/>
        <properties scheduling.dataValidatie="${scheduling.dataValidatie}"/>
        <properties scheduling.rolRelatiesPrepare="${scheduling.rolRelatiesPrepare}"/>
        <properties scheduling.ruleEngine="${scheduling.ruleEngine}"/>
        <properties scheduling.personeelSynchronisatie="${scheduling.personeelSynchronisatie}"/>
        <properties scheduling.activeDirectorySynchronisatie="${scheduling.activeDirectorySynchronisatie}"/>
    </jndiReferenceEntry>

    <jndiReferenceEntry id="propertiesWebservices" jndiName="properties/identiteiten_rollen_webservices" factoryRef="propertyProvider">
        <properties biztalk.username="${biztalk.username}"/>
        <properties biztalk.password="${biztalk.password}"/>
        <properties rolToekenningMeldingService.url="${rolToekenningMeldingService.url}"/>
    </jndiReferenceEntry>

    <jndiReferenceEntry id="propertiesLdap" jndiName="properties/ldapB2E" factoryRef="propertyProvider">
        <properties protocol="${protocol}"/>
        <properties server="${server}"/>
        <properties port="${port}"/>
        <properties ldapPassword="${ldapPassword}"/>
        <properties ldapUser="${ldapUser}"/>
        <properties base.distinguishedName="${base.distinguishedName}"/>
    </jndiReferenceEntry>

    <jndiURLEntry jndiName="url/log4j_identiteiten_rollen_2_web" value="${log.log4j.location}"/>
    <jndiURLEntry jndiName="url/identiteitenCacheConfig" value="${url.cache.config}"/>
    <jndiURLEntry jndiName="url/biztalkRolToekenningMeldingServiceHost" value="${url.biztalkRolToekenningMeldingServiceHost}"/>

    <mailSession description="De Lijn SMTP" from="" host="${smtp.host}"
            id="mailSession" jndiName="mail/Session" mailSessionID="IdentiteitenMailSession"
            password="" user=""/>

    <httpEndpoint host="*" httpPort="9081" httpsPort="9444" id="defaultHttpEndpoint"/>

    <classloading useJarUrls="true"/>

    <application id="identiteiten-rollen-web-ear" location="identiteiten-rollen-web-ear.ear" name="identiteiten_rollen_web_ear"
                 type="ear">
        <classloader apiTypeVisibility="spec, ibm-api, stable, third-party" libraryRef="propertyProviderLib"/>
    </application>
</server>

ServletContext 'null' initialized 消息是由一个较旧的 MyFaces 错误引起的:MYFACES-3356。不幸的是,Liberty jsf-2.0 实现似乎没有该修复 - 值得向 IBM 开具支持票。

作为解决方法,如果它适用于您的应用程序,您可以通过 <applicationManager autoExpand="true"/>

在 server.xml 中启用应用程序扩展

因此,在与同事合作后,我们发现了 JSF 无法呈现的问题。好吧,我们希望这是我必须附加的正确解决方案

<feature>webProfile-6.0</feature>

到功能堆栈,突然间 JSF 活了过来。我们还尝试删除它,然后只添加

<feature>managedBeans-1.0</feature>

但这还不够,所以我们决定只保留网络配置文件,即使它引入了我们可能不需要的更多功能