cancel
Showing results for 
Search instead for 
Did you mean: 

AlfrescoRuntimeException : Transaction must be active

cblandin
Champ in-the-making
Champ in-the-making
Hello,

I implemented my own AuthenticationFilter (I took for example the NovellIChainsHTTPRequestAuthenticationFilter) to configure a CAS authentication.
The communication with the CAS server seems to work but when I set the authentication
authComponent.setCurrentUser(userName);‍
  in the function setAuthenticatedUser(HttpServletRequest req, HttpSession httpSess, String userName) of my filter (it comes from NovellIChainsHTTPRequestAuthenticationFilter) I get this error :
org.alfresco.error.AlfrescoRuntimeException: Transaction must be active and synchronization is required   at org.alfresco.repo.transaction.AlfrescoTransactionSupport.registerSynchronizations(AlfrescoTransactionSupport.java:363)   at org.alfresco.repo.transaction.AlfrescoTransactionSupport.getSynchronization(AlfrescoTransactionSupport.java:348)   at org.alfresco.repo.transaction.AlfrescoTransactionSupport.bindDaoService(AlfrescoTransactionSupport.java:202)   at org.alfresco.repo.transaction.TransactionalDaoInterceptor.invoke(TransactionalDaoInterceptor.java:58)   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)   at $Proxy1.getNode(Unknown Source)   at org.alfresco.repo.node.db.DbNodeServiceImpl.exists(DbNodeServiceImpl.java:130)   at sun.reflect.GeneratedMethodAccessor159.invoke(Unknown Source)   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)   at java.lang.reflect.Method.invoke(Method.java:585)   at org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvocationHandler.invoke(StoreRedirectorProxyFactory.java:213)   at $Proxy2.exists(Unknown Source)   at org.alfresco.repo.security.person.PersonServiceImpl.getPersonOrNull(PersonServiceImpl.java:149)   at org.alfresco.repo.security.person.PersonServiceImpl.getPerson(PersonServiceImpl.java:104)   at cirad.CASAuthenticationFilter.setAuthenticatedUser(CASAuthenticationFilter.java:210)   at cirad.CASAuthenticationFilter.doFilter(CASAuthenticationFilter.java:178)   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)   at edu.yale.its.tp.cas.client.filter.CASFilter.doFilter(CASFilter.java:193)   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)   at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)   at java.lang.Thread.run(Thread.java:595)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Does someone know what is the problem ?

Christophe
4 REPLIES 4

kevinr
Star Contributor
Star Contributor
You need to wrap your code in UserTransaction. There are many examples in the web-client code of this pattern.

Thanks,

Kevin

srao
Champ in-the-making
Champ in-the-making
Hi Kevin,
I am Alfresco 2.0 and get exactly the same error.  I am not sure what you mean by wrap your code with UserTransaction.   Can you give some more details or a link or something.

Thanks
srao

kevinr
Star Contributor
Star Contributor
If you download the SDK there are many examples of client code, here is a snippet that will work in a servlet:
UserTransaction tx = null;try{   tx = Repository.getServiceRegistry(servletContext).getTransactionService().getUserTransaction();   tx.begin();      // your code here…   // …      // commit the transaction   tx.commit();}catch (Throwable err){   try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Hope this helps,

Kevin

srao
Champ in-the-making
Champ in-the-making
Hi

I do have usertransaction wrapper around the code.  I still get the same error.  I am using the CASAuthenticationFilter code directly from this link…

http://issues.alfresco.com/browse/AWC-952?page=com.atlassian.jira.plugin.system.issuetabpanels:all-t...

Here is the stack trace
—————————————————————————————
org.alfresco.error.AlfrescoRuntimeException: Transaction must be active and synchronization is required

Hide Details

org.alfresco.error.AlfrescoRuntimeException: Transaction must be active and synchronization is required
at org.alfresco.repo.transaction.AlfrescoTransactionSupport.registerSynchronizations(AlfrescoTransactionSupport.java:371)
at org.alfresco.repo.transaction.AlfrescoTransactionSupport.getSynchronization(AlfrescoTransactionSupport.java:356)
at org.alfresco.repo.transaction.AlfrescoTransactionSupport.bindDaoService(AlfrescoTransactionSupport.java:210)
at org.alfresco.repo.transaction.TransactionalDaoInterceptor.invoke(TransactionalDaoInterceptor.java:66)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy1.getNode(Unknown Source)
at org.alfresco.repo.node.db.DbNodeServiceImpl.exists(DbNodeServiceImpl.java:160)
at sun.reflect.GeneratedMethodAccessor156.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvocationHandler.invoke(StoreRedirectorProxyFactory.java:221)
at $Proxy2.exists(Unknown Source)
at sun.reflect.GeneratedMethodAccessor156.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterceptor.java:227)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy3.exists(Unknown Source)
at org.alfresco.repo.security.authentication.RepositoryAuthenticationDao.getUserOrNull(RepositoryAuthenticationDao.java:164)
at org.alfresco.repo.security.authentication.RepositoryAuthenticationDao.loadUserByUsername(RepositoryAuthenticationDao.java:113)
at org.alfresco.repo.security.authentication.AuthenticationComponentImpl.getUserDetails(AuthenticationComponentImpl.java:98)
at org.alfresco.repo.security.authentication.AbstractAuthenticationComponent.setCurrentUser(AbstractAuthenticationComponent.java:97)
at org.alfresco.web.app.servlet.CASAuthenticationFilter.doFilter(CASAuthenticationFilter.java:152)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at edu.yale.its.tp.cas.client.filter.CASFilter.doFilter(CASFilter.java:332)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
————————————————————————————-

Thank for helping me out.