2012-09-19 43 views
1

我是Spring的新手。我試圖運行一個名爲library的自學項目,在Tomcat上使用Spring web流。作爲IDE,我使用Eclipse Indigo。使用Eclipse Indigo的Tomcat 6.0.35上的Spring Web Flow

我的項目的WebContent文件夾結構如下:

WebContent 
    pages 
     welcome 
      - introduction.jsp 
      - menu.jsp 
      - welcome.jsp 
      - welcome.xml 
    WEB-INF 
     - library-service.xml 
     - library-servlet.xml 
     - library-webflow.xml 
     - web.xml 
     lib 
      - commons-logging.jar 
      - jstl.jar 
      - ognl-2.6.9.jar 
      - org.springframework.binding-2.0.9.RELEASE.jar 
      - org.springframework.js-2.0.9.RELEASE.jar 
      - org.springframework.webflow-2.0.9.RELEASE.jar 
      - spring.jar 
      - spring-webmvc.jar 
      - standard.jar 

由於內容web.xml中,它是如下:

<display-name>library</display-name> 

<context-param> 
    <param-name>contextConfigLocation</param-name> 
<param-value>/WEB-INF/library-service.xml</param-value> 
</context-param> 

<listener> 
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
</listener> 

<servlet> 
    <servlet-name>library</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
</servlet> 

<servlet-mapping> 
    <servlet-name>library</servlet-name> 
    <url-pattern>/pages/*</url-pattern> 
</servlet-mapping> 

庫servlet.xml中的內容如下:

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> 

    <import resource="library-webflow.xml" /> 

</beans> 

我已經使用library-service.xml來從服務層聲明bean。其內容如下:

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> 

<bean name="libraryService" 
    class="com.library.service.LibraryService" /> 

</beans> 

由於welcome.jsp頁面的內容,它是如下:

<html> 
<head> 
<title>Welcome</title> 
</head> 
<body> 
    <h2>Welcome!</h2> 
    <a href="${flowExecutionUrl}&_eventId=next">Next</a> 
    <a href="${flowExecutionUrl}&_eventId=skip">Skip</a> 
</body> 
</html> 

由於的welcome.xml的內容是:

<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="welcome"> 
     <transition on="next" to="introduction" /> 
     <transition on="skip" to="menu" /> 
</view-state> 

    <view-state id="introduction"> 
     <transition on="next" to="menu" /> 
    </view-state> 

    <view-state id="menu" /> 
</flow> 

我的問題是,當我運行welcome.jsp時,我在Tomcat中得到了下面的嵌套錯誤。我正在使用Tomcat 6.0.35。

Sep 19, 2012 4:41:11 PM org.apache.catalina.core.ApplicationDispatcher invoke 
SEVERE: Servlet.service() for servlet library threw exception 
java.lang.NullPointerException 
    at org.springframework.webflow.conversation.impl.ContainedConversation.unlock(ContainedConversation.java:107) 
    at org.springframework.webflow.execution.repository.support.ConversationBackedFlowExecutionLock.unlock(ConversationBackedFlowExecutionLock.java:55) 
    at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:178) 
    at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183) 
    at org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174) 
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) 
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875) 
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807) 
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) 
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646) 
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436) 
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374) 
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302) 
    at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:236) 
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:257) 
    at org.springframework.webflow.mvc.servlet.ServletMvcView.doRender(ServletMvcView.java:50) 
    at org.springframework.webflow.mvc.view.AbstractMvcView.render(AbstractMvcView.java:180) 
    at org.springframework.webflow.engine.ViewState.render(ViewState.java:282) 
    at org.springframework.webflow.engine.ViewState.refresh(ViewState.java:241) 
    at org.springframework.webflow.engine.ViewState.resume(ViewState.java:219) 
    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.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174) 
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) 
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875) 
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807) 
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) 
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) 
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) 
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) 
    at java.lang.Thread.run(Unknown Source) 

Sep 19, 2012 4:41:11 PM org.apache.catalina.core.StandardWrapperValve invoke 
SEVERE: Servlet.service() for servlet library threw exception 
java.lang.NullPointerException 
    at org.springframework.webflow.conversation.impl.ContainedConversation.unlock(ContainedConversation.java:107) 
    at org.springframework.webflow.execution.repository.support.ConversationBackedFlowExecutionLock.unlock(ConversationBackedFlowExecutionLock.java:55) 
    at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:178) 
    at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183) 
    at org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174) 
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48) 
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:875) 
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:807) 
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571) 
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:501) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293) 
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859) 
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602) 
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) 
    at java.lang.Thread.run(Unknown Source) 

我做錯了什麼?

+0

是,除了講述左右。 – duffymo

+0

:-)是的。我想知道哪裏錯了。 –

回答

0

嘗試添加一個Webflow XML到web.xml:

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>/WEB-INF/library-service.xml, /WEB-INF/library-webflow.xml</param-value> 
</context-param> 
+0

感謝duffymo,但它沒有區別。 –