AnsweredAssumed Answered

How to call the node-service when my AMP starts up?

Question asked by hbf on Jan 18, 2008
Latest reply on Feb 28, 2008 by stijndereede
Hi!

My AMP preloads some data (the country tags that are currently in use, to be precise). I've first implemented "lazy caching" in the sense that the data is loaded/fetched only when some code asks for it.

This does not work however, as some client code is asking for the data within an afterCommit() handler. The result is

13:29:01,257 User:admin ERROR [repo.transaction.AlfrescoTransactionSupport] After completion (committed) listener exception: 
   listener: org.myorg.module.myapp.service.MyService@c937c8
org.alfresco.error.AlfrescoRuntimeException: onCommit cache modifications are not allowed.
   at org.alfresco.repo.cache.TransactionalCache.put(TransactionalCache.java:398)
   at org.alfresco.repo.ownable.impl.OwnableServiceImpl.getOwner(OwnableServiceImpl.java:144)
   at org.alfresco.repo.security.permissions.dynamic.OwnerDynamicAuthority.hasAuthority(OwnerDynamicAuthority.java:58)
   at org.alfresco.repo.security.permissions.impl.PermissionServiceImpl.getAuthorisations(PermissionServiceImpl.java:447)
   at org.alfresco.repo.security.permissions.impl.PermissionServiceImpl.hasPermission(PermissionServiceImpl.java:345)
   at org.alfresco.repo.security.permissions.impl.PermissionServiceImpl.hasPermission(PermissionServiceImpl.java:577)
   at sun.reflect.GeneratedMethodAccessor266.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:281)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:187)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:154)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
   at $Proxy14.hasPermission(Unknown Source)

Therefore my question: What is the easiest way to run a few queries against the nodeService after AMP startup? I tried to do it from within my init-method="init" bean initialization method, but it seems no transaction is set up at this point yet.

Thanks for any hint,
Kaspar

Outcomes