AnsweredAssumed Answered

Developing a custom webapp with Alfresco embedded

Question asked by pitt1 on Jul 26, 2007
Latest reply on Jul 31, 2007 by pmonks
I am writing a proof-of-concept web application that embeds Alfresco and uses its repository services API.  Currently, I'm trying to flush out a few details.

1. I have a simple servlet that grabs the application context and authenticates in the init() method, which will start up the embedded Alfresco instance (modeled after the FirstFoundationClient in the SDK):

ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
AuthenticationService authenticationService = serviceRegistry.getAuthenticationService();
authenticationService.authenticate(username, password.toCharArray());

When I visit the servlet in the browser, I sporadically get the following stack trace, which is usually alleviated if I just refresh the page:

09:37:41,994 ERROR [[/AlfrescoAPIServlets-0.1].[EmbeddedAlfrescoServlet]] Servlet.service() for servlet EmbeddedAlfrescoServlet threw exception
net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext
        at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.credentialsNotFound(
        at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.beforeInvocation(
        at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
        at org.alfresco.repo.audit.AuditComponentImpl.auditImpl(
        at org.alfresco.repo.audit.AuditComponentImpl.audit(
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(
        at $Proxy14.selectNodes(Unknown Source)

Does anybody have clues as to what the problem could be?

2. The web client uses a different startup method, configured as context listeners defined in web.xml.  This has the effect of starting up the alfresco server when the app server starts up and deploys the application, rather than when the first time the servlet is run.


So how do I grab the application context in my servlet once I've started up the embedded Alfresco instance?  If I use the code in #1, it attempts to start the alfresco server all over again.

3. I would like to be able to quickly answer my own questions like the ones above by looking at the Alfresco codebase.  Javadocs are helpful when writing client code, but they don't really explain the package hierarchy.  Is anyone aware of documentation that describes this?  For example, I'd like to know where to look to find out how web service calls translate to repository api calls on the server side. There's only so much I can infer from looking at package names.  :)