struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frans Thamura <fr...@meruvian.org>
Subject Re: @Transactional Spring Annotation in a Struts2 Action does not work
Date Tue, 05 May 2009 04:24:42 GMT
will u make a tiny tutori for your work like struts-spring-ajax and
put in the wiki of S2

that will be awesome ;)

F

On Tue, May 5, 2009 at 10:17 AM, Mauricio Aniche
<mauricioaniche@gmail.com> wrote:
> Wes,
>
> I just put the proxy-target-class="true", put all cglib and its dependencies
> and everything worked!
>
> Thanks in advance,
> Mauricio
>
> On Fri, May 1, 2009 at 9:32 AM, Wes Wannemacher <wesw@wantii.com> wrote:
>
>> See if you can force Spring to use CGLIB proxies... JDK proxies are
>> interface-based, so unless you are implementing an interface that
>> exposes all of the methods you will interact with (Action interface
>> has no methods, IIRC), then AOP / @Transactional won't work right.
>>
>> Although, carry on with the Service layer discussion, I agree with
>> that and take my fix as no indication that I would ever try to make an
>> Action transactional (wink).
>>
>> -Wes
>>
>> On Thu, Apr 30, 2009 at 10:41 PM, Mauricio Aniche
>> <mauricioaniche@gmail.com> wrote:
>> > Hi Jeroen,
>> >
>> > The problem is that I am not a big fan of services layer. Sometimes it
>> looks
>> > very anemic to me. But I totally agree with you when you say the action
>> > should not know about persistence problems, and that's why I want to do
>> it
>> > via AOP.
>> >
>> > I had the same thought about the problem: the Spring proxy does not work
>> > properly with all the magic Struts2 and Reflection do!
>> >
>> > I tried to open a bug in the Struts2 JIRA, but they closed it and said
>> that
>> > it works. I think it should be some kind of spring or struts
>> configuration I
>> > am not doing right.
>> >
>> > Thanks in advance,
>> > Mauricio
>> >
>> > On Thu, Apr 30, 2009 at 11:22 PM, Jeroen De Ridder <voetsjoeba@gmail.com
>> >wrote:
>> >
>> >> You really shouldn't be making your Struts 2 actions @Transactional.
>> Doing
>> >> that causes Spring to create a proxy so it can put some extra
>> >> transaction-handling logic between the method call and the actual
>> method.
>> >> The thing is, Struts 2 and OGNL rely heavily on reflection on the action
>> >> classes which simply does not work at all with the proxies created by
>> >> Spring.
>> >>
>> >> Regardless, making your actions @Transactional means mixing persistence
>> >> concerns with controller logic in the same class. You should consider
>> >> keeping the two separated. For example, the service approach is a good
>> >> start:
>> >> http://struts.apache.org/2.0.14/docs/struts-2-spring-2-jpa-ajax.html.
>> >>
>> >>
>> >>  Yes, I am. Everything works fine when I don't try to use Spring
>> >>> transactional AOP!
>> >>>
>> >>> Mauricio
>> >>>
>> >>> On Thu, Apr 30, 2009 at 9:43 PM, Dave Newton <newton.dave@yahoo.com>
>> >>> wrote:
>> >>>
>> >>>
>> >>>
>> >>>> Mauricio Aniche wrote:
>> >>>>
>> >>>>
>> >>>>
>> >>>>> I am using Struts2+Spring+JPA/Hibernate. When I use the
>> @Transactional
>> >>>>> to
>> >>>>> mark an execute() method in a Struts2 Action, the action stops
>> working
>> >>>>> properly (i.e. the attributes in the action are not automatically
>> >>>>> setted).
>> >>>>> It does not work with Spring AOP transactions as well.
>> >>>>>
>> >>>>> In my struts.config I setted the following constant:
>> >>>>> ----
>> >>>>> <constant name="struts.objectFactory" value="spring" />
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>> You're using the Spring plugin, correct?
>> >>>>
>> >>>> Dave
>> >>>>
>> >>>>
>> >>>> ---------------------------------------------------------------------
>> >>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >>>> For additional commands, e-mail: user-help@struts.apache.org
>> >>>>
>> >>>>
>> >>>>
>> >>>>
>> >>>
>> >>>
>> >>>
>> >>
>> >>
>> >
>>
>>
>>
>> --
>> Wes Wannemacher
>> Author - Struts 2 In Practice
>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
>> http://www.manning.com/wannemacher
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>



-- 
-- 
Frans Thamura
Meruvian. Java and Enterprise OSS

Mobile: +62 855 7888 699
Blog & Profile: http://frans.thamura.info

We provide services to migrate your apps to Java (web), in amazing
fast and reliable.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message