cancel
Showing results for 
Search instead for 
Did you mean: 

A valid SecureContext was not provided in the RequestContext

prezesso
Champ in-the-making
Champ in-the-making
When I try to get root node for store:
StoreRef storeRef = bootstrap.getStoreRef();
this.services.getNodeService().getRootNode(storeRef);
I receive exception:
net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext
   at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:477)
   at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:355)
   at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:77)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:44)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:146)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   at $Proxy8.getRootNode(Unknown Source)

I do it in scheduled job.
When I do it for example in Action handler everything is OK.
What can be a problem?
1 REPLY 1

raweck
Champ on-the-rise
Champ on-the-rise
Try to execute problematic code as a system user, for example:

AuthenticationUtil.runAs(new RunAsWork<String>()
         {
            public String doWork() throws Exception
            {
               return yourProblematicFunction();
            }
         }, AuthenticationUtil.getSystemUserName());