DWR Spring JPA

View: New views
5 Messages — Rating Filter:   Alert me  

DWR Spring JPA

by Shardul Bhatt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I am using Spring, JPA and DWR with Annotations.

I have exposed methods of the SerivceClass and and calling these methods using DWR. The Service Class
then uses

WebContextFactory.get().forwardToString("/serch.do?searchString=" + searchString); to invoke the SearchController.

It sems that when a request i sent to he Controller in the manner mentioned above, the Shared EntityManager does not bind with the request and the application tries to create another instance of the Entity Manager which closes before the request is processed....

please find the trace below..

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
13:56:55,532 ERROR YGGenericDAO:55 - YGPropertyDAOImpl : Something went wrong executing getPropertyIdsForName for Search String


I need help to resolve this issue...

Thanks,
Shardul.

Re: DWR Spring JPA

by XMaNIaC :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That's not a DWR issue. A new thread creates a new entity manager,
seems correct to me.

Regards

On Wed, Oct 14, 2009 at 11:13 AM, Shardul Bhatt <shardul.bhatt@...> wrote:

>
> Hi All,
>
> I am using Spring, JPA and DWR with Annotations.
>
> I have exposed methods of the SerivceClass and and calling these methods
> using DWR. The Service Class
> then uses
>
> WebContextFactory.get().forwardToString("/serch.do?searchString=" +
> searchString); to invoke the SearchController.
>
> It sems that when a request i sent to he Controller in the manner mentioned
> above, the Shared EntityManager does not bind with the request and the
> application tries to create another instance of the Entity Manager which
> closes before the request is processed....
>
> please find the trace below..
>
> 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
> 13:56:55,532 ERROR YGGenericDAO:55 - YGPropertyDAOImpl : Something went
> wrong executing getPropertyIdsForName for Search String
>
> I need help to resolve this issue...
>
> Thanks,
> Shardul.
>
> --
> View this message in context: http://www.nabble.com/DWR-Spring-JPA-tp25887746p25887746.html
> Sent from the DWR - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: DWR Spring JPA

by Shardul Bhatt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the answer, it indeed is not a DWR issue...

The problem was with the configuration of the "OpenEntityManagerInViewFilter" in the web.xml.

It should be mapped <url-pattern>/*</url-pattern> to handle DWR requests.

Regards,
Shardul.


XMaNIaC wrote:
That's not a DWR issue. A new thread creates a new entity manager,
seems correct to me.

Regards

On Wed, Oct 14, 2009 at 11:13 AM, Shardul Bhatt <shardul.bhatt@gmail.com> wrote:
>
> Hi All,
>
> I am using Spring, JPA and DWR with Annotations.
>
> I have exposed methods of the SerivceClass and and calling these methods
> using DWR. The Service Class
> then uses
>
> WebContextFactory.get().forwardToString("/serch.do?searchString=" +
> searchString); to invoke the SearchController.
>
> It sems that when a request i sent to he Controller in the manner mentioned
> above, the Shared EntityManager does not bind with the request and the
> application tries to create another instance of the Entity Manager which
> closes before the request is processed....
>
> please find the trace below..
>
> 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
> 13:56:55,532 ERROR YGGenericDAO:55 - YGPropertyDAOImpl : Something went
> wrong executing getPropertyIdsForName for Search String
>
> I need help to resolve this issue...
>
> Thanks,
> Shardul.
>
> --
> View this message in context: http://www.nabble.com/DWR-Spring-JPA-tp25887746p25887746.html
> Sent from the DWR - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@dwr.dev.java.net
> For additional commands, e-mail: users-help@dwr.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@dwr.dev.java.net
For additional commands, e-mail: users-help@dwr.dev.java.net

Re: DWR Spring JPA

by Shardul Bhatt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I was able to integrate DWR with SPring using annotations...everything seemed to work fine until I tried persisting Data using the application.

This is the DWR Configuration...in the application-servlet.config.xml


       <dwr:configuration>
                <dwr:convert type="bean"  
                                  class="org.springframework.web.servlet.ModelAndView"></dwr:convert>
                <dwr:convert type="bean" class="com.yg.util.ResultPage"></dwr:convert>
                <dwr:convert type="bean" class="com.yg.model.*"></dwr:convert>
        </dwr:configuration>
       
        <dwr:annotation-config/>
        <dwr:url-mapping/>
        <dwr:controller id="dwrController" debug="true"/>
        <context:component-scan base-package="com.yoursgallery.*" />
               
    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
                <property name="order" value="1" />
        </bean>
        <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping">
                <property name="order" value="2" />
        </bean>


Before I integrated DWR - I used

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />

and things worked fine.

DWR does not work with    
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />

and gives

javax.servlet.ServletException: No adapter for handler [org.directwebremoting.spring.DwrController@19960e4]: Does your handler implement a supported interface like Controller?

Where am i messing up? Please help. Thanks in advance.

Shardul.

Re: DWR Spring JPA

by XMaNIaC :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This has been answered multiple times in the list. Please do a search. Basically you should substitute adapter for handler mapping.

Regards

On Thu, Oct 15, 2009 at 5:16 PM, Shardul Bhatt <shardul.bhatt@...> wrote:

Hi,

I was able to integrate DWR with SPring using annotations...everything
seemed to work fine until I tried persisting Data using the application.

This is the DWR Configuration...in the application-servlet.config.xml


      <dwr:configuration>
               <dwr:convert type="bean"

class="org.springframework.web.servlet.ModelAndView"></dwr:convert>
               <dwr:convert type="bean"
class="com.yoursgallery.util.ResultPage"></dwr:convert>
               <dwr:convert type="bean" class="com.yoursgallery.model.*"></dwr:convert>
       </dwr:configuration>

       <dwr:annotation-config/>
       <dwr:url-mapping/>
       <dwr:controller id="dwrController" debug="true"/>
       <context:component-scan base-package="com.yoursgallery.*" />

      <bean
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
               <property name="order" value="1" />
       </bean>
       <bean
class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
               <property name="order" value="2" />
       </bean>


Before I integrated DWR - I used

<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"
/>

and things worked fine.

DWR does not work with
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"
/>

and gives

javax.servlet.ServletException: No adapter for handler
[org.directwebremoting.spring.DwrController@19960e4]: Does your handler
implement a supported interface like Controller?

Where am i messing up? Please help. Thanks in advance.

Shardul.
--
View this message in context: http://www.nabble.com/DWR-Spring-JPA-tp25887746p25910444.html
Sent from the DWR - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...