AnsweredAssumed Answered

Upload Web Script Authentication trouble

Question asked by bjorn_r on Oct 15, 2007
Latest reply on Oct 21, 2007 by bjorn_r
I have trouble using the new upload web script in E2.1. When I use the script from my browser with a traditional form everything works as expected. However, when I try to post a file from a java client based on Jakarta Commons HttpClient I experience some strange behaviour. My request is first authenticated, but then I get a net.sf.acegisecurity.AuthenticationCredentialsNotFoundException

The uploaded file gets to Tomcat’s temp folder, but never reaches the repository.

Here is the response received by the client:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Upload Web Script Sample</title>
    <link rel="stylesheet" href="/alfresco/css/main.css" TYPE="text/css">
  </head>
  <body>
    <table>
      <tr>
        <td><img src="/alfresco/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
        <td><nobr><span class="mainTitle">Upload Web Script Sample</span></nobr></td>
      </tr>
      <tr><td><td>Alfresco Enterprise Network v2.1.1 (@build-number@)
      <tr><td><td> 
      <tr><td><td>Uploaded <a href="/alfresco/service/sample/folder/Company Home/testmapp2">countries.pdf</a> of size 113,155.
    </table>
  </body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Web Script Status 500 - Internal Error</title>
    <link rel="stylesheet" href="/alfresco/css/main.css" TYPE="text/css">
  </head>
  <body>
    <table>
     <tr>
        <td><img src="/alfresco/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
        <td><nobr><span class="mainTitle">Web Script Status 500 - Internal Error</span></nobr></td>
     </tr>
    </table>
    <br>
    <table>
     <tr><td>The Web Script <a href="/alfresco/service/sample/upload">/alfresco/service/sample/upload</a> has responded with a status of 500 - Internal Error.
    </table>
    <br>
    <table>
     <tr><td><b>500 Description:</b><td> An error inside the HTTP server which prevented it from fulfilling the request.
     <tr><td> 
     <tr><td><b>Message:</b><td>A valid SecureContext was not provided in the RequestContext
       <tr><td> 
   <tr><td><b>Exception:</b><td>net.sf.acegisecurity.AuthenticationCredentialsNotFoundException - A valid SecureContext was not provided in the RequestContext
   <tr><td><td> 
         <tr><td><td>net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.credentialsNotFound(AbstractSecurityInterceptor.java:477)
         <tr><td><td>net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.beforeInvocation(AbstractSecurityInterceptor.java:355)
         <tr><td><td>net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:77)
         <tr><td><td>org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
         <tr><td><td>org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:49)
         <tr><td><td>org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
         <tr><td><td>org.alfresco.repo.audit.AuditComponentImpl.auditImpl(AuditComponentImpl.java:256)
         <tr><td><td>org.alfresco.repo.audit.AuditComponentImpl.audit(AuditComponentImpl.java:191)
         <tr><td><td>org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:69)
         <tr><td><td>org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
         <tr><td><td>org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
         <tr><td><td>org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:176)
         <tr><td><td>org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:210)
         <tr><td><td>$Proxy85.exists(Unknown Source)
         <tr><td><td>org.alfresco.repo.rule.RuleServiceImpl.checkForCopy(RuleServiceImpl.java:976)
         <tr><td><td>org.alfresco.repo.rule.RuleServiceImpl.canExecuteRule(RuleServiceImpl.java:951)
         <tr><td><td>org.alfresco.repo.rule.RuleServiceImpl.executePendingRule(RuleServiceImpl.java:884)
         <tr><td><td>org.alfresco.repo.rule.RuleServiceImpl.executePendingRulesImpl(RuleServiceImpl.java:857)
         <tr><td><td>org.alfresco.repo.rule.RuleServiceImpl.executePendingRules(RuleServiceImpl.java:830)
         <tr><td><td>org.alfresco.repo.rule.RuleTransactionListener.beforeCommit(RuleTransactionListener.java:69)
         <tr><td><td>org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.doBeforeCommit(AlfrescoTransactionSupport.java:631)
         <tr><td><td>org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.doBeforeCommit(AlfrescoTransactionSupport.java:613)
         <tr><td><td>org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.beforeCommit(AlfrescoTransactionSupport.java:591)
         <tr><td><td>org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCommit(TransactionSynchronizationUtils.java:48)
         <tr><td><td>org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:821)
         <tr><td><td>org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:637)
         <tr><td><td>org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:624)
         <tr><td><td>org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:307)
         <tr><td><td>org.alfresco.util.transaction.SpringAwareUserTransaction.commit(SpringAwareUserTransaction.java:420)
         <tr><td><td>org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:244)
         <tr><td><td>org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:160)
         <tr><td><td>org.alfresco.web.scripts.WebScriptRuntime.executeScript(WebScriptRuntime.java:174)
         <tr><td><td>org.alfresco.web.scripts.WebScriptServlet.service(WebScriptServlet.java:106)
         <tr><td><td>javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
         <tr><td><td>org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
         <tr><td><td>org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         <tr><td><td>org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
         <tr><td><td>org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
         <tr><td><td>org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
         <tr><td><td>org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
         <tr><td><td>org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         <tr><td><td>org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
         <tr><td><td>org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
         <tr><td><td>org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
         <tr><td><td>org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
         <tr><td><td>java.lang.Thread.run(Thread.java:619)
   <tr><td><td> 
     <tr><td><b>Server</b>:<td>Alfresco Enterprise Network v2.1.1 (@build-number@) schema 74
     <tr><td><b>Time</b>:<td>Oct 14, 2007 10:51:28 PM
     <tr><td> 
    </table>
  </body>
</html>

Any comments or suggestions are welcome!

Outcomes