Myfaces ServletContext ‘null’ 已初始化

huangapple go评论139阅读模式
英文:

Myfaces ServletContext 'null' initialized

问题

I'm migrating an application from a WebSphere 8.5.5.x environment to Liberty 20.0.0.3. I got most of it working except the JSF part. Something is wrong with the initialization and I can't figure out what it is nor how to debug it. Since this library is supplied by Liberty I can't just put breakpoints to debug.

I can give the following comparison

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

Liberty

[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

First thing that is strange he is doing it twice on the liberty setup, second thing is that the ServletContext is 'null'.

Maybe I'm missing a setting in web.xml or faces-config.xml is wrong. I'm not sure, WebSphere might be a bit more lenient than Liberty and fix some stuff for me.

Has anyone got any experience with loading MyFaces?

Updated info

web.xml

...

server.xml

...

英文:

I'm migrating an application from a websphere 8.5.5.x environment to liberty 20.0.0.3. I got most of it working except the JSF part. Something is wrong with the initialization and I can't figure out what it is nor how to debug it. Since this library is supplied by liberty I can't just put breakpoints to debug.

I can give the following comparison

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

Liberty

[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

First thing that is strange he is doing it twice on the liberty setup, second thing is that the ServletContext is 'null'.

Maybe I'm missing a setting in web.xml or faces-config.xml is wrong. I'm not sure, websphere might be a bit more lenient then liberty and fix some stuff for me.

Has anyone got any experience with loading myfaces ?

Updated info

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>

答案1

得分: 1

这个ServletContext 'null' initialized消息是由一个旧的MyFaces bug引起的:MYFACES-3356。不幸的是,Liberty jsf-2.0 实现似乎没有这个修复 - 建议向IBM开启一个支持工单可能是值得的。

作为一种解决方法,如果对您的应用程序可行,您可以通过在server.xml中使用<applicationManager autoExpand="true"/>来启用应用程序扩展。

英文:

This ServletContext &#39;null&#39; initialized message is caused by an older MyFaces bug: MYFACES-3356. Unfortunately the Liberty jsf-2.0 implementation doesn't appear to have that fix - it would be worthwhile to open a support ticket with IBM.

As a workaround, if it's workable for your app you can enable application expansion in your server.xml via &lt;applicationManager autoExpand=&quot;true&quot;/&gt;

答案2

得分: 0

所以在与同事合作后,我们发现了 JSF 未能渲染的问题。希望这是正确的解决方案,我不得不将以下内容追加到功能堆栈中:

<feature>webProfile-6.0</feature>

突然之间,JSF 就恢复正常了。我们还尝试将其移除,然后只添加以下内容:

<feature>managedBeans-1.0</feature>

但那还不够,所以我们决定保持 WebProfile,即使它会引入一些我们可能不需要的额外功能。

英文:

So after collaborating with a co worker we found the issue why JSF wasn't rendering. Well we hope it's the right solution I had to append

&lt;feature&gt;webProfile-6.0&lt;/feature&gt;

to the feature stack, and all of the sudden JSF came to life. We also tried removing it and then just adding

&lt;feature&gt;managedBeans-1.0&lt;/feature&gt;

but that wasn't enough, so we settled on just keeping the webprofile even if it pulls in some more features we might not need

huangapple
  • 本文由 发表于 2020年4月3日 21:04:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/61012573.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定