AuthenticationCredentialsNotFoundException error for search
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2010 02:50 AM
I am using Alfresco 3.2r with Tomcat 6 with JDK 1.6.
I have written below code to get children of companyhome as:
StoreRef storeRef5 = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");ResultSet rs = serviceRegistry.getSearchService().query(storeRef5, SearchService.LANGUAGE_XPATH, "/app:company_home"); NodeRef companyHomeNodeRef = null; try { if (rs.length() == 0) { throw new AlfrescoRuntimeException("Didn't find Company Home"); } companyHomeNodeRef = rs.getNodeRef(0); }catch (Exception e) { logger.error("Error while getting company home "+e.getMessage()); } List<ChildAssociationRef> children = serviceRegistry.getNodeService().getChildAssocs(companyHomeNodeRef); for (ChildAssociationRef childAssoc : children) { NodeRef childNodeRef = childAssoc.getChildRef(); logger.debug("childNodeRef "+" "+childNodeRef.getId()+childNodeRef.getStoreRef()); }
While i am trying to invoke it, i am getting below error :
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:171)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.alfresco.repo.audit.AuditMethodInterceptor.proceedWithAudit(AuditMethodInterceptor.java:238)
at org.alfresco.repo.audit.AuditMethodInterceptor.proceed(AuditMethodInterceptor.java:205)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:153)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy27.query(Unknown Source)
at com.xxxx.alfresco.km.constraints.CommunitySearchConstraint.getAllowedValues(CommunitySearchConstraint.java:182)
at org.alfresco.cmis.dictionary.CMISBasePropertyDefinition.<init>(CMISBasePropertyDefinition.java:108)
at org.alfresco.cmis.dictionary.CMISAbstractTypeDefinition.createProperty(CMISAbstractTypeDefinition.java:126)
at org.alfresco.cmis.dictionary.CMISAbstractTypeDefinition.createProperties(CMISAbstractTypeDefinition.java:104)…..
Line no 182 says:
ResultSet rs = serviceRegistry.getSearchService().query(storeRef5, SearchService.LANGUAGE_XPATH, "/app:company_home");
I can assume that it is related to service dependency injection but not getting how to resolve it.
Can anybody tell me how to achieve this: maybe by making my class as managed bean & injecting searchservice in faces-config-beans.xml??? :?
Is there any generic way that i can get any service without any error outside of alfresco i.e. my custom code?
Any idea?
Is there any change in way to get services in 3.2+?
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2010 03:42 AM
I just came across this wiki article:
http://wiki.alfresco.com/wiki/Java_Foundation_API
It says :
Access to Java Foundation API
The Java Foundation API is in fact a set of interfaces; each interface represents a function of the repository. A Spring Framework Bean is provided as the implementation for each interface.
The list of available public services (that is, Spring beans) can be found in:
the configuration file /projects/repository/config/alfresco/public-services-context.xml
the service interface org.alfresco.service.ServiceRegistry
There are three approaches to accessing the interfaces in your own code:
Use standard Spring dependency injection (recommended, if your client code is also Spring based)
Manual access via the Spring getBean() method
Indirectly via Alfresco's ServiceRegistry
Spring provides excellent documentation on how to bind Beans together, so that will not be duplicated here.
I have tried all approaches but error remains same.:shock:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2010 07:49 AM

i hope the developers will do that option one day, since its very usefull to add customers as propertie to your documents and put them into workflows

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2010 08:02 AM
There's three approaches you can use.
a) Use the AuthenticationUtil class to establish a secure context.
b) Use the AuthenticationUtil class to run as the system user.
c) Bypass the security check by using the internal services (the one with the lower case name).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2010 12:39 AM
i got list of all categories coming up in content properties page.

Please refer to this post of mine:
http://forums.alfresco.com/en/viewtopic.php?f=9&t=20589&p=84639#p84639

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2010 07:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2010 11:24 AM
Any help is much appreciated.
public class LuceneSearchBasedListConstraint extends SearchBasedDependencyListConstraint{
private static final long serialVersionUID = 1L;
protected static Logger logger = Logger.getLogger(LuceneSearchBasedListConstraint.class);
protected String query;
protected String strStoreRef =
StoreRef.PROTOCOL_WORKSPACE + StoreRef.URI_FILLER + "SpacesStore";
public LuceneSearchBasedListConstraint(){}
@Override
protected List<String> getSearchResult(){
if(logger.isDebugEnabled())
logger.debug("Original Query " + query);
String siteQuery = getSites(query);
//this is where the query from the alfresco content model constraints comes in.
StoreRef storeRef = new StoreRef(strStoreRef);
[size=150]ResultSet resultSet = getServiceRegistry().getSearchService().query(storeRef, SearchService.LANGUAGE_LUCENE, siteQuery);[/size]
NodeService nodeSvc = getServiceRegistry().getNodeService();
Collection<String> allowedValues = new TreeSet<String>();
for (ResultSetRow row : resultSet)
allowedValues.add((String)nodeSvc.getProperty(row.getNodeRef(), ContentModel.PROP_NAME));
return new ArrayList<String>(allowedValues);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2011 04:43 AM
Hope this helps.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2016 04:08 PM
All code which do critical operations against repository requires to run with secure context and within one single transaction.
You can achieve this by putting code under runas block.
AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Void>() {
public Void doWork(){
//Put you logic here
}
return null;
}
}, AuthenticationUtil.getSystemUserName());
Hope this helps to all other users.
