Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Problem with Transactions using EclipseLink

Tim, did you ever find a solution for the 'No transaction is currently
active' issue? I'm currently running into that myself with Spring,
EclipseLink 2, and Felix.

Thanks,
Bill



Eric Gulatee wrote:
> 
> Tim,
> 
> Thank you.  :)
> 
> When flushing I hit:
> 
> Caused by: javax.persistence.TransactionRequiredException:
> Exception Description: No transaction is currently active
> 	at
> org.eclipse.persistence.internal.jpa.transaction.EntityTransactionWrapper.throwCheckTransactionFailedException(EntityTransactionWrapper.java:109)
> 	at
> org.eclipse.persistence.internal.jpa.transaction.EntityTransactionWrapper.checkForTransaction(EntityTransactionWrapper.java:50)
> 	at
> org.eclipse.persistence.internal.jpa.EntityManagerImpl.checkForTransaction(EntityManagerImpl.java:1241)
> 	at
> org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:509)
> 	at da.db.dao.jpa.UserDaoJpaImpl.save(UserDaoJpaImpl.java:36)
> 
> Kinda confused.  :)
> 
> I have @Transactional attributes on my DAO and spring stuff was
> running transactions outside OSGI...
> 
> I clearly see unit of work commit.
> I am guessing it is trying to link that to a spring transaction?
> I guess I'll enable debugging on spring transaction code to see what's
> going on.
> 
> Cheers,
> Eric G.
> 
> 
> On Sun, Nov 2, 2008 at 4:03 PM, Tim Hollosy <hollosyt@xxxxxxxxx> wrote:
>> Hmmm, no inserts. Maybe a flushing issue? Did you try calling
>> em.flush() right after your merge/persist?
>>
>> ./tch
>>
>>
>>
>> On Sun, Nov 2, 2008 at 3:57 PM, Eric Gulatee <eric.gulatee@xxxxxxxxx>
>> wrote:
>>> Right now, nothing other than selects are getting executed.  [I don't
>>> see any SQL inserts/updates actually getting executed from
>>> eclipselink]
>>>
>>> A little snippet of the DAO which matches the logs I provided.  (I am
>>> using org.springframework.transaction.annotation.Transactional
>>> annotation).
>>>
>>> Additionally I have a service layer above the daos which also has
>>> transactional.  I'm pretty certain I am doing something wrong.  [This
>>> worked previously when I was using non osgi & older version of
>>> eclipselink nd my project was structure differently]
>>> I just can't see it for the life of me.
>>>
>>>
>>> import da.db.dao.UserDao;
>>> import da.db.model.User;
>>>
>>> import org.slf4j.Logger;
>>> import org.slf4j.LoggerFactory;
>>> import org.springframework.stereotype.Repository;
>>> import org.springframework.transaction.annotation.Transactional;
>>>
>>> //~--- JDK imports
>>> ------------------------------------------------------------
>>>
>>> import java.util.Collection;
>>> import java.util.List;
>>>
>>> import javax.persistence.EntityManager;
>>> import javax.persistence.PersistenceContext;
>>> import javax.persistence.Query;
>>>
>>> @Repository
>>> public class UserDaoJpaImpl implements UserDao {
>>>
>>>        Logger logger = LoggerFactory.getLogger(UserDaoJpaImpl.class);
>>>
>>>        @PersistenceContext
>>>    private EntityManager entityManager;
>>>
>>>        @Transactional
>>>    public void save(User u) {
>>>        logger.info("Persisting using EM=" + getEntityManager());
>>>        getEntityManager().persist(u);
>>>        logger.info("Persisted using EM=" + getEntityManager());
>>>    }
>>>
>>>
>>>
>>>
>>> On Sun, Nov 2, 2008 at 2:50 PM, Tim Hollosy <hollosyt@xxxxxxxxx> wrote:
>>>> Ya uow stuff will use the spring tx. I see u r doing some aop stuff.
>>>> Maybe that is messing up your tx. What tx annotation do you use on the
>>>> method shown. Does this happen everywhere or just a certain chunk of
>>>> code?
>>>>
>>>> On 11/2/08, Eric Gulatee <eric.gulatee@xxxxxxxxx> wrote:
>>>>> Tim,
>>>>>
>>>>> Yeah.  Spring is managing the transaction.  Do the eclipselink
>>>>> unitofwork tied into the spring transactions?
>>>>> Here is the xml file.
>>>>>
>>>>>
>>>>>       <import resource="applicationContext-dao.xml" />
>>>>>       <import resource="applicationContext-db-eclipselink.xml" />
>>>>>
>>>>>       <tx:advice id="txAdvice"
>>>>> transaction-manager="transactionManagerPvt">
>>>>>               <!-- the transactional semantics... -->
>>>>>               <tx:attributes>
>>>>>                       <!-- all methods starting with 'get' are
>>>>> read-only -->
>>>>>                       <tx:method name="get*" read-only="true" />
>>>>>                       <!-- other methods use the default transaction
>>>>> settings (see below) -->
>>>>>                       <tx:method name="*" />
>>>>>               </tx:attributes>
>>>>>       </tx:advice>
>>>>>
>>>>>       <aop:config>
>>>>>               <aop:pointcut id="daoServiceOperation"
>>>>> expression="execution(*
>>>>> da.db.dao.jpa.*.*(..))" />
>>>>>               <aop:advisor advice-ref="txAdvice"
>>>>> pointcut-ref="daoServiceOperation" />
>>>>>       </aop:config>
>>>>>
>>>>>       <bean id="transactionManagerPvt"
>>>>> class="org.springframework.orm.jpa.JpaTransactionManager">
>>>>>               <property name="entityManagerFactory"
>>>>> ref="entityManagerFactoryPrivate" />
>>>>>               <property name="jpaDialect" ref="jpaDialect"></property>
>>>>>       </bean>
>>>>>
>>>>>       <context:spring-configured/>
>>>>>
>>>>>       <tx:annotation-driven
>>>>> transaction-manager="transactionManagerPvt" />
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Sun, Nov 2, 2008 at 10:59 AM, Tim Hollosy <hollosyt@xxxxxxxxx>
>>>>> wrote:
>>>>>> Hmm what transaction manager are you using? Is spring managing them?
>>>>>>
>>>>>> On 11/2/08, Eric Gulatee <eric.gulatee@xxxxxxxxx> wrote:
>>>>>>> All,
>>>>>>>
>>>>>>> Hi I'm trying to build something using spring, jpa, osgi and
>>>>>>> eclipselink
>>>>>>> :)
>>>>>>>
>>>>>>> I am not seeing my transactions getting committed.  I've started
>>>>>>> poking around in fisheye for eclipselink looking at unitofwork etc.
>>>>>>>
>>>>>>> Here are the eclipselink logs.  [Which to me indicate there are
>>>>>>> commits]   -- Begin transaction and commit transaction.
>>>>>>>
>>>>>>> Any leads/suggestions or ideas what I could be doing wrong to
>>>>>>> explain
>>>>>>> the lack of data being inserted into the DB?
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Eric G.
>>>>>>>
>>>>>>> [2008-11-02 09:59:20.939] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]:
>>>>>>> Connection(7513337)--begin transaction
>>>>>>> [2008-11-02 09:59:20.940] server-tomcat-thread-11
>>>>>>>         da.db.dao.jpa.UserDaoJpaImpl.unknown I Persisting using
>>>>>>> EM=org.eclipse.persistence.internal.jpa.EntityManagerImpl@17b09f
>>>>>>> [2008-11-02 09:59:20.940] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finest]: PERSIST
>>>>>>> operation called on: da.db.model.User@b21979.
>>>>>>> [2008-11-02 09:59:20.940] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finest]: assign
>>>>>>> sequence to the object (1,542 -> da.db.model.User@b21979)
>>>>>>> [2008-11-02 09:59:20.940] server-tomcat-thread-11
>>>>>>>         da.db.dao.jpa.UserDaoJpaImpl.unknown I Persisted using
>>>>>>> EM=org.eclipse.persistence.internal.jpa.EntityManagerImpl@17b09f
>>>>>>> [2008-11-02 09:59:20.941] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]: begin
>>>>>>> unit
>>>>>>> of work commit
>>>>>>> [2008-11-02 09:59:20.941] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]:
>>>>>>> Connection(7513337)--commit transaction
>>>>>>> [2008-11-02 09:59:20.941] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]: end unit
>>>>>>> of
>>>>>>> work commit
>>>>>>> [2008-11-02 09:59:20.942] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]: resume
>>>>>>> unit
>>>>>>> of work
>>>>>>> [2008-11-02 09:59:20.942] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]: release
>>>>>>> unit of work
>>>>>>> [2008-11-02 09:59:20.942] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]: client
>>>>>>> released
>>>>>>> [2008-11-02 09:59:20.943] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]: client
>>>>>>> acquired
>>>>>>> [2008-11-02 09:59:20.943] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]:
>>>>>>> Connection(3805535)--begin transaction
>>>>>>> [2008-11-02 09:59:20.943] server-tomcat-thread-11
>>>>>>>  da.service.impl.AuditManagementImpl.unknown I Adding audit log
>>>>>>> [2008-11-02 09:59:20.943] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finest]: PERSIST
>>>>>>> operation called on: da.db.model.AuditLog@401ab2.
>>>>>>> [2008-11-02 09:59:20.944] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finest]: assign
>>>>>>> sequence to the object (1,543 -> da.db.model.AuditLog@401ab2)
>>>>>>> [2008-11-02 09:59:20.944] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]: begin
>>>>>>> unit
>>>>>>> of work commit
>>>>>>> [2008-11-02 09:59:20.944] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]:
>>>>>>> Connection(3805535)--commit transaction
>>>>>>> [2008-11-02 09:59:20.944] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]: end unit
>>>>>>> of
>>>>>>> work commit
>>>>>>> [2008-11-02 09:59:20.945] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]: resume
>>>>>>> unit
>>>>>>> of work
>>>>>>> [2008-11-02 09:59:20.945] server-tomcat-thread-11
>>>>>>>                                   System.out I [EL Finer]: release
>>>>>>> unit of work
>>>>>>> _______________________________________________
>>>>>>> eclipselink-users mailing list
>>>>>>> eclipselink-users@xxxxxxxxxxx
>>>>>>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> ./tch
>>>>>> _______________________________________________
>>>>>> eclipselink-users mailing list
>>>>>> eclipselink-users@xxxxxxxxxxx
>>>>>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>>>>>
>>>>> _______________________________________________
>>>>> eclipselink-users mailing list
>>>>> eclipselink-users@xxxxxxxxxxx
>>>>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>>>>
>>>>
>>>>
>>>> --
>>>> ./tch
>>>> _______________________________________________
>>>> eclipselink-users mailing list
>>>> eclipselink-users@xxxxxxxxxxx
>>>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>>>
>>> _______________________________________________
>>> eclipselink-users mailing list
>>> eclipselink-users@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>>
>> _______________________________________________
>> eclipselink-users mailing list
>> eclipselink-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
>>
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/eclipselink-users
> 
> 

-- 
View this message in context: http://old.nabble.com/Problem-with-Transactions-using-EclipseLink-tp20290856p28986269.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top