How can I update Websphere 7 to use EL2.2?

2019-07-20 04:42发布

问题:

This is what I have done:

  1. Following this post from Lincoln Baxter I downloaded el-api-2.2.jar and el-impl-2.2.jar
  2. Then created isolated shard library and added them there.
  3. We are using Myfaces so in web.xml added this bit

    <context-param> <param-name>org.apache.myfaces.EXPRESSION_FACTORY</param-name> <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
    </context-param>

This is the issue:

I do not think it getting picked up and application is still using one out the the box apache based.

Caused by: javax.el.ELException: Error Parsing: #{testBean.testel2('hello')}
    at org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:129)
    at org.apache.el.lang.ExpressionBuilder.build(ExpressionBuilder.java:150)
    at org.apache.el.lang.ExpressionBuilder.createMethodExpression(ExpressionBuilder.java:201)
    at org.apache.el.ExpressionFactoryImpl.createMethodExpression(ExpressionFactoryImpl.java:56)
    at org.apache.myfaces.view.facelets.tag.TagAttributeImpl.getMethodExpression(TagAttributeImpl.java:219)
    at org.apache.myfaces.view.facelets.tag.jsf.ActionSourceRule$ActionMapper2.applyMetadata(ActionSourceRule.java:73)
    at org.apache.myfaces.view.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:45)
    at javax.faces.view.facelets.MetaTagHandler.setAttributes(MetaTagHandler.java:68)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.setAttributes(DelegatingMetaTagHandler.java:93)
    at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.setAttributes(BehaviorsAddingComponentHandlerWrapper.java:115)
    at org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:269)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:54)
    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:51)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:59)
    at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:55)
    at org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:324)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:54)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.applyNextHandler(DelegatingMetaTagHandler.java:59)
    at org.richfaces.view.facelets.html.BehaviorsAddingComponentHandlerWrapper.applyNextHandler(BehaviorsAddingComponentHandlerWrapper.java:55)
    at org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate.apply(ComponentTagHandlerDelegate.java:324)
    at javax.faces.view.facelets.DelegatingMetaTagHandler.apply(DelegatingMetaTagHandler.java:54)
    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:51)
    at org.apache.myfaces.view.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:86)
    at org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:167)
    at org.apache.myfaces.view.facelets.impl.TemplateContextImpl$TemplateManagerImpl.apply(TemplateContextImpl.java:128)
    at org.apache.myfaces.view.facelets.impl.TemplateContextImpl.includeDefinition(TemplateContextImpl.java:92)
    at org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:433)
    at org.apache.myfaces.view.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:93)
    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:51)
    at org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:57)
    at javax.faces.view.facelets.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:51)
    at org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:45)
    at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:322)
    at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:369)
    at org.apache.myfaces.view.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:347)
    at org.apache.myfaces.view.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:215)
    at org.apache.myfaces.view.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:140)
    at org.apache.myfaces.view.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:57)
    at org.apache.myfaces.view.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:45)
    at org.apache.myfaces.view.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:143)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.buildView(FaceletViewDeclarationLanguage.java:363)
    at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:66)
    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:239)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:191)
    ... 31 more
Caused by: org.apache.el.parser.ParseException: Encountered "(" at line 1, column 26.
Was expecting one of:
    "}" ...
    "." ...
    "[" ...
    ">" ...
    "gt" ...
    "<" ...
    "lt" ...
    ">=" ...
    "ge" ...
    "<=" ...
    "le" ...
    "==" ...
    "eq" ...
    "!=" ...
    "ne" ...
    "&&" ...
    "and" ...
    "||" ...
    "or" ...
    "*" ...
    "+" ...
    "-" ...
    "/" ...
    "div" ...
    "%" ...
    "mod" ...

    at org.apache.el.parser.ELParser.generateParseException(ELParser.java:2142)
    at org.apache.el.parser.ELParser.jj_consume_token(ELParser.java:2024)
    at org.apache.el.parser.ELParser.DeferredExpression(ELParser.java:113)
    at org.apache.el.parser.ELParser.CompositeExpression(ELParser.java:40)
    at org.apache.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:97)

Update: I tried to use JBoss EL instead and I notice this line

[13/02/12 15:19:06:113 EST] 00000029 ExternalSpeci I   MyFaces Unified EL support disabled

in the log and that led me to this code

Copied from source of myfaces-impl-2.1.6

package org.apache.myfaces.util;

import java.util.logging.Level;
import java.util.logging.Logger;

import javax.el.ELContext;

/**
 * <p>
 * Utility class for determining which specifications are available
 * in the current process. See JIRA issue: http://issues.apache.org/jira/browse/MYFACES-2386
 * </p>
 *
 * @author Jan-Kees van Andel
 * @author Jakob Korherr (latest modification by $Author: lu4242 $)
 * @version $Revision: 963000 $ $Date: 2010-07-11 01:54:18 -0500 (Sun, 11 Jul 2010) $
 * @since 2.0
 */
public final class ExternalSpecifications
{

    //private static final Log log = LogFactory.getLog(BeanValidator.class);
    private static final Logger log = Logger.getLogger(ExternalSpecifications.class.getName());

    private static volatile Boolean beanValidationAvailable;
    private static volatile Boolean unifiedELAvailable;

   //Removed code from here before posting on Stack Overflow
   //Relevant method is below  

    /**
     * This method determines if Unified EL is present.
     *
     * Eager initialization is used for performance. This means Unified EL binaries
     * should not be added at runtime after this variable has been set.
     * @return true if UEL is available, false otherwise.
     */
    public static boolean isUnifiedELAvailable()
    {
        if (unifiedELAvailable == null)
        {
            try
            {
                // Check if the UEL classes are available.
                // If the JSP EL classes are loaded first, UEL will not work
                // properly, hence it will be disabled.
                unifiedELAvailable = (
                        Class.forName("javax.el.ValueReference") != null
                     && Class.forName("javax.el.ValueExpression")
                                .getMethod("getValueReference", ELContext.class) != null
                );
            }
            catch (Throwable t)
            {
                //log.log(Level.FINE, "Error loading class (could be normal)", t);
                unifiedELAvailable = false;
            }

            log.info("MyFaces Unified EL support " + (unifiedELAvailable ? "enabled" : "disabled"));
        }
        return unifiedELAvailable;
    }

    /**
     * this class should not be instantiated.
     */
    private ExternalSpecifications()
    {
    }

}

try block throws exception on both checks when inspecting and during executing as expected goes to catch and that results in a false being returned. I believe due to this it falls back to EL provided by WebSphere and not JBoss EL.