Results 1 to 3 of 3

Thread: View seems to be not mapped correctly (Webflow 2.2.1 with JSF 2.0 on OSGi)

  1. #1
    Join Date
    Jun 2012
    Posts
    3

    Question View seems to be not mapped correctly (Webflow 2.2.1 with JSF 2.0 on OSGi)

    Hi all,

    I am fighting a couple of days now in getting Spring Web Flow & JSF 2.0 running correctly within an OSGi container. The overall deployment seems to be fine, however when Web Flow tries to render the first view of my flow I get a FileNotFoundException which indicates that the first view is mapped incorrectly when navigating to 'http://localhost:8080/org.scoaring.web.war/spring/main' (the full stack is trace is further below):

    Code:
    java.io.FileNotFoundException: C:\Dateien\eclipse\sauerlandwettbewerb\org.scoaring.web.war\testPage.xhtml (Das System kann die angegebene Datei nicht finden)
    	at java.io.FileInputStream.open(Native Method)
    I *think* the URL should be 'C:\Dateien\eclipse\sauerlandwettbewerb\org.scoari ng.web.war\spring\main\testPage.xhtml' instead, however I am very new to Spring Web Flow & Spring MVC.

    I tried to debug a bit and found out that the final 'testPage' URL is constructed in the following class: 'com.sun.faces.facelets.impl.DefaultFaceletFactory '. The code snippet creating the problematic URL is the following:
    Code:
        public URL resolveURL(URL source, String path) throws IOException {
            if (path.startsWith("/")) {
                URL url = this.resolver.resolveUrl(path);
                if (url == null) {
                    throw new FileNotFoundException(path
                                                    + " Not Found in ExternalContext as a Resource");
                }
                return url;
            } else {
                return new URL(source, path);
            }
        }
    with:
    Code:
    source=file:/C:/Dateien/eclipse/sauerlandwettbewerb/org.scoaring.web.war/
    path=testPage.xhtml
    Hence the resulting URL 'C:\Dateien\eclipse\sauerlandwettbewerb\org.scoari ng.web.war\testPage.xhtml' is constructed and stored in the internal 'relativeLocations' map.

    I am now a bit stucked since I am lacking Spring Web Flow & MVC knowledge. Does anybody have an idea what's going wrong or a pointer how to proceed? One thing to note is that I try to execute the tests in an OSGi container (Eclipse Virgo 3.0.3 / Equinox). I have the same problem for both Jetty and Tomcat as the underlying Servlet Container (in case of Tomcat a 'jndi' URL is constructed though).


    thanks and best regards,
    David

    (additional information in the next post)

  2. #2
    Join Date
    Jun 2012
    Posts
    3

    Default

    Additional information:
    Spring version: 3.0.7
    Spring Web flow version: 2.2.1
    JSF implementation: Mojarra 2.0.9

    I took the 'swf-booking-sample' as a basis and have the following setup ('main' is the flow I would like to execute):
    Code:
    + WEB-INF
    +   config
          web-application-config.xml
          webflow-config.xml
          webmvc-config.xml
    +   flows
    +     main
            main-flow.xml
            testPage.xhtml
            testPage2.xhtml
    -   layouts
        web.xml
    main-flow.xml:
    HTML 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">
    
      <!-- just to check if *something* is working -->
      <action-state id="blub">
        <evaluate expression="true" />
        <transition to="testPage" />
      </action-state>
    
      <view-state id="testPage">
        <transition on="submit" to="testPage2" />
      </view-state>
    
      <view-state id="testPage2">
        <transition on="submit" to="testPage2" />
      </view-state>
    
      <end-state id="finish" />
    
    </flow>
    webmvc-config.xml:
    HTML 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:faces="http://www.springframework.org/schema/faces"
      xsi:schemaLocation="
           	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           	http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces-2.0.xsd">
    
      <faces:resources />
    
      <!-- Maps request paths to flows in the flowRegistry; e.g. a path of /hotels/booking 
        looks for a flow with id "hotels/booking" -->
      <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
        <property name="order" value="1" />
        <property name="flowRegistry" ref="flowRegistry" />
        <property name="defaultHandler">
          <!-- If no flow match, map path to a view to render; e.g. the "/intro" 
            path would map to the view named "intro" -->
          <bean
            class="org.springframework.web.servlet.mvc.UrlFilenameViewController">
          </bean>
        </property>
      </bean>
    
      <!-- Maps logical view names to Facelet templates in /WEB-INF (e.g. 'search' 
        to '/WEB-INF/search.xhtml' -->
      <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>
    
      <!-- Dispatches requests mapped to org.springframework.web.servlet.mvc.Controller 
        implementations -->
      <bean
        class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
    
      <!-- Dispatches requests mapped to flows to FlowHandler implementations -->
      <bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
        <property name="flowExecutor" ref="flowExecutor" />
      </bean>
    
    </beans>
    webflow-config.xml (I skipped the JPA and security parts of the sample for now):
    HTML 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-2.5.xsd
               http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
               http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces-2.0.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="facesFlowBuilderServices" base-path="/WEB-INF/flows">
        <webflow:flow-location-pattern value="/**/*-flow.xml" />
      </webflow:flow-registry>
    	
    	<!-- Configures the Spring Web Flow JSF integration -->
    	<faces:flow-builder-services id="facesFlowBuilderServices" development="true" />
    
    	<!-- Installs a listener that creates and releases the FacesContext for each request. -->
    	<bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>
    
    </beans>
    web.xml:
    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <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">
    
      <context-param>
        <param-name>contextClass</param-name>
        <param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
      </context-param>
    
      <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
          /WEB-INF/config/web-application-config.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>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
      </context-param>
    
      <context-param>
        <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
        <param-value>1</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>charEncodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
          <param-name>encoding</param-name>
          <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
          <param-name>forceEncoding</param-name>
          <param-value>true</param-value>
        </init-param>
      </filter>
    
      <filter-mapping>
        <filter-name>charEncodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
    
      <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
    
      <servlet>
        <servlet-name>org.scoaring.web.war</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>org.scoaring.web.war</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>

  3. #3
    Join Date
    Jun 2012
    Posts
    3

    Default

    full stack trace:
    Code:
    java.io.FileNotFoundException: C:\Dateien\eclipse\sauerlandwettbewerb\org.scoaring.web.war\testPage.xhtml (Das System kann die angegebene Datei nicht finden)
    	at java.io.FileInputStream.open(Native Method)
    	at java.io.FileInputStream.<init>(FileInputStream.java:138)
    	at java.io.FileInputStream.<init>(FileInputStream.java:97)
    	at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
    	at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
    	at com.sun.faces.facelets.impl.DefaultFaceletCache._getLastModified(DefaultFaceletCache.java:161)
    	at com.sun.faces.facelets.impl.DefaultFaceletCache.access$000(DefaultFaceletCache.java:62)
    	at com.sun.faces.facelets.impl.DefaultFaceletCache$1.newInstance(DefaultFaceletCache.java:82)
    	at com.sun.faces.facelets.impl.DefaultFaceletCache$1.newInstance(DefaultFaceletCache.java:78)
    	at com.sun.faces.util.ExpiringConcurrentCache$1.call(ExpiringConcurrentCache.java:99)
    	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    	at com.sun.faces.util.ExpiringConcurrentCache.get(ExpiringConcurrentCache.java:114)
    	at com.sun.faces.facelets.impl.DefaultFaceletCache.getFacelet(DefaultFaceletCache.java:119)
    	at com.sun.faces.facelets.impl.DefaultFaceletCache.getFacelet(DefaultFaceletCache.java:62)
    	at com.sun.faces.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:248)
    	at com.sun.faces.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:193)
    	at com.sun.faces.application.view.FaceletViewHandlingStrategy.buildView(FaceletViewHandlingStrategy.java:741)
    	at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:100)
    	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    	at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    	at org.springframework.faces.webflow.FlowLifecycle.render(FlowLifecycle.java:80)
    	at org.springframework.faces.webflow.JsfView.render(JsfView.java:90)
    	at org.springframework.webflow.engine.ViewState.render(ViewState.java:314)
    	at org.springframework.webflow.engine.ViewState.refresh(ViewState.java:265)
    	at org.springframework.webflow.engine.ViewState.resume(ViewState.java:243)
    	at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
    	at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
    	at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
    	at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
    	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
    	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
    	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:565)
    	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1361)
    	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1332)
    	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:477)
    	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
    	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:499)
    	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
    	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
    	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
    	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
    	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:965)
    	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
    	at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
    	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
    	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
    	at org.eclipse.jetty.server.Server.handle(Server.java:348)
    	at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
    	at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:884)
    	at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:938)
    	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:630)
    	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
    	at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:77)
    	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:606)
    	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:46)
    	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
    	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
    	at java.lang.Thread.run(Thread.java:722)

Posting Permissions

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