Results 1 to 3 of 3

Thread: UIViewRoot null with Spring 3 and mojarra

  1. #1
    Join Date
    Nov 2011
    Posts
    3

    Default UIViewRoot null with Spring 3 and mojarra

    Hi to everyone,

    I'm trying to setup an application with Spring 3.0.6, Spring webflow 2.3, Spring security 2.0.7 and Mojarra 2.1.3

    I see the login page all right, but after login I get an exception, due to the fact that UIViewRoot is null (I think looking at the source):

    Code:
    SEVERE: Servlet.service() for servlet Spring MVC Dispatcher Servlet threw exception
    java.lang.NullPointerException
    	at com.sun.faces.context.StateContext.startTrackViewModifications(StateContext.java:178)
    	at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:455)
    	at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148)
    	at org.springframework.faces.webflow.FlowViewHandler.restoreFlowView(FlowViewHandler.java:144)
    	at org.springframework.faces.webflow.FlowViewHandler.restoreView(FlowViewHandler.java:83)
    ...
    before this I was using myfaces 2.1.3 and everything worked fine, I had to switch to mojarra for some other compatibility issue.

    my configuration files are:

    faces-config.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <faces-config xmlns="http://java.sun.com/xml/ns/javaee" 
    			  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-facesconfig_2_0.xsd"
    			  version="2.0"> 
    	<application>
        </application>
    </faces-config>
    spring_flow.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" 
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:tx="http://www.springframework.org/schema/tx" 
           xmlns:webflow="http://www.springframework.org/schema/webflow-config" 
           xmlns:faces="http://www.springframework.org/schema/faces"
           xsi:schemaLocation="http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-3.0.xsd
            http://www.springframework.org/schema/tx 
            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
            http://www.springframework.org/schema/webflow-config 
            http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd 
            http://www.springframework.org/schema/faces 
            http://www.springframework.org/schema/faces/spring-faces-2.2.xsd">
    
    	<faces:resources />
    
        <bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
            <property name="flowExecutor" ref="flowExecutor" />
        </bean>
    
    
    	<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    	    <property name="mappings">
                <value>
     	            /flows/*=flowController
                </value>
    	    </property>
            <property name="defaultHandler">
                <bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/>
            </property>
        </bean>
    		
    	<bean  class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter">
    	</bean>
    		
    
        <bean id="faceletsViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    	     <property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
    	     <property name="prefix" value="/WEB-INF/"/>
    	     <property name="suffix" value=".xhtml"/>
        </bean>
    		
    	<bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">
    	  <property name="flowExecutor" ref="flowExecutor"/>
    	</bean>
    
    	<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry">
    		<webflow:flow-execution-listeners> 
    			<webflow:listener ref="flowExecutionListener" /> 
    			<webflow:listener ref="flowFacesContextLifecycleListener" /> 
    		</webflow:flow-execution-listeners> 
    	</webflow:flow-executor> 
    
    	<bean id="flowExecutionListener" class="org.springframework.webflow.persistence.HibernateFlowExecutionListener"> 
    		<constructor-arg ref="sessionFactory" />
    		<constructor-arg ref="txnManager" /> 
    	</bean> 
    	
    	<bean id="flowFacesContextLifecycleListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" /> 
    		
    	<webflow:flow-registry id="flowRegistry" flow-builder-services="facesFlowBuilderServices">
    	    <webflow:flow-location-pattern value="/WEB-INF/flows/**/*.xml"/>
    	</webflow:flow-registry>
    
    	<bean id="conversionService" class="org.springframework.faces.model.converter.FacesConversionService"/>
    	
        <bean id="expressionParser" class="org.springframework.webflow.expression.el.WebFlowELExpressionParser">
             <constructor-arg>
                 <bean class="org.jboss.el.ExpressionFactoryImpl"/>    
             </constructor-arg>
             <property name="conversionService" ref="conversionService"/>
         </bean>		
    
    	<faces:flow-builder-services id="facesFlowBuilderServices" expression-parser="expressionParser" conversion-service="conversionService"/>
    	
    </beans>
    web.xml

    Code:
    <?xml version = '1.0'?>
    <web-app 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" xmlns="http://java.sun.com/xml/ns/j2ee">
    
        <description>OBE AutoLoading</description>
    
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>/WEB-INF/spring_context.xml</param-value>
    	</context-param>
    
    	<context-param>
    		<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    		<param-value>.xhtml</param-value>
    	</context-param>
    	
    	<context-param>
    		<param-name>facelets.DEVELOPMENT</param-name>
    		<param-value>true</param-value>
    	</context-param>
    	
        <context-param>
    		<param-name>facelets.REFRESH_PERIOD</param-name>
    		<param-value>1</param-value>
        </context-param>
    
    	<context-param>
    		<param-name>com.sun.faces.expressionFactory</param-name>
    		<param-value>com.sun.el.ExpressionFactoryImpl</param-value>
    	</context-param>
        
        <context-param>
    		<param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>
    		<param-value>false</param-value>
    	</context-param>
    
    	<filter>
    		<filter-name>extensionsFilter</filter-name>
    		<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    		<init-param>
    			<description>Size limit for uploaded files.
    						 10 - 10 bytes, 10k - 10 KB, 10m - 10 MB, 1g - 1 GB
    			</description>
          		<param-name>uploadMaxFileSize</param-name>
          		<param-value>100m</param-value>
        	</init-param>
        	<init-param>
    			<description>Set the threshold size - files below this limit are stored in memory,
    			 	        files above this limit are stored on disk.
    						10 - 10 bytes, 10k - 10 KB, 10m - 10 MB, 1g - 1 GB
    			</description>
    			<param-name>uploadThresholdSize</param-name>
    			<param-value>100k</param-value>
    		</init-param>
    	</filter>
    
    	<filter-mapping>
        	<filter-name>extensionsFilter</filter-name>
        	<servlet-name>Faces Servlet</servlet-name>
    	</filter-mapping>
    
    	
    	<filter-mapping>
    		<filter-name>extensionsFilter</filter-name>
    		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
     	</filter-mapping>
    
    	<filter-mapping>
        	<filter-name>extensionsFilter</filter-name>
    		<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
    	</filter-mapping>
    
    	<filter-mapping>
    		<filter-name>extensionsFilter</filter-name>
    		<url-pattern>*.xhtml</url-pattern>
    	</filter-mapping>
    	
    	<filter-mapping>
            <filter-name>extensionsFilter</filter-name>
            <url-pattern>/faces/*</url-pattern>
    	</filter-mapping>
    	
    	<context-param>
    		<param-name>org.apache.myfaces.ADD_RESOURCE_CLASS</param-name>
    		<param-value>org.apache.myfaces.renderkit.html.util.DefaultAddResource</param-value>
    	</context-param>
    	
    	<context-param>
        	<param-name>org.apache.myfaces.CHECK_EXTENSIONS_FILTER</param-name>
    		<param-value>true</param-value>
    	</context-param>
      
        <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>
          
    	<listener>
            <listener-class>org.springframework.security.ui.session.HttpSessionEventPublisher</listener-class>
        </listener>    
    	
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    	
    	<listener>
    	    <listener-class>org.springframework.web.context.request.RequestContextListener </listener-class>
    	</listener>
    
        <servlet>
    		<servlet-name>Faces Servlet</servlet-name> 
    	  	<servlet-class>javax.faces.webapp.FacesServlet</servlet-class> 
    	</servlet>
    	<servlet-mapping>
    	  	<servlet-name>Faces Servlet</servlet-name> 
    	  	<url-pattern>*.xhtml</url-pattern> 
    	</servlet-mapping>
    
        <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>
    
        <servlet-mapping>
    		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    		<url-pattern>/spring/*</url-pattern>
        </servlet-mapping>
        
     
    </web-app>
    It's the first time a start a Spring application from scratch, any help is very appreciated, thank you

    Mattia

  2. #2
    Join Date
    Aug 2011
    Location
    Hamburg
    Posts
    1

    Default Anything new? I have the same problem

    Hello malavock82,

    did you solve the problem? I have the same problem using now Mojarra JSF 2.1.5, Spring 3.0.6.RELEASE and (!) spring-webflow 2.3.0.BUILD-SNAPSHOT.

    Kind regards
    okossak

  3. #3
    Join Date
    Nov 2011
    Posts
    3

    Default

    Hi Okossak,

    at the time I had to drop the issue and remove Mojarra. Now after 1 year I come back to the same issue... did you manage to solve it yourself?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •