[GLASSFISH-17218] Incorrect log message regarding which version of Mojarra is actually being run. Created: 22/Aug/11  Updated: 12/Jun/13

Status: In Progress
Project: glassfish
Component/s: web_container
Affects Version/s: 3.1.1
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Ed Burns Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: 5 days
Time Spent: Not Specified
Original Estimate: 5 days

Attachments: Text File 20110825-GLASSFISH-17218-grep.txt     Text File 20130612-i_gf_17218.patch     File helloDuke-jsf-1_2-B.war     File i_glassfish_17218_mojarra_1_2_war.war     File i_glassfish_17218_mojarra_1_2_war.war     File i_glassfish_17218_myfaces_1_2_war.war     File i_glassfish_17218_myfaces_1_2_war.war     Text File message.txt     Zip Archive mojarra-1_2_15-src.zip    
Issue Links:
Dependency
depends on GLASSFISH-17231 WebappClassloader#getResourceAsStream... Resolved

 Description   

If you use the useBundledJsf="false" property to force a version of Mojarra (packaged in WEB-INF/lib) other than the one built in to the container to be used, static variables will come from the container version and not the version bundled in WEB-INF/lib.

One manifestation of this problem is that log messages will be the messages from the container-bundled Mojarra when they should be coming from the WEB-INF/lib-bundled Mojarra. I expect there are other problems as well.



 Comments   
Comment by Ed Burns [ 22/Aug/11 ]

server.log tail. Note that there is no invocation of any com.sun.faces classes.

helloDuke-jsf-1_2.war

this is the helloDuke sample instrumented with the appropriate sun-web.xml.

Comment by Ed Burns [ 22/Aug/11 ]

I observe another very strange phenomenon.

With a far more complicated app, I include the same text as the WEB-INF/sun-web.xml:

8<--------------------------
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">

<sun-web-app>
<class-loader delegate="false"/>
<property name="useBundledJsf" value="true" />
</sun-web-app>
8<-----------------------------

and it does deploy successfully to GlassFish 3.1.1 final. The app is at <http://javaweb.us.oracle.com/~edburns/adf-richclient-demo-includes-jsf12-WORKING1.war>. I am able to set breakpoints in the Mojarra JSF 1.2_15 source code, in the ConfigureListener, and it is indeed getting hit and the breakpoints are lining up correctly. However, the log message at the console is misleading. The log message says:

[#|2011-08-22T08:49:51.791-0700|INFO|glassfish3.1.1|javax.enterprise.resource.webcontainer.jsf.config|_ThreadID=17;_ThreadName=Thread-2;|Initializing Mojarra 2.1.3 (FCS b02) for context '/adf-richclient-demo-includes-jsf12-WORKING1'|#]

But it is indeed the 1.2 implementation that is producing this log message.

I believe this is because the LogStrings.properties file corresponding to Mojarra 2.1.3 is getting loaded ahead of the one from Mojarra 1.2_15. As you would expect the key corresponding to this log message is the same in both cases, but the value differs.

In Mojarra 1.2_15, the entry reads:

jsf.config.listener.version=Initializing Mojarra (1.2_15-20100816-SNAPSHOT) for context ''

{0}''

And in Mojarra 2.1.3, the entry reads:

jsf.config.listener.version=Initializing Mojarra 2.1.3 (FCS b02) for context ''{0}

''

As you can see, the 2.1.3 version of the properties file appears to be picked up.

Ed

Comment by Ed Burns [ 22/Aug/11 ]

This app actually does have Mojarra 1.2_15 bundled in it. It deploys successfully, but I still see an incorrect version identifier, indicating some classloading problem.

Comment by Ed Burns [ 22/Aug/11 ]

Source from jsf 1.2_15.

Comment by Shing Wai Chan [ 22/Aug/11 ]

This is due to a bug in WebappClassLoader#getResourceAsStream when useBundledJsf = true. I have a fix locally in my workspace. Need to do more testing.

Comment by Ed Burns [ 23/Aug/11 ]

helloDuke with bundled MyFaces.

Comment by Ed Burns [ 23/Aug/11 ]

helloDuke with bundled Mojarra 1.2_15

Comment by Ed Burns [ 23/Aug/11 ]

Committed to mojarra trunk:

Adding jsf-test/GLASSFISH-17218
Adding jsf-test/GLASSFISH-17218/build.xml
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/pom.xml
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/java
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/java/helloDuke
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/java/helloDuke/UserNameBean.java
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/webapp
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/webapp/WEB-INF
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/webapp/WEB-INF/faces-config.xml
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/webapp/WEB-INF/sun-web.xml
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/webapp/WEB-INF/web.xml
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/webapp/error.jsp
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/webapp/greeting.jsp
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/webapp/index.html
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/webapp/response.jsp
Adding (bin) jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/webapp/wave.med.gif
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/pom.xml
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/java
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/java/helloDuke
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/java/helloDuke/UserNameBean.java
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/webapp
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/webapp/WEB-INF
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/webapp/WEB-INF/faces-config.xml
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/webapp/WEB-INF/sun-web.xml
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/webapp/WEB-INF/web.xml
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/webapp/error.jsp
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/webapp/greeting.jsp
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/webapp/index.html
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/webapp/response.jsp
Adding (bin) jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/webapp/wave.med.gif
Transmitting file data .....................
Committed revision 9282.

Comment by Ed Burns [ 23/Aug/11 ]

Committed automated test to mojarra trunk.

Currently the test fails in overriding built in mojarra with mojarra 1.2_15, but it should pass when Shing Wai fixes the bug.

Sending jsf-test/GLASSFISH-17218/build.xml
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_htmlunit
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_htmlunit/pom.xml
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_htmlunit/src
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_htmlunit/src/main
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_htmlunit/src/main/java
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_htmlunit/src/main/java/com
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_htmlunit/src/main/java/com/sun
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_htmlunit/src/main/java/com/sun/faces
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_htmlunit/src/main/java/com/sun/faces/regression
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_htmlunit/src/main/java/com/sun/faces/regression/i_glassfish_17218_htmlunit
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_htmlunit/src/main/java/com/sun/faces/regression/i_glassfish_17218_htmlunit/IssueGLASSFISH_17218MojarraTestCase.java
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_htmlunit/src/main/java/com/sun/faces/regression/i_glassfish_17218_htmlunit/IssueGLASSFISH_17218MyFacesTestCase.java
Adding jsf-test/GLASSFISH-17218/i_glassfish_17218_htmlunit/src/main/resources
Sending jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/pom.xml
Sending jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/java/helloDuke/UserNameBean.java
Sending jsf-test/GLASSFISH-17218/i_glassfish_17218_mojarra_1_2_war/src/main/webapp/response.jsp
Sending jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/java/helloDuke/UserNameBean.java
Sending jsf-test/GLASSFISH-17218/i_glassfish_17218_myfaces_1_2_war/src/main/webapp/response.jsp
Sending jsf-test/build.xml
Transmitting file data ..........
Committed revision 9283.

Comment by Ed Burns [ 23/Aug/11 ]

Updated test apps that assert the implementation vendor and implementation version of the JSF used.

Comment by Shing Wai Chan [ 23/Aug/11 ]

With the fix in GLASSFISH-17231, it will always picked up the error messages from the first loaded jsf jars.
This is due to the face that the logger in jsf are static variable which will not be loaded again even though a new com.sun.faces.config.ConfigureListener is created.

Assign to Jsf team as the remaining change should be in Mojarra.

Comment by Ed Burns [ 25/Aug/11 ]

An undocumented, but occasionally vital feature of GlassFish is the ability to force the container to use a bundled Jsf implementation instead of the one provided by the container as a part of its JavaEE compatibility.

This feature is in direct opposition to the text at <http://download.oracle.com/docs/cd/E19798-01/821-1752/beagb/index.html>:

For a number of packages, including java.* and javax.*, symbol resolution is always delegated to the
parent class loader regardless of the delegate setting. This prevents applications from overriding core
Java runtime classes or changing the API versions of specifications that are part of the Java EE platform.

Nonetheless, we have implemented the feature and it did work in the past.

The feature is activating by including a WEB-INF/sun-web.xml like this:

8<-----------------------------
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">

<sun-web-app>
<class-loader delegate="false"/>
<property name="useBundledJsf" value="true" />
</sun-web-app>
8<-------------------------------

Comment by Ed Burns [ 25/Aug/11 ]

Output from this command on the mojarra source tree.

find jsf-api/src/main/java jsf-ri/src/main/java jsf-tools/src/main/java name .svn -prune -o -name build -prune -o -name target -prune -o -name ".class" -prune -o -name ".jar" -prune -o -name "*.java" -exec grep "static" {} \; -print | grep -v "(" | grep -v String > 20110825GLASSFISH-17218-grep.txt

Comment by yoxu [ 28/Sep/11 ]

I try to deploy a app that bundled JSF 2.1.3 jsf-api.jar and jsf-impl.jar in WAR. The
glassfish-web.xml specify <class-loader delegate="false"/>
<property name="useBundledJsf" value="true" />. When deploy it in asadmin console,
it always fail with following class cast issue. If i set property useBundledJsf to
false, it deploys OK.

java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! org.glassfish.weld.jsf.WeldFacesConfigProvider cannot be cast to com.sun.faces.spi.ConfigurationResourceProvider
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:138)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:619)

Comment by justinas [ 09/Dec/12 ]

Glassfish 3.1.2 Also seems to be affected.

glassfish-web.xml(sun-web.xml not present):
<class-loader delegate="false"/>
<property name="useBundledJsf" value="true"/>

Added mojarra 2.1.15 to my applibs

INFO: Initializing Mojarra 2.1.15 ( 20121116-1710 https://svn.java.net/svn/mojarra~svn/tags/2.1.15@11020) for context '/varzhtc'
SEVERE: Critical error during deployment:
com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! org.glassfish.weld.jsf.WeldFacesConfigProvider cannot be cast to com.sun.faces.spi.ConfigurationResourceProvider
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:376)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:223)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4750)
at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:550)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5366)
at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2019)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:301)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:353)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at org.glassfish.deployment.admin.ReDeployCommand.execute(ReDeployCommand.java:126)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.lang.ClassCastException: org.glassfish.weld.jsf.WeldFacesConfigProvider cannot be cast to com.sun.faces.spi.ConfigurationResourceProvider
at com.sun.faces.spi.ConfigurationResourceProviderFactory.createProviders(ConfigurationResourceProviderFactory.java:92)
at com.sun.faces.config.ConfigManager.getConfigurationResourceProviders(ConfigManager.java:470)
at com.sun.faces.config.ConfigManager.getFacesConfigResourceProviders(ConfigManager.java:453)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:323)
... 50 more

Comment by Ed Burns [ 29/May/13 ]

If you have a patch for this, we'd love to have it!

Generated at Thu Jul 28 21:02:57 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.