Results 1 to 2 of 2

Thread: The requested resource () is not available.

  1. #1
    Join Date
    Aug 2012
    Posts
    2

    Default The requested resource () is not available.

    Hi all,

    I've been trying to get a simple hello world (pizza) example going with JSF and SWF but I keep hitting this same problem. When loading from the URL I'm expecting to see my jsf view at (http://localhost:8080/Pizza/spring/main-flow), I get a 404 message;

    Code:
    type Status report
    message
    description The requested resource () is not available.
    Loading http://localhost:8080/Pizza/controll...owId=main-flow gives;

    Code:
    type Exception report
    
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    
    javax.servlet.ServletException: Cannot create a session after the response has been committed
    	javax.faces.webapp.FacesServlet.service(FacesServlet.java:229)
    	org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
    	org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:147)
    	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    root cause
    
    java.lang.IllegalStateException: Cannot create a session after the response has been committed
    	org.apache.catalina.connector.Request.doGetSession(Request.java:2871)
    	org.apache.catalina.connector.Request.getSession(Request.java:2307)
    	org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:898)
    	org.apache.myfaces.context.servlet.SessionMap.setAttribute(SessionMap.java:56)
    	org.apache.myfaces.util.AbstractThreadSafeAttributeMap.put(AbstractThreadSafeAttributeMap.java:109)
    	org.apache.myfaces.util.AbstractThreadSafeAttributeMap.put(AbstractThreadSafeAttributeMap.java:38)
    	org.apache.myfaces.renderkit.ServerSideStateCacheImpl.saveSerializedViewInServletSession(ServerSideStateCacheImpl.java:217)
    	org.apache.myfaces.renderkit.ServerSideStateCacheImpl.saveSerializedView(ServerSideStateCacheImpl.java:872)
    	org.apache.myfaces.renderkit.html.HtmlResponseStateManager.saveState(HtmlResponseStateManager.java:144)
    	org.apache.myfaces.application.StateManagerImpl.saveView(StateManagerImpl.java:253)
    	org.springframework.faces.webflow.FlowViewStateManager.saveView(FlowViewStateManager.java:170)
    	org.apache.myfaces.shared.view.JspViewDeclarationLanguageBase.renderView(JspViewDeclarationLanguageBase.java:219)
    	org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:285)
    	org.springframework.faces.webflow.FlowViewHandler.renderView(FlowViewHandler.java:99)
    	org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:115)
    	org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
    	javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
    	org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
    	org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:147)
    	org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    note The full stack trace of the root cause is available in the VMware vFabric tc Runtime 2.7.0.RELEASE/7.0.27.A.RELEASE logs.
    
    VMware vFabric tc Runtime 2.7.0.RELEASE/7.0.27.A.RELEASE
    As far as I can see the log file is not created. I have seen reports of " Cannot create a session after the response has been committed" occurring with big session data - but in fairness this is the simplest example I can think of; it contains no jsf tags at all.

    Project Structure;

    webapp
    - flow
    -- a.xhtml
    -- main-flow.xml
    - WEB-INF
    -- applicationContext-webflow.xml
    -- faces-config.xml
    -- web.xml
    - index.html (this is just a redirect which seems to work fine)

    a.xhtml
    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <html>
          <body>
    		<b>hello</b>
          </body>
    </html>
    main-flow.xml
    Code:
     <?xml version="1.0" encoding="UTF-8"?>
    <flow xmlns="http://www.springframework.org/schema/webflow"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/webflow
            http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
    	<view-state id="main" view="a" />
    </flow>
    applicationContext-webflow.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: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/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">
    
        <!-- Executes flows: the central entry point into the Spring Web Flow system -->
        <webflow:flow-executor id="flowExecutor">
            <webflow:flow-execution-listeners>
                <webflow:listener ref="facesContextListener"/>
            </webflow:flow-execution-listeners>
        </webflow:flow-executor>
    	
        <!-- The registry of executable flow definitions -->
        <webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
            <webflow:flow-location path="/flow/main-flow.xml" />
        </webflow:flow-registry>
    
        <!-- Configures the Spring Web Flow JSF integration -->
        <faces:flow-builder-services id="flowBuilderServices" />
    
        <!-- A listener maintain one FacesContext instance per Web Flow request. -->
        <bean id="facesContextListener" 
            class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" />	
            
        <faces:resources />
        
        <bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
            <property name="flowExecutor" ref="flowExecutor" />
        </bean>
        
        <!-- 
        <bean id="faceletsViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    		<property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
    		<property name="suffix" value=".xhtml" />
    	</bean>
    	 -->
    
    </beans>
    faces-config.xml
    Code:
    <?xml version="1.0"?>
    <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>
            <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
        </application>
    </faces-config>
    web.xml
    Code:
    <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	version="3.0"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    	<display-name>Pizza</display-name>
    	<description>Roo generated Pizza application</description>
    	<!-- Enable escaping of form submission contents -->
    	<context-param>
    		<param-name>defaultHtmlEscape</param-name>
    		<param-value>true</param-value>
    	</context-param>
    	<context-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
    	</context-param>
    	<context-param>
    		<param-name>primefaces.THEME</param-name>
    		<param-value>trontastic</param-value>
    	</context-param>
    	<filter>
    		<filter-name>PrimeFaces FileUpload Filter</filter-name>
    		<filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    	</filter>
    	<filter-mapping>
    		<filter-name>PrimeFaces FileUpload Filter</filter-name>
    		<servlet-name>Faces Servlet</servlet-name>
    	</filter-mapping>
    	<filter>
    		<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
    		<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
    	</filter>
    	<filter-mapping>
    		<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
    		<url-pattern>/*</url-pattern>
    	</filter-mapping>
    	<!-- Creates the Spring Container shared by all Servlets and Filters -->
    	<listener>
    		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    	<listener>
    		<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
    	</listener>
    	<servlet>
    		<servlet-name>Faces Servlet</servlet-name>
    		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>Faces Servlet</servlet-name>
    		<url-pattern>*.faces</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>/WEB-INF/applicationContext-webflow.xml</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    
    	<servlet-mapping>
    		<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
    		<url-pattern>/spring/*</url-pattern>
    	</servlet-mapping>
    	
    
    
    	<session-config>
    		<session-timeout>10</session-timeout>
    	</session-config>
    	<welcome-file-list>
    		<welcome-file>index.html</welcome-file>
    	</welcome-file-list>
    </web-app>

    Most of the configuration has been copied directly from the web flow tutorial pages on JSF/SWF integration. The project (including JSF web scaffold) was generated by Roo, perhaps something that Roo generated is interfering and needs to be removed?

    Any help would be much appreciated,

    Thanks,
    Andy

  2. #2
    Join Date
    Aug 2012
    Posts
    2

    Default

    Update:

    Changing part of web.xml to the following prevents the error when loading http://localhost:8080/Pizza/controll...owId=main-flow
    Code:
    	<servlet-mapping>
    		<servlet-name>Faces Servlet</servlet-name>
    		<url-pattern>*.xhtml</url-pattern>
    	</servlet-mapping>
    But instead I receive an error similar to the (404) I get on my expected URL;

    Code:
    type Status report
    message /Pizza/controller.faces
    description The requested resource (/Pizza/controller.faces) is not available.
    If it wasn't already clear, I'm not really sure what I'm looking at here - but it looks like I just have one problem now, the 404 messages.

    Any help appreciated.

    Thanks,
    Andy

Tags for this Thread

Posting Permissions

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