views:

396

answers:

2

Background

The application I am working on currently uses Spring + JPA. Everything was working fine before we decided to introduce DWR.

Using DWR I invoke a method on a Service class and it then redirects to the Controller.

try{
      return WebContextFactory.get()
                        .forwardToString("/search.do?searchString=" + searchString);
}catch(...){

}

After this, when the search method is invoked at the DAO, it does not find an pen session.

Session session = (Session) entityManager.getDelegate();

This session here is closed...

I think my changes(of introducing DWR) should not in any way affect the Session creation.

Awaiting inputs.

Shardul.

A: 

This is the trace I get in the logs....


13:56:55,501 DEBUG DefaultAnnotationHandlerMapping:176 - Mapping [/search.do] to handler 'com.xxxxx.controller.YGSearchController@a262c1'

13:56:55,517 DEBUG HandlerMethodInvoker:134 - Invoking request handler method: public java.lang.String com.xxxxx.controller.YGSearchController.search(java.lang.String,java.lang.String,int,int,boolean,boolean,javax.servlet.http.HttpServletRequest,org.springframework.ui.Model)

13:56:55,517 DEBUG YGGenericDAO:29 - YGPropertyDAOImpl : In getPropertyIdsForName for Search Strings

13:56:55,517 DEBUG SharedEntityManagerCreator$SharedEntityManagerInvocationHandler:189 - Creating new EntityManager for shared EntityManager invocation

13:56:55,517 DEBUG SessionImpl:247 - opened session at timestamp: 12555088155

13:56:55,517 DEBUG EntityManagerFactoryUtils:313 - Closing JPA EntityManager


The Session is opened and closed before the request is entirely processed...


13:56:55,532 DEBUG DispatcherServlet:588 - Could not complete request java.lang.NullPointerException at com.x.service.impl.YGSearchServiceImpl.search(YGSearchServiceImpl.java:101)


This is the trace from the console


org.hibernate.SessionException: Session is closed! at org.hibernate.impl.AbstractSessionImpl.errorIfClosed(AbstractSessionImpl.java:72) at

org.hibernate.impl.SessionImpl.createCriteria(SessionImpl.java:1535) at com.x.dao.impl.YGPropertyDAOImpl.getPropertyIdsForName(YGPropertyDAOImpl.java:32)


Any comments?

SB
+1  A: 

Issue resolved.

The problem was with the configuration of OpenEntityManagerInViewFilter in the web.xml. It was not intercepting the DWR requests as it was mapped to a

*.do

instead of

/*

Shardul.

SB

related questions