在 Oracle Weblogic 10.3.6 上部署的应用程序中使用 EL 2.2 不起作用?

Using EL 2.2 in an application deployed on Oracle Weblogic 10.3.6 isn't working?

我正在 运行宁 Weblogic 10.3.6 并尝试构建一个支持 JSF 2.2.8EL 2.2 和 [=18= 的新动态 Web 应用程序(在 eclipse 中) ],但不幸的是 EL 2.2 抛出异常。

weblogic.xml

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" 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_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.3/weblogic-web-app.xsd">
    <wls:weblogic-version>10.3.6</wls:weblogic-version>

    <wls:context-root>MyApp</wls:context-root>

    <wls:library-ref>
        <wls:library-name>jstl</wls:library-name>
        <wls:specification-version>1.2</wls:specification-version>
        <wls:exact-match>true</wls:exact-match>
    </wls:library-ref>

    <wls:container-descriptor>                  
        <wls:prefer-application-packages>
            <wls:package-name>com.sun.el.*</wls:package-name>
            <wls:package-name>javax.el.*</wls:package-name>     
            <wls:package-name>com.sun.faces.*</wls:package-name>
            <wls:package-name>javax.faces.*</wls:package-name>
        </wls:prefer-application-packages>
    </wls:container-descriptor>        
</wls:weblogic-web-app>


尝试 运行 一个在 EL

中调用参数化方法的页面抛出以下异常
com.sun.el.parser.ParseException: Encountered "(" at line 1, column 22.
 Was expecting one of:
    "}" ...
    "." ...
    "[" ...
    ">" ...
    "gt" ...
    "<" ...
    "lt" ...
    ">=" ...
    "ge" ...
    "<=" ...
    "le" ...
    "==" ...
    "eq" ...
    "!=" ...
    "ne" ...
    "&&" ...
    "and" ...
    "||" ...
    "or" ...
    "*" ...
    "+" ...
    "-" ...
    "?" ...
    "/" ...
    "div" ...
    "%" ...
    "mod" ...

    at com.sun.el.parser.ELParser.generateParseException(ELParser.java:2143)
    at com.sun.el.parser.ELParser.jj_consume_token(ELParser.java:2025)
    at com.sun.el.parser.ELParser.DeferredExpression(ELParser.java:113)
    at com.sun.el.parser.ELParser.CompositeExpression(ELParser.java:40)
    at com.sun.el.lang.ExpressionBuilder.createNodeInternal(ExpressionBuilder.java:173)


weblogic.xml <container-descriptor> 更改为

<wls:container-descriptor>
    <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>

产生与上面相同的异常,直到我将以下内容添加到 web.xml

<context-param>
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>     
</context-param>

然后抛出的异常变为

java.lang.NoSuchMethodError: javax.el.ELResolver.invoke(Ljavax/el/ELContext;Ljava/lang/Object;Ljava/lang/Object;[Ljava/lang/Class;[Ljava/lang/Object;)Ljava/lang/Object;
    at com.sun.el.parser.AstValue.getValue(AstValue.java:111)
    at com.sun.el.parser.AstValue.getValue(AstValue.java:163)
    at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
    at com.sun.faces.facelets.el.ELText$ELTextVariable.writeText(Unknown Source)
    at com.sun.faces.facelets.el.ELText$ELTextComposite.writeText(Unknown Source)
    at com.sun.faces.facelets.compiler.TextInstruction.write(Unknown Source)
    at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(Unknown Source)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(Unknown Source)
    at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(Unknown Source)
    at javax.faces.component.UIComponentBase.encodeChildren(Unknown Source)
    at javax.faces.component.UIComponent.encodeAll(Unknown Source)
    at javax.faces.component.UIComponent.encodeAll(Unknown Source)
    at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(Unknown Source)
    at com.sun.faces.application.view.MultiViewHandler.renderView(Unknown Source)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(Unknown Source)
    at com.sun.faces.lifecycle.Phase.doPhase(Unknown Source)
    at com.sun.faces.lifecycle.LifecycleImpl.render(Unknown Source)
    at javax.faces.webapp.FacesServlet.service(Unknown Source)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

我不明白 weblogic 的行为方式,与 this question

中的第二个答案中相同的步骤与其他开发人员一起工作

我发现了一些关于 Oracle forums 的解决方法,它将 WAR 封装在 EAR 中并使用 EAR 的 weblogic-application.xml 基本上强制执行相同的包引用,但是显然这次 weblogic 尊重偏好并且工作正常。

仍然不知道如何只使用 WAR 文件。

论坛上发布的解决方案

For me the following worked:

Weblogic 10.3.5.0

I have a JavaEE application with both ejbs in EJB container and Facelets in Web container.

I added /META_INF/weblogic-application.xml :

    <?xml version = '1.0' encoding = 'windows-1252'?>
<weblogic-application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.1/weblogic-application.xsd"
xmlns="http://xmlns.oracle.com/weblogic/weblogic-application">
<prefer-application-packages>
<package-name>com.sun.el.*</package-name>
<package-name>javax.el.*</package-name>
</prefer-application-packages>
</weblogic-application>

Included el-api-2.2.jar and el-impl-2.2.jar to the WEB-INF/lib library.

it works, it does not work for me when using the weblogic.xml

谢谢“965902”无论你是谁!

这是我在旧 weblogic 中针对 EL 的解决方法:

<context-param> <param-name>com.sun.faces.expressionFactory</param-name> <param-value>org.jboss.el.ExpressionFactoryImpl</param-value> </context-param>

  • 享受参数化方法调用。不需要其他配置(没有库引用,没有首选应用程序包,没有首选 web-inf-类)

我 运行 在 WebLogic 12.1.3 中尝试部署 JSF 2.2 时遇到类似错误。接受的答案还不够,或者至少会导致其他错误。以下是诀窍:

web/pom.xml:

<dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>2.2.13</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>2.2.13</version>
        </dependency>
        <dependency>
            <groupId>javax.el</groupId>
            <artifactId>el-api</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>el-impl</artifactId>
            <version>2.2</version>
        </dependency>
        <dependency>
            <groupId>javax.el</groupId>
            <artifactId>javax.el-api</artifactId>
            <version>2.2.1</version>
        </dependency>
        <dependency>
            <groupId>javax.faces</groupId>
            <artifactId>javax.faces-api</artifactId>
            <version>2.2</version>
        </dependency>

weblogic-应用程序:

<?xml version="1.0" encoding="UTF-8"?>
    <weblogic-application
        xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application"
        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/javaee_5.xsd
            http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.4/weblogic-application.xsd">

        <prefer-application-packages>
                <package-name>javax.el.*</package-name>
                <package-name>javax.faces.*</package-name>
                <package-name>com.sun.el.*</package-name>
                <package-name>com.sun.faces.*</package-name>
                <package-name>com.bea.faces.*</package-name>
            </prefer-application-packages>

            <prefer-application-resources>
                <resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
                <resource-name>META-INF/services/com.sun.faces.*</resource-name>
            </prefer-application-resources>

    </weblogic-application>

这里有更多详细信息 post https://roundwheeltech.wordpress.com/2016/06/15/deploying-a-jsf-2-2-to-weblogic-12-1-3/