[jboss-jira] [JBoss JIRA] (WFLY-3234) Wrong JSF class loaded in third dependencies
jaikiran pai (JIRA)
issues at jboss.org
Wed Apr 9 02:48:13 EDT 2014
[ https://issues.jboss.org/browse/WFLY-3234?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12960379#comment-12960379 ]
jaikiran pai commented on WFLY-3234:
------------------------------------
Hi Janario,
This doesn't have anything to do with the runtime loading of classes. As noted by you, the web-util Maven project relies on:
{code}
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
{code}
The FaceletContext.FACELET_CONTEXT_KEY is a compile time constant, so when your LoaderContext.java gets compiled the compiler does an inline replacement in the getContextKeyMethod and places com.sun.faces.facelets.FACELET_CONTEXT as the value (since that's what is being used in your project dependency).
On the other hand, you are compiling the web-test war project against the 7.0 version of the library which as a result does an inline replacement of the latest value.
You can take a look at the compiled classes yourself using the javap -c command which shows the output like below for the LoaderContext class:
{code}
javap -c br.com.janario.LoaderContext
....
public static java.lang.String getFaceletContextKey();
Code:
0: ldc #2; //String com.sun.faces.facelets.FACELET_CONTEXT
2: areturn
....
{code}
> Wrong JSF class loaded in third dependencies
> --------------------------------------------
>
> Key: WFLY-3234
> URL: https://issues.jboss.org/browse/WFLY-3234
> Project: WildFly
> Issue Type: Bug
> Security Level: Public(Everyone can see)
> Components: JSF
> Affects Versions: 8.0.0.Final, 8.0.1.Final
> Environment: WildFly 8.0.0.Final or 8.0.1.Final-SNAPSHOT (20140408)
> Reporter: Janario Oliveira
> Assignee: Farah Juma
> Priority: Critical
> Labels: jsf22
> Attachments: web-test-war-src.zip, web-util-jar-src.zip
>
>
> I have a web project, war, who use a third maven dependency which load java ee 6 dependency with provided scope:
> <dependency>
> <groupId>javax</groupId>
> <artifactId>javaee-web-api</artifactId>
> <version>6.0</version>
> <scope>provided</scope>
> </dependency>
> In runtime the third dependency tries to load a FaceletContext and to ensure compatibility it uses the constant from javax.faces.view.facelets.FaceletContext.FACELET_CONTEXT_KEY which fails because the constant returns the old constant from java ee 6 version, com.sun.faces.facelets.FACELET_CONTEXT instead of javax.faces.FACELET_CONTEXT from java ee 7.
> If I try the same code from a class in war project it loads the right constant and works.
> E.g.
> public FaceletContext getFaceletContext() {
> final FacesContext currentInstance = FacesContext.getCurrentInstance();
> return (FaceletContext) currentInstance.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
> //from third dependency "com.sun.faces.facelets.FACELET_CONTEXT"
> //from classes in war "javax.faces.FACELET_CONTEXT"
> }
> I've created it with critical priority because it broke compatibility with some jsf frameworks.
> Attached the project where I could simulate
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the jboss-jira
mailing list