Announcement Announcement Module
Collapse
No announcement yet.
How to setup Unified EL for swf-booking-faces Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to setup Unified EL for swf-booking-faces

    Hi, have added 'el-api.jar' to deployed swf-booking-faces application which deploys and starts fine but at runtime browser dispalys nice Facelets error page

    "Could not instantiate feature[compiler.ExpressionFactory]: com.sun.el.ExpressionFactoryImpl"

    Code:
    com.sun.facelets.FaceletException: Could not instantiate feature[compiler.ExpressionFactory]: com.sun.el.ExpressionFactoryImpl
    	at com.sun.facelets.compiler.Compiler.featureInstance(Compiler.java:154)
    	at com.sun.facelets.compiler.Compiler.createExpressionFactory(Compiler.java:128)
    	at com.sun.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:198)
    	at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:144)
    	at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:95)
    	at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:517)
    Seems application is finding the el-api.jar (if remove then get deploy time error - can not find javax.el.ELContext etc).

    Seems something else is required which is not documented in spring faces ref doc ? Have tried el-api.ri w/o success - in any case i think spring faces should use the included jboss-el impl ?

  • #2
    Originally posted by gbayfield View Post
    Hi, have added 'el-api.jar' to deployed swf-booking-faces application which deploys and starts fine but at runtime browser dispalys nice Facelets error page
    What web container do you use?

    In tomcat 6.0.x el-api.jar is included in <tomcat_home>/lib and shouldn't be placed into web app lib folder.

    Comment


    • #3
      Originally posted by gbayfield View Post
      Seems something else is required which is not documented in spring faces ref doc ? Have tried el-api.ri w/o success - in any case i think spring faces should use the included jboss-el impl ?
      jboss-el isn't used by default when evaluating expressions in your facelets. It's used in flow controllers.

      In order to use jboss-el to evaluate expressions in facelets you should add into your web.xml:

      Code:
      	<context-param>
      	  <param-name>com.sun.faces.expressionFactory</param-name>
      	  <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
      	</context-param>
      This will allow to call any methods with params in your facelets. Actually really great feature that should be documented better than it is .

      Comment


      • #4
        Facelets environment still not resolving an EL Factory Impl for swf-booking-faces

        Hi and ... have built and trying to run the swf-booking-faces reference out-of-the-box app on WAS 6.1
        I see now that it was the facelets env and not the webflow env that can not resolve the ExpressionFactoryImpl -I had added el-api.jar (per pg 16 ref doc)to the classpath for the webflow env (lol- i just assumed facelets would use same) - i have added the web.xml entry as described (pls see below) but unfortunately facelet RENDERING still wants to find com.sun.el.ExpressionFactoryImpl ?

        What additional facelets config do i need to do to get this running on Unified EL ?
        Or should i add another EL environment (what jars is facelets currently trying to find ?), thanks for your help...

        web.xml with context param
        Code:
        <?xml version="1.0" encoding="ISO-8859-1"?>
        <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
        	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        	version="2.4">
        
        	<!-- The master configuration file for this Spring web application -->
        	<context-param>
        		<param-name>contextConfigLocation</param-name>
        		<param-value>
        			/WEB-INF/config/web-application-config.xml
        		</param-value>
        	</context-param>
        	
        	<!-- Use JSF view templates saved as *.xhtml, for use with Facelets -->
        	<context-param>
        		<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        		<param-value>.xhtml</param-value>
        	</context-param>
        	
        	<!-- Enables special Facelets debug output during development -->
          	<context-param>
                <param-name>facelets.DEVELOPMENT</param-name>
           		<param-value>true</param-value>
          	</context-param>
          	
          	<!-- Causes Facelets to refresh templates during development -->
          	<context-param>
          		<param-name>facelets.REFRESH_PERIOD</param-name>
          		<param-value>1</param-value>
          	</context-param>
        
             <!-- Configure Facelets to use JBoss EL -->
          	<context-param>
          		<param-name>com.sun.faces.expressionFactory</param-name>
          		<param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
          	</context-param>
        
        	<!-- Enables Spring Security -->
        	 <filter>
                <filter-name>springSecurityFilterChain</filter-name>
                <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
            </filter>
        
            <filter-mapping>
              <filter-name>springSecurityFilterChain</filter-name>
              <url-pattern>/*</url-pattern>
            </filter-mapping>
        	
        	<!-- Loads the Spring web application context -->
        	<listener>
        		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        	</listener>
          	
          	<!-- Serves static resource content from .jar files such as spring-faces.jar -->
        	<servlet>
        		<servlet-name>Resources Servlet</servlet-name>
        		<servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
        		<load-on-startup>0</load-on-startup>
        	</servlet>
        		
        	<!-- Map all /resources requests to the Resource Servlet for handling -->
        	<servlet-mapping>
        		<servlet-name>Resources Servlet</servlet-name>
        		<url-pattern>/resources/*</url-pattern>
        	</servlet-mapping>
        	
        	<!-- The front controller of this Spring Web application, responsible for handling all application requests -->
        	<servlet>
        		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        		<init-param>
        			<param-name>contextConfigLocation</param-name>
        			<param-value></param-value>
        		</init-param>
        		<load-on-startup>2</load-on-startup>
        	</servlet>
        		
        	<!-- Map all /spring requests to the Dispatcher Servlet for handling -->
        	<servlet-mapping>
        		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        		<url-pattern>/spring/*</url-pattern>
        	</servlet-mapping>
        
        	<!-- Just here so the JSF implementation can initialize, *not* used at runtime -->
        	<servlet>
        		<servlet-name>Faces Servlet</servlet-name>
        		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        		<load-on-startup>1</load-on-startup>
        	</servlet>
        	
        	<!-- Just here so the JSF implementation can initialize -->
        	<servlet-mapping>
        		<servlet-name>Faces Servlet</servlet-name>
        		<url-pattern>*.faces</url-pattern>
        	</servlet-mapping>
        	
        	<welcome-file-list>
        		<welcome-file>index.html</welcome-file>
        	</welcome-file-list>
        
        </web-app>
        error
        Code:
        com.sun.facelets.FaceletException: Could not instantiate feature[compiler.ExpressionFactory]: com.sun.el.ExpressionFactoryImpl
        	at com.sun.facelets.compiler.Compiler.featureInstance(Compiler.java:154)
        	at com.sun.facelets.compiler.Compiler.createExpressionFactory(Compiler.java:128)
        	at com.sun.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:198)
        	at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:144)
        	at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet

        Comment


        • #5
          com.sun.el.ExpressionFactoryImpl is found in the Unified EL reference implementation. You can get a copy of it here:

          http://download.java.net/maven/1/el-...l-impl-1.0.jar

          Comment


          • #6
            Facelets pages rendering but broken links as unresolved ${request.contextPath} ?

            With addition of JBoss EL in web.xml and addition of el-impl-1.0.jar, am finding the facelets pages now resolve but all images and links with ${request.contextPath} are not resolving correctly in rendered pages

            Layout is :
            <a href="http://www.thespringexperience.com">
            <img src="${request.contextPath}/resources/images/diplomat.jpg" alt="generic hotel" />

            Online demo page correctly shows
            <a href="http://www.thespringexperience.com">
            <img src="$/swf-booking-pages/resources/images/diplomat.jpg" alt="generic hotel" />

            I have
            <a href="http://www.thespringexperience.com">
            <img src="/resources/images/diplomat.jpg" alt="generic hotel" />

            which of course will not correctly resolve even though resources servlet is deployed and working (not resolving el variable request.contextPath ?).

            Log in debug mode shows no errors at all?
            Have deployed el-api.jar and el-impl-.0.jar & web.xml change above- what else does facelets require ?

            Code:
            [31/07/08 15:50:35:824 BST] 0000001c SystemOut     O DEBUG: org.springframework.security.util.FilterChainProxy - Converted URL to lowercase, from: '/spring/intro'; to: '/spring/intro'
            [31/07/08 15:50:35:824 BST] 0000001c SystemOut     O DEBUG: org.springframework.security.util.FilterChainProxy - Candidate is: '/spring/intro'; pattern is /**; matched=true
            [31/07/08 15:50:35:824 BST] 0000001c SystemOut     O DEBUG: org.springframework.security.util.FilterChainProxy - /spring/intro at position 1 of 10 in additional filter chain; firing Filter: 'org.springframework.security.context.HttpSessionContextIntegrationFilter[ order=200; ]'
            ..
            org.springframework.faces.support.RequestLoggingPhaseListener - Entering JSF Phase: RESTORE_VIEW 1
            [31/07/08 15:50:35:840 BST] 0000001c SystemOut     O DEBUG: org.springframework.faces.support.RequestLoggingPhaseListener - Entering JSF Phase: RENDER_RESPONSE 6
            [31/07/08 15:50:35:840 BST] 0000001c SystemOut     O DEBUG: org.springframework.faces.mvc.JsfView - Asking view handler to render view
            [31/07/08 15:50:35:840 BST] 0000001c SystemOut     O DEBUG: org.springframework.faces.mvc.JsfView - View rendering complete
            [31/07/08 15:50:35:840 BST] 0000001c SystemOut     O DEBUG: org.springframework.web.servlet.DispatcherServlet - Cleared thread-bound request context: [email protected]835d8
            [31/07/08 15:50:35:840 BST] 0000001c SystemOut     O DEBUG: org.springframework.web.servlet.DispatcherServlet - Successfully completed request
            [31/07/08 15:50:35:840 BST] 0000001c SystemOut     O DEBUG: org.springframework.web.context.support.XmlWebApplicationContext - Publishing event in context [[email protected]2a602a60]: ServletRequestHandledEvent: url=[/swf-booking-faces/spring/intro]; client=[127.0.0.1]; method=[GET]; servlet=[Spring MVC Dispatcher Servlet]; session=[9pHIxEcKj9ZTASBL0IAdSg4]; user=[null]; time=[0ms]; status=[OK]
            [31/07/08 15:50:35:840 BST] 0000001c SystemOut     O DEBUG: org.springframework.web.context.support.XmlWebApplicationContext - Publishing event in context [[email protected]3cee3cee]: ServletRequestHandledEvent: url=[/swf-booking-faces/spring/intro]; client=[127.0.0.1]; method=[GET]; servlet=[Spring MVC Dispatcher Servlet]; session=[9pHIxEcKj9ZTASBL0IAdSg4]; user=[null]; time=[0ms]; status=[OK]
            [31/07/08 15:50:35:840 BST] 0000001c SystemOut     O DEBUG: org.springframework.security.ui.ExceptionTranslationFilter - Chain processed normally
            [31/07/08 15:50:35:840 BST] 0000001c SystemOut     O DEBUG: org.springframework.security.context.HttpSessionContextIntegrationFilter - SecurityContext contents are anonymous - context will not be stored in HttpSession. 
            [31/07/08 15:50:35:840 BST] 0000001c SystemOut     O DEBUG: org.springframework.security.context.HttpSessionContextIntegrationFilter - SecurityContextHolder now cleared, as request processing completed

            Comment


            • #7
              What JSF implementation are you using?

              Comment


              • #8
                JSF implementation with swf-booking-faces on WAS 6.1

                good question - Was thinking the JSf implementation was delivered as part of the swf-booking-faces application (ivy cache jars) but i cant see it in there now.
                If this is not the case then must be from the IBM WAS 6.1 JVM environment ? What is best way to determine this ?

                Comment


                • #9
                  The JSF RI does get included by default when building the sample, but I'm wondering if it may somehow conflict with whatever WAS 6.1 already includes. If the 1.2 RI included with the sample is being used, you should see something like this in the log at startup:

                  INFO: Initializing Mojarra (1.2_08-b06-FCS) for context '/swf-booking-faces'

                  Comment


                  • #10
                    Potential conflict between spirng and IBM JSF impl's

                    Think we're getting closer to problem now!, the swf-booking-faces debug logging does Not have any ref to Mojarra from above but i do have the following IBM jars deployed
                    C:\Program Files\IBM\WebSphere\AppServer\optionalLibraries\IB M\JWL\2.0\odc-jsf.jar
                    C:\Program Files\IBM\WebSphere\AppServer\optionalLibraries\IB M\JWL\2.0\jsf-ibm.jar
                    according to the IBM doco
                    Code:
                    http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/cweb_javaserver_faces.html
                    Am now thinking the IBM JSF env has not been setup as required - am investigating ...

                    There is also potential for conflict between spring jsf and ibm jsf here ?
                    Code:
                     Rendering view [org.springframework.faces.mvc.JsfView: name 'intro'; URL [/WEB-INF/intro.xhtml]] in DispatcherServlet with name 'Spring MVC Dispatcher Servlet'
                    [31/07/08 16:50:02:133 BST] 0000001f SystemOut     O DEBUG: org.springframework.faces.mvc.JsfView - Rendering view with name 'intro' with model null and static attributes {}
                    [31/07/08 16:50:02:133 BST] 0000001f SystemOut     O DEBUG: org.springframework.faces.support.RequestLoggingPhaseListener - Entering JSF Phase: RESTORE_VIEW 1
                    [31/07/08 16:50:02:149 BST] 0000001f SystemOut     O DEBUG: org.springframework.faces.support.RequestLoggingPhaseListener - Entering JSF Phase: RENDER_RESPONSE 6
                    [31/07/08 16:50:02:149 BST] 0000001f SystemOut     O DEBUG: org.springframework.faces.mvc.JsfView - Asking view handler to render view
                    [31/07/08 16:50:02:601 BST] 0000001f compiler      I   Added Library from: wsjar:file:/C:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/LONW00700Node01Cell/grb10_war.ear/grb10.war/WEB-INF/lib/com.springsource.com.sun.facelets-1.1.14.jar!/META-INF/jsf-core.taglib.xml[31/07/08 16:50:02:601 BST] 0000001f compiler      I   Added Library from: wsjar:file:/C:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/LONW00700Node01Cell/grb10_war.ear/grb10.war/WEB-INF/lib/com.springsource.com.sun.facelets-1.1.14.jar!/META-INF/jsf-html.taglib.xml
                    [31/07/08 16:50:02:617 BST] 0000001f compiler      I   Added Library from: wsjar:file:/C:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/LONW00700Node01Cell/grb10_war.ear/grb10.war/WEB-INF/lib/com.springsource.com.sun.facelets-1.1.14.jar!/META-INF/jsf-ui.taglib.xml
                    [31/07/08 16:50:02:632 BST] 0000001f compiler      I   Added Library from: wsjar:file:/C:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/LONW00700Node01Cell/grb10_war.ear/grb10.war/WEB-INF/lib/com.springsource.com.sun.facelets-1.1.14.jar!/META-INF/jstl-core.taglib.xml
                    [31/07/08 16:50:02:632 BST] 0000001f compiler      I   Added Library from: wsjar:file:/C:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/LONW00700Node01Cell/grb10_war.ear/grb10.war/WEB-INF/lib/com.springsource.com.sun.facelets-1.1.14.jar!/META-INF/jstl-fn.taglib.xml
                    [31/07/08 16:50:02:695 BST] 0000001f compiler      I   Added Library from: wsjar:file:/C:/Program Files/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/LONW00700Node01Cell/grb10_war.ear/grb10.war/WEB-INF/lib/org.springframework.faces-2.0.2.BUILD-20080729100021.jar!/META-INF/springfaces.taglib.xml
                    [31/07/08 16:50:02:804 BST] 0000001f SystemOut     O DEBUG: org.springframework.faces.mvc.JsfView - View rendering complete

                    Comment


                    • #11
                      Originally posted by jeremyg484 View Post
                      com.sun.el.ExpressionFactoryImpl is found in the Unified EL reference implementation. You can get a copy of it here:

                      http://download.java.net/maven/1/el-...l-impl-1.0.jar
                      Jeremy, adding that link to the SWF documentation would really help. As it is now, I don't use either maven or ivy and I ended up downloading glassfish or jboss and extracting them and digging through the result of that to get an el implementation. After doing that I realized that that's not a viable way to do business and went back to ognl.

                      Comment


                      • #12
                        We created a JIRA to improve the documentation here. It's a little confusing because some managed EE environments like Tomcat 6 include the core Unified EL implementation classes. Other environments do not, and we do encourage the community to tell us about those so we can get them properly documented.

                        Keith

                        Comment


                        • #13
                          Success ! Spring booking faces ref app running on WAS 61

                          Finally have swf-booking-faces running on WAS 6.1
                          Steps:
                          *In was61 console deploy web app with Unified EL jars (see this thread) against the war module (not application level)
                          *Deploy sample web app with PARENT_LAST classloader (own classloader per war)
                          * add the following IBM context param (the missing piece for me) since we need to 'turn off' the IBM JSF environment to use Spring faces.

                          web.xml additions
                          Code:
                          <!--  GRB Configure Facelets to use JBoss EL 
                            --> 
                          - <context-param>
                            <param-name>com.sun.faces.expressionFactory</param-name> 
                            <param-value>org.jboss.el.ExpressionFactoryImpl</param-value> 
                            </context-param>
                          - <!--  GRB Prevent IBM from parsing app faces-config.xml 
                            --> 
                          - <context-param>
                            <param-name>com.ibm.ws.jsf.LOAD_FACES_CONFIG_AT_STARTUP</param-name> 
                            <param-value>false</param-value> 
                            </context-param>
                          Sample application now works perfectly in WAS 6.1.0.9 (Feature pack for web services) without errors !

                          Comment


                          • #14
                            correction ...

                            should clarify/correct
                            * Admin console class loader settings must be
                            "Classes loaded with application class loader first"
                            "Single class loader for application"
                            * Unified EL added a Shared library to web.xml war level

                            Comment


                            • #15
                              Originally posted by Keith Donald View Post
                              We created a JIRA to improve the documentation here. It's a little confusing because some managed EE environments like Tomcat 6 include the core Unified EL implementation classes. Other environments do not, and we do encourage the community to tell us about those so we can get them properly documented.

                              Keith
                              Excellent; thanks.

                              Comment

                              Working...
                              X