MHosafy
MHosafy

Reputation: 174

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

I'm running Weblogic 10.3.6 and trying to build a new dynamic web application (in eclipse) that supports JSF 2.2.8 and EL 2.2 and JDK 1.7 U45, but unfortunately EL 2.2 is throwing an exception.

The 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>


The following exception is thrown trying to run a page with an parameterized method call in 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)


Changing the weblogic.xml <container-descriptor> to

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

yields the same exception above, untill I add the following to the web.xml

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

Then the exception thrown changes to

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)

I don't understand how weblogic is behaving, the same steps worked with other develobers as in the second answer in this question

Upvotes: 1

Views: 4533

Answers (3)

6006604
6006604

Reputation: 7789

I ran into a similar error trying to deploy JSF 2.2 in WebLogic 12.1.3. The accepted answer didn't quite suffice, or at least it lead to other errors. The following did the trick:

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-application:

<?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>

There are more details in this post https://roundwheeltech.wordpress.com/2016/06/15/deploying-a-jsf-2-2-to-weblogic-12-1-3/.

Upvotes: 1

Dmytro Voloshyn
Dmytro Voloshyn

Reputation: 409

Here is my workaround for EL in the old weblogic:

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

  • Enjoy parameterized method calls. No other configuration required (no library-refs, no prefer-application-packages, no prefer-web-inf-classes)

Upvotes: 3

MHosafy
MHosafy

Reputation: 174

I have found a bit of a work around on the Oracle forums, it encapsulates the WAR in an EAR and uses the EAR's weblogic-application.xml to basically enforce the same package references but apparently this time weblogic honors the preferences and it works fine.

Still don't know how to do that with only a WAR file.

Solution posted on the forums

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

Thank you "965902" whoever you are !

Upvotes: 0

Related Questions