2017-05-14 57 views
0

我呼吁ProcessOrder调用从春季Webflow的功能在数据库中存储(MySQL的)

@Id 
@GeneratedValue 
private int id; 

private String productname; 

private int customerid; 

private String customerName; 

private String shippingAdress; 

private int productid; 

private int quantity; 

private int status; 

以下POJO和这个类叫做CartItem

@Id 
    @GeneratedValue 
    private int cartItemId; 

@ManyToOne 
@JoinColumn(name = "cartId") 
@JsonIgnore 
private Cart cart; 

@ManyToOne 
@JoinColumn(name = "productId") 
private Product product; 

private int quantity; 
private double totalPrice; 

这个类叫车

@Id 
    @GeneratedValue 
    private int cartId; 

@OneToMany(mappedBy = "cart", cascade = CascadeType.ALL, fetch = FetchType.EAGER) 
private List<CartItem> cartItems; 

@OneToOne 
@JoinColumn(name = "customerId") 
@JsonIgnore 
private Customer customer; 

private double grandTotal; 

以下类叫做CustomerOrder

@Id 
    @GeneratedValue 
    private int customerOrderId; 

@OneToOne 
@JoinColumn(name = "cartId") 
private Cart cart; 

@OneToOne 
@JoinColumn(name = "customerId") 
private Customer customer; 

@OneToOne 
@JoinColumn(name = "billingAddressId") 
private BillingAddress billingAddress; 

@OneToOne 
@JoinColumn(name="shippingAddressId") 
private ShippingAddress shippingAddress; 

我有更多的课程,但它们与问题无关。

还有一个弹簧weblfow与以下XML片段。

<var name="order" class="com.emusicstore.model.CustomerOrder" /> 

<action-state id="processOrder"> 
    <evaluate expression="CartItemDaoImpl.removeAllCartItemsCart(order.cart)" /> 
    <transition to="thankCustomer" /> 

和CartItemDaoImpl的removeAllCartItemsCart功能如下

public void removeAllCartItemsCart(Cart cart) { 
     List<CartItem> cartItems = cart.getCartItems(); 

    Session session = sessionFactory.getCurrentSession(); 
    int cusid = cart.getCustomer().getCustomerId(); 
    System.out.println(cusid); 

    for (CartItem item : cartItems) { 
     int pid = item.getProduct().getProductId(); 
     Query query=session.createQuery("from ProcessOrder where customerid= ? and productid= ?"); 
     query.setInteger(0, cusid); 
     query.setInteger(1, pid); 
     ProcessOrder pOrder1 =(ProcessOrder) query.uniqueResult(); 
     if(pOrder1!=null){ 
      pOrder1.setStatus(5); 
      session.saveOrUpdate(pOrder1); 
     } 
     //query.executeUpdate(); 
     removeCartItem(item); 
    } 
} 

运行这给了我一个例外,它的我附加的屏幕截图。我无法想出摆脱它的办法。从webflow调用函数后可以连接到数据库吗?

Exception Screenshot

EDIT 1

以下是堆栈跟踪

SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/emusicstore] threw exception [Request processing failed; nested exception is org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [Annot[email protected] targetAction = [[email protected] expression = CartItemDaoImpl.removeAllCartItemsCart(order.cart), resultExpression = [null]], attributes = map[[empty]]] in state 'processOrder' of flow 'checkout' -- action execution attributes were 'map[[empty]]'] with root cause 
org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 0): Property or field 'CartItemDaoImpl' cannot be found on object of type 'org.springframework.webflow.engine.impl.RequestControlContextImpl' - maybe not public? 
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:226) 
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:93) 
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:81) 
    at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:51) 
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:87) 
    at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:131) 
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:299) 
    at org.springframework.binding.expression.spel.SpringELExpression.getValue(SpringELExpression.java:84) 
    at org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:75) 
    at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188) 
    at org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145) 
    at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51) 
    at org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:101) 
    at org.springframework.webflow.engine.State.enter(State.java:194) 
    at org.springframework.webflow.engine.Transition.execute(Transition.java:227) 
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.execute(FlowExecutionImpl.java:393) 
    at org.springframework.webflow.engine.impl.RequestControlContextImpl.execute(RequestControlContextImpl.java:214) 
    at org.springframework.webflow.engine.TransitionableState.handleEvent(TransitionableState.java:119) 
    at org.springframework.webflow.engine.Flow.handleEvent(Flow.java:555) 
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.handleEvent(FlowExecutionImpl.java:388) 
    at org.springframework.webflow.engine.impl.RequestControlContextImpl.handleEvent(RequestControlContextImpl.java:210) 
    at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:232) 
    at org.springframework.webflow.engine.ViewState.resume(ViewState.java:196) 
    at org.springframework.webflow.engine.Flow.resume(Flow.java:545) 
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:258) 
    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:943) 
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) 
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) 
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) 
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) 
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) 
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50) 
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) 
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) 
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) 
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) 
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) 
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) 
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 

编辑2

CartItemDaoImpl

package com.emusicstore.dao.impl; 

import com.emusicstore.dao.CartItemDao; 
import com.emusicstore.model.Cart; 
import com.emusicstore.model.CartItem; 
import com.emusicstore.model.ProcessOrder; 

import org.hibernate.Query; 
import org.hibernate.Session; 
import org.hibernate.SessionFactory; 
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.stereotype.Repository; 
import org.springframework.transaction.annotation.Transactional; 

import java.util.List; 


@Repository 
@Transactional 
public class CartItemDaoImpl implements CartItemDao{ 

    @Autowired 
    private SessionFactory sessionFactory; 

    public void addCartItem(CartItem cartItem) { 
     Session session = sessionFactory.getCurrentSession(); 
     session.saveOrUpdate(cartItem); 
     session.flush(); 
    } 

    public void removeCartItem (CartItem cartItem) { 
     Session session = sessionFactory.getCurrentSession(); 
     session.delete(cartItem); 
     session.flush(); 
    } 


    public void removeAllCartItemsCart(Cart cart) { 
     List<CartItem> cartItems = cart.getCartItems(); 

     Session session = sessionFactory.getCurrentSession(); 
     int cusid = cart.getCustomer().getCustomerId(); 
     System.out.println(cusid); 

     for (CartItem item : cartItems) { 
      int pid = item.getProduct().getProductId(); 
      Query query=session.createQuery("from ProcessOrder where customerid= ? and productid= ?"); 
      query.setInteger(0, cusid); 
      query.setInteger(1, pid); 
      ProcessOrder pOrder1 =(ProcessOrder) query.uniqueResult(); 
      if(pOrder1!=null){ 
       pOrder1.setStatus(5); 
       session.saveOrUpdate(pOrder1); 
      } 
      //query.executeUpdate(); 
      removeCartItem(item); 
     } 
    } 

    public void removeAllCartItems(Cart cart) { 
     List<CartItem> cartItems = cart.getCartItems(); 
     for (CartItem item : cartItems) { 
      removeCartItem(item); 
     } 
    } 

    public CartItem getCartItemByProductId (int productId) { 
     Session session = sessionFactory.getCurrentSession(); 
     Query query = session.createQuery("from CartItem where productId = ?"); 
     query.setInteger(0, productId); 
     session.flush(); 

     return (CartItem) query.uniqueResult(); 
    } 
} 

EDIT 3

以下列出了在一个Webflow xml文件

SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/emusicstore] threw exception [Request processing failed; nested exception is org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [[email protected] targetAction = [[email protected] expression = cartItemDaoImpl.removeAllCartItemsCart(order.cart), resultExpression = [null]], attributes = map[[empty]]] in state 'processOrder' of flow 'checkout' -- action execution attributes were 'map[[empty]]'] with root cause 
org.springframework.expression.spel.SpelEvaluationException: EL1004E:(pos 16): Method call: Method removeAllCartItemsCart(com.emusicstore.model.Cart) cannot be found on com.sun.proxy.$Proxy60 type 
    at org.springframework.expression.spel.ast.MethodReference.findAccessorForMethod(MethodReference.java:211) 
    at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:125) 
    at org.springframework.expression.spel.ast.MethodReference.access$000(MethodReference.java:49) 
    at org.springframework.expression.spel.ast.MethodReference$MethodValueRef.getValue(MethodReference.java:342) 
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88) 
    at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:131) 
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:299) 
    at org.springframework.binding.expression.spel.SpringELExpression.getValue(SpringELExpression.java:84) 
    at org.springframework.webflow.action.EvaluateAction.doExecute(EvaluateAction.java:75) 
    at org.springframework.webflow.action.AbstractAction.execute(AbstractAction.java:188) 
    at org.springframework.webflow.execution.AnnotatedAction.execute(AnnotatedAction.java:145) 
    at org.springframework.webflow.execution.ActionExecutor.execute(ActionExecutor.java:51) 
    at org.springframework.webflow.engine.ActionState.doEnter(ActionState.java:101) 
    at org.springframework.webflow.engine.State.enter(State.java:194) 
    at org.springframework.webflow.engine.Transition.execute(Transition.java:227) 
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.execute(FlowExecutionImpl.java:393) 
    at org.springframework.webflow.engine.impl.RequestControlContextImpl.execute(RequestControlContextImpl.java:214) 
    at org.springframework.webflow.engine.TransitionableState.handleEvent(TransitionableState.java:119) 
    at org.springframework.webflow.engine.Flow.handleEvent(Flow.java:555) 
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.handleEvent(FlowExecutionImpl.java:388) 
    at org.springframework.webflow.engine.impl.RequestControlContextImpl.handleEvent(RequestControlContextImpl.java:210) 
    at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:232) 
    at org.springframework.webflow.engine.ViewState.resume(ViewState.java:196) 
    at org.springframework.webflow.engine.Flow.resume(Flow.java:545) 
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:258) 
    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:943) 
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:877) 
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966) 
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647) 
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330) 
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118) 
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50) 
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87) 
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342) 
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192) 
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160) 
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344) 
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) 
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) 
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408) 
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041) 
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603) 
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at java.lang.Thread.run(Thread.java:745) 

在cartItemDaoImpl改变的C的情况下继后的堆栈跟踪弹簧Webflow的xml文件

<?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"> 

    <var name="order" class="com.emusicstore.model.CustomerOrder" /> 

    <action-state id="addCartToOrder"> 
     <evaluate expression="cartDaoImpl.validate(requestParameters.cartId)" result="order.cart" /> 
     <transition to="InvalidCartWarning" on-exception="java.io.IOException" /> 
     <transition to="collectCustomerInfo" /> 
    </action-state> 

    <view-state id="collectCustomerInfo" view="collectCustomerInfo.jsp" model="order"> 
     <transition on="customerInfoCollected" to="collectShippingDetail" /> 
    </view-state> 

    <view-state id="collectShippingDetail" view="collectShippingDetail.jsp" model="order"> 
     <transition on="shippingDetailCollected" to="orderConfirmation" /> 
     <transition on="backToCollectCustomerInfo" to="collectCustomerInfo" /> 
    </view-state> 

    <view-state id="orderConfirmation"> 
     <transition on="orderConfirmed" to="processOrder" /> 
     <transition on="backToCollectShippingDetail" to="collectShippingDetail" /> 
    </view-state> 

    <action-state id="processOrder"> 
     <evaluate expression="cartItemDaoImpl.removeAllCartItemsCart(order.cart)" /> 
     <transition to="thankCustomer" /> 
    </action-state> 

    <view-state id="thankCustomer" model="order"> 
     <transition to="endState" /> 
    </view-state> 

    <end-state id="endState" /> 

    <view-state id="invalidCartWarning"> 
     <transition to="endState" /> 
    </view-state> 

    <end-state id="cancelCheckout" view="checkOutCancelled.jsp" /> 

    <global-transitions> 
     <transition on="cancel" to="cancelCheckout" /> 
    </global-transitions> 
</flow> 

另外我只是想强调一下,如果我只是将removeAllCartItemsCart方法更改为

public void removeAllCartItemsCart(Cart cart) { 
     List<CartItem> cartItems = cart.getCartItems(); 
     for (CartItem item : cartItems) { 

      removeCartItem(item); 
     } 
    } 

它工作得很好。所以我猜测它跟我试图在那里执行查询有关。

+0

请从日志(不是来自浏览器的图像)添加堆栈跟踪。 –

+0

@ v.ladynev编辑了这个问题。 – user3508140

+0

您没有为CartItemDaoImpl使用正确的bean名称。我的猜测是'cartItemDaoImpl'或'cartItemDao' – rptmat57

回答

1

注释@Repository正在创建一个默认名称为cartItemDaoImpl的bean。

您可以了解有关默认命名约定here的信息。

所以,你应该使用

<evaluate expression="cartItemDaoImpl.removeAllCartItemsCart(order.cart)" /> 

以小写开始c

或者让你的代码,但改变你的注释@Repository("CartItemDaoImpl")

[更新]

你现在有一个不同的问题。您正在使用@Transactional,但对于Spring AOP,Aspects只有在由于代理而处于接口中的方法时才有效。

所以你现在要做的是将void removeAllCartItemsCart(Cart cart);添加到您的界面CartItemDao

+0

我纠正了这一点。但它仍然不起作用。同样的错误。 – user3508140

+0

你可以发布你的webflow配置文件吗? – rptmat57

+0

并更新堆栈跟踪错误应该略有不同 – rptmat57