Reputation: 5331
I am getting strange error in spring webflow.
2019-06-07 15:04:39.026 ERROR 29470 --- [nio-8096-exec-8] o.a.c.c.C.[.[.[.[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException: null
at org.springframework.webflow.execution.repository.support.AbstractFlowExecutionRepository.getConversation(AbstractFlowExecutionRepository.java:170) ~[spring-webflow-2.4.4.RELEASE.jar:2.4.4.RELEASE]
at org.springframework.webflow.execution.repository.support.AbstractFlowExecutionRepository.getLock(AbstractFlowExecutionRepository.java:125) ~[spring-webflow-2.4.4.RELEASE.jar:2.4.4.RELEASE]
at org.springframework.webflow.executor.FlowExecutorImpl.launchExecution(FlowExecutorImpl.java:142) ~[spring-webflow-2.4.4.RELEASE.jar:2.4.4.RELEASE]
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:263) ~[spring-webflow-2.4.4.RELEASE.jar:2.4.4.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
This is happening inside spring webflow library and I completely not know why. My flow looks like:
<action-state id="checkProductAvailable">
<evaluate expression="knowledgeSourceService.test(requestParameters.productUUid, requestParameters._eventId)"/>
<transition on="internet" to="validateAndProceedToSummary">
<evaluate expression="knowledgeSourceService.extractCustomerSelectedSourceFromRequest(requestParameters)"
result="flowScope.customerSelectedSource"/>
<evaluate expression="knowledgeSourceService.enhanceProductData(requestParameters.productUUid)"
result="conversationScope.selectedProduct"/>
</transition>
<transition on="requireProducts" to="products" />
</action-state>
<decision-state id="validateAndProceedToSummary">
<if test="knowledgeSourceService.updateCustomerSelection(flowScope.customerSelectedSource, flowScope.productList.selectedProduct.customerSelectedSource)"
then="proceedToSummary" else="invalidateFormState"/>
</decision-state>
When I change transition from validateAndProceedToSummary
back to products
it works without any errors. But with this validateAndProceedToSummary
decision state it fails.
products
is view state:
<view-state id="products" view="invest-flow-products" model="productList">
Can You help me?
knowledgeSourceService.updateCustomerSelection(flowScope.customerSelectedSource, flowScope.productList.selectedProduct.customerSelectedSource)
is calling method:
public boolean updateCustomerSelection(String old, String new) {
But as far I see it dosnt reach this method (I'put breakpoint) for success path (proceedToSummary
). It reach only when fail path is executed (invalidateFormState
). So like some precondition is not filled. But not know which. Can We somehow debug it?
Upvotes: 2
Views: 388
Reputation: 104
If the updateCustomerSelection() is returning wrapper boolean, then we need to check for null value as it is possible that wrapper boolean can hold null value also.
Below code should solve the NPE problem:
if (null != updateCustomerSelection() && updateCustomerSelection()) {
//code
}
or if you are using apache commons library, then you can write as shown below:
if (BooleanUtils.isTrue(updateCustomerSelection())) {
//code
}
Upvotes: 0