cancel
Showing results for 
Search instead for 
Did you mean: 

500 Internal Error when adding a js controller to webscript

rzs
Champ in-the-making
Champ in-the-making
Hello,

Im using Alfresco Tomcat Bundle  3.3g.I created a helloworld webscript,consisting of a helloworld.get.html.ftl and helloworld.get.desc.xml . It worked fine. My code is located in /Company Home/Data Dictionary/Web Scripts Extensions.The code for the ftl and xml file are as follows:

helloworld.get.desc.xml
 <webscript>
      <shortname>Hello World</shortname>
      <description>Hello world web script</description>
      <url>/helloworld?name={nameArgument}</url>
    </webscript>

helloworld.get.html.ftl
 <html>
        <body>
            <p> <b> <font color="blue">  Hello, ${args.name} !  </font> </b> </p>
          
        </body>
  </html>

I then added a controller, helloworld.get.js consisting of the following code

model.foo = "bar";

I modified the ftl as follows :
 <html>
        <body>
            <p> <b> <font color="blue">  Hello, ${args.name} !  </font> </b> </p>
             <p> Foo : {foo} </p>
          
        </body>
  </html>


Then i refreshed the web scripts. Now, if i try to access the webscript using http://localhost:8080/alfresco/service/helloworld?name='rzs", i get 500 internal error with the following message :

"06050002 Wrapped Exception (with status template): 06050010 Transaction must be active and synchronization is required: Thread[http-8080-2,5,main]"

The full stack trace is as follows :


The Web Script /alfresco/service/helloworld has responded with a status of 500 - Internal Error.

500 Description:    An error inside the HTTP server which prevented it from fulfilling the request.

Message:   06050002 Wrapped Exception (with status template): 06050010 Transaction must be active and synchronization is required: Thread[http-8080-2,5,main]

Exception:   org.alfresco.error.AlfrescoRuntimeException - 06050010 Transaction must be active and synchronization is required: Thread[http-8080-2,5,main]

org.alfresco.repo.transaction.AlfrescoTransactionSupport.registerSynchronizations(AlfrescoTransactionSupport.java:454)
org.alfresco.repo.transaction.AlfrescoTransactionSupport.getSynchronization(AlfrescoTransactionSupport.java:438)
org.alfresco.repo.transaction.AlfrescoTransactionSupport.getResource(AlfrescoTransactionSupport.java:231)
org.alfresco.repo.domain.hibernate.DirtySessionMethodInterceptor.getFlushData(DirtySessionMethodInterceptor.java:208)
org.alfresco.repo.domain.hibernate.DirtySessionMethodInterceptor.invoke(DirtySessionMethodInterceptor.java:386)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.alfresco.repo.transaction.SingleEntryTransactionResourceInterceptor.invokeInternal(SingleEntryTransactionResourceInterceptor.java:148)
org.alfresco.repo.transaction.SingleEntryTransactionResourceInterceptor.invoke(SingleEntryTransactionResourceInterceptor.java:132)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
$Proxy8.getNodePair(Unknown Source)
org.alfresco.repo.node.db.DbNodeServiceImpl.getNodePairNotNull(DbNodeServiceImpl.java:140)
org.alfresco.repo.node.db.DbNodeServiceImpl.getPaths(DbNodeServiceImpl.java:1997)
org.alfresco.repo.node.db.DbNodeServiceImpl.getPath(DbNodeServiceImpl.java:1981)
sun.reflect.GeneratedMethodAccessor369.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
org.alfresco.repo.tenant.MultiTNodeServiceInterceptor.invoke(MultiTNodeServiceInterceptor.java:104)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
$Proxy10.getPath(Unknown Source)
sun.reflect.GeneratedMethodAccessor369.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.alfresco.repo.service.StoreRedirectorProxyFactory$RedirectorInvocationHandler.invoke(StoreRedirectorProxyFactory.java:215)
$Proxy11.getPath(Unknown Source)
sun.reflect.GeneratedMethodAccessor369.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterceptor.java:303)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.alfresco.repo.node.MLPropertyInterceptor.invoke(MLPropertyInterceptor.java:303)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:269)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.alfresco.repo.node.NodeRefPropertyMethodInterceptor.invoke(NodeRefPropertyMethodInterceptor.java:269)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
$Proxy10.getPath(Unknown Source)
org.alfresco.repo.web.scripts.RepoStore.getPath(RepoStore.java:285)
org.alfresco.repo.web.scripts.RepoStore.getBaseDir(RepoStore.java:250)
org.alfresco.repo.web.scripts.RepoStore.access$000(RepoStore.java:71)
org.alfresco.repo.web.scripts.RepoStore$RepoScriptContent.getPath(RepoStore.java:940)
org.springframework.extensions.webscripts.ScriptProcessorRegistry.getScriptProcessor(ScriptProcessorRegistry.java:153)
org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:970)
org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:330)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:434)
org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:257)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:319)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:177)
org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:116)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:619)

Exception:   org.springframework.extensions.webscripts.WebScriptException - 06050002 Wrapped Exception (with status template): 06050010 Transaction must be active and synchronization is required: Thread[http-8080-2,5,main]

org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:740)


Please help
Thank You.
2 REPLIES 2

joe_m
Champ in-the-making
Champ in-the-making
Change your helloword.get.desc.xml to
<webscript>
      <shortname>Hello World</shortname>
      <description>Hello world web script</description>
      <url>/helloworld?name={nameArgument}</url>
      <authentication>user</authentication>
      <transaction>required</transaction>
</webscript>

It should work.

rzs
Champ in-the-making
Champ in-the-making
Thanks for the reply joe. That worked !! Smiley Happy . I am learning about webscripts and had followed the article "Intro to the Web Script Framework" by Jeff Potts on http://ecmarchitect.com/alfresco-developer-series . But he doesnt have the authentication and transaction tag in his example.
Could you please tell me why those tags are required ?

Thanks a lot .