Skip to main content

@Transactional in Spring not really using JTA

6 replies [Last post]
Anonymous

Hi,

I have Spring 2.5 configured to use JTA and TopLink. The logs show that
it detected JTA in GlassFish, and I am able to do SELECT queries with
JPA. When I try to add/change/delete a record it tells me that there is
no active transaction.

http://forum.springframework.org/showthread.php?t=60035

Can someone please help me? I am really stuck.

Thanks,
Ryan

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

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
monocongo
Offline
Joined: 2007-04-13

When you make your blog entry about this issue then please update this thread so I'll know about it. I seem to be stuck on similar issues and would like to see your solution. Thanks.

--James

Ryan de Laplante

I think you are referring to my own thread:

http://forums.java.net/jive/thread.jspa?messageID=294441&#294441

I thought I had it working but it turns out JTA isn't being used. When
I run select queries everything works great. When I do a
entityManager.merge(someEntity) it tells me that there is no active
transaction.

I found this thread in the Spring forums where someone else had the same
problem. They said switching to Hibernate for JPA provider made JTA work:

http://forum.springframework.org/showthread.php?t=36573

I'm going to give that a try shortly if I don't find another solution in
the GlassFish forums.

Thanks,
Ryan

Marina Vatkina wrote:
> Did you try to search GF forum? There were discussions about problems
> and solutions not so long ago.
>
> Regards,
> -marina
>
> Ryan de Laplante wrote:
>> Hi,
>>
>> I have Spring 2.5 configured to use JTA and TopLink. The logs show
>> that it detected JTA in GlassFish, and I am able to do SELECT queries
>> with JPA. When I try to add/change/delete a record it tells me that
>> there is no active transaction.
>>
>> http://forum.springframework.org/showthread.php?t=60035
>>
>> Can someone please help me? I am really stuck.
>>
>>
>> Thanks,
>> Ryan
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

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

Ryan de Laplante

I found the solution! When using JPA in Spring you have to tell the JPA
provider how to find the JTA transaction manager in persistence.xml :

For GlassFish's built-in TopLink Essentials (JPA RI) :

For Hibernate Entity Manager :

value="org.hibernate.transaction.SunONETransactionManagerLookup"/>

Nowhere on the Internet will you find a complete example on how to
create a Maven2 project to be run on GlassFish that uses the built-in
JTA and JPA providers, and only swap out EJB for Spring 2.5.5. Also how
to get the unit test environment set up for this. Soon I am going to
write a GlassFish Users FAQ and blog entry on how to do this.

Thanks,
Ryan

Ryan de Laplante wrote:
> I think you are referring to my own thread:
>
> http://forums.java.net/jive/thread.jspa?messageID=294441&#294441
>
> I thought I had it working but it turns out JTA isn't being used.
> When I run select queries everything works great. When I do a
> entityManager.merge(someEntity) it tells me that there is no active
> transaction.
>
> I found this thread in the Spring forums where someone else had the
> same problem. They said switching to Hibernate for JPA provider made
> JTA work:
>
> http://forum.springframework.org/showthread.php?t=36573
>
> I'm going to give that a try shortly if I don't find another solution
> in the GlassFish forums.
>
>
> Thanks,
> Ryan
>
>
>
> Marina Vatkina wrote:
>> Did you try to search GF forum? There were discussions about problems
>> and solutions not so long ago.
>>
>> Regards,
>> -marina
>>
>> Ryan de Laplante wrote:
>>> Hi,
>>>
>>> I have Spring 2.5 configured to use JTA and TopLink. The logs show
>>> that it detected JTA in GlassFish, and I am able to do SELECT
>>> queries with JPA. When I try to add/change/delete a record it tells
>>> me that there is no active transaction.
>>>
>>> http://forum.springframework.org/showthread.php?t=60035
>>>
>>> Can someone please help me? I am really stuck.
>>>
>>>
>>> Thanks,
>>> Ryan
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

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

Marina Vatkina

That makes sense, because when GlassFish is in charge, we do set this property
automatically for both, TLE, and Hibernate, to simplify user's access.

Regards,
-marina

Ryan de Laplante wrote:
> I found the solution! When using JPA in Spring you have to tell the JPA
> provider how to find the JTA transaction manager in persistence.xml :
>
> For GlassFish's built-in TopLink Essentials (JPA RI) :
>
>
>
>
>
>
> For Hibernate Entity Manager :
>
>
>
> value="org.hibernate.transaction.SunONETransactionManagerLookup"/>
>
>
>
> Nowhere on the Internet will you find a complete example on how to
> create a Maven2 project to be run on GlassFish that uses the built-in
> JTA and JPA providers, and only swap out EJB for Spring 2.5.5. Also how
> to get the unit test environment set up for this. Soon I am going to
> write a GlassFish Users FAQ and blog entry on how to do this.
>
> Thanks,
> Ryan
>
>
> Ryan de Laplante wrote:
>
>> I think you are referring to my own thread:
>>
>> http://forums.java.net/jive/thread.jspa?messageID=294441&#294441
>>
>> I thought I had it working but it turns out JTA isn't being used.
>> When I run select queries everything works great. When I do a
>> entityManager.merge(someEntity) it tells me that there is no active
>> transaction.
>>
>> I found this thread in the Spring forums where someone else had the
>> same problem. They said switching to Hibernate for JPA provider made
>> JTA work:
>>
>> http://forum.springframework.org/showthread.php?t=36573
>>
>> I'm going to give that a try shortly if I don't find another solution
>> in the GlassFish forums.
>>
>>
>> Thanks,
>> Ryan
>>
>>
>>
>> Marina Vatkina wrote:
>>
>>> Did you try to search GF forum? There were discussions about problems
>>> and solutions not so long ago.
>>>
>>> Regards,
>>> -marina
>>>
>>> Ryan de Laplante wrote:
>>>
>>>> Hi,
>>>>
>>>> I have Spring 2.5 configured to use JTA and TopLink. The logs show
>>>> that it detected JTA in GlassFish, and I am able to do SELECT
>>>> queries with JPA. When I try to add/change/delete a record it tells
>>>> me that there is no active transaction.
>>>>
>>>> http://forum.springframework.org/showthread.php?t=60035
>>>>
>>>> Can someone please help me? I am really stuck.
>>>>
>>>>
>>>> Thanks,
>>>> Ryan
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

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

Marina Vatkina

Did you try to search GF forum? There were discussions about problems and
solutions not so long ago.

Regards,
-marina

Ryan de Laplante wrote:
> Hi,
>
> I have Spring 2.5 configured to use JTA and TopLink. The logs show that
> it detected JTA in GlassFish, and I am able to do SELECT queries with
> JPA. When I try to add/change/delete a record it tells me that there is
> no active transaction.
>
> http://forum.springframework.org/showthread.php?t=60035
>
> Can someone please help me? I am really stuck.
>
>
> Thanks,
> Ryan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

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

Ryan de Laplante

Thanks for the tip. I did a brief search and did not see solutions to
my specific problem.. but I will come back to this later today to see if
I can find the post you are talking about.

I've almost got it all working. I posted a barebones sample app here:

http://forum.springframework.org/showpost.php?p=200821&postcount=24

Once I get JTA working then I'm going to write a blog entry or wiki page
with instructions on how to use Spring in GlassFish with JPA RI and JTA.

Thanks,
Ryan

Marina Vatkina wrote:
> Did you try to search GF forum? There were discussions about problems
> and solutions not so long ago.
>
> Regards,
> -marina
>
> Ryan de Laplante wrote:
>> Hi,
>>
>> I have Spring 2.5 configured to use JTA and TopLink. The logs show
>> that it detected JTA in GlassFish, and I am able to do SELECT queries
>> with JPA. When I try to add/change/delete a record it tells me that
>> there is no active transaction.
>>
>> http://forum.springframework.org/showthread.php?t=60035
>>
>> Can someone please help me? I am really stuck.
>>
>>
>> Thanks,
>> Ryan
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>

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