Home

unable to execute backup Webscript

You are here

5 posts / 0 new
Last post
unable to execute backup Webscript

Hi all,
I'm trying to deploy a backend webscript based on the simple example found here https://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples#SimpleWebScript.java ("The World's Simplest Webscript").
But I can't make it working.
-> Web script is registered
-> the "The World's Simplest Webscript", is working fine

I'm getting the following error : (config is detailed below)

thanks for your help !

________________________

The Web Script /core/service/ks2/dlockws/lock 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: 06220001 Cannot locate template processor for template org/alfresco/ks2/dlockws/lock.get.html

Exception: org.springframework.extensions.webscripts.WebScriptException - 06220001 Cannot locate template processor for template org/alfresco/ks2/dlockws/lock.get.html

org.springframework.extensions.webscripts.AbstractWebScript.renderTemplate(AbstractWebScript.java:904)
org.springframework.extensions.webscripts.DeclarativeWebScript.renderFormatTemplate(DeclarativeWebScript.java:267)
org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:147)
org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:429)
org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:452)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:491)
org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:529)
org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:341)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378)
org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

.....
________________________

my class: (jar file /tomcat/webapps/alfresco/WEB-INF/lib )

package org.alfresco.module.ks2.dlockws;

import ....

public class lock extends org.springframework.extensions.webscripts.DeclarativeWebScript {

public void executeImpl (WebScriptRequest req, WebScriptResponse res)
throws IOException
{

...

try
{

if (req.getParameter("a") == null || req.getParameter("a").length() == 0)
{

status.setCode(HttpServletResponse.SC_BAD_REQUEST);
status.setMessage("no parameter");
status.setRedirect(true);
return;
}
else
{
status.setCode(HttpServletResponse.SC_OK );
message = "param a=" + req.getParameter("a");
status.setMessage(message);
status.setRedirect(true);
return;
}
}
catch(Exception e)
{
//throw new WebScriptException("Unable to serialize JSON");
status.setCode(HttpServletResponse.SC_FORBIDDEN);
status.setMessage("Invalid username & password");
status.setException(e);
status.setRedirect(true);
}
}

......
}

________________________

lock.get.desc.xml content: (file in /tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/module/ks2/dlockws )

lock
dLock Web Service, methode lock
/ks2/dlockws/lock
admin
ks2 Web Scripts

________________________

web script declaration: (in file /tomcat/webapps/alfresco/WEB-INF/classes/alfresco/web-scripts-application-context.xml

_________________________

4.2.e

Vincent.

solved: I was extending the

solved: I was extending the DeclarativeWebScript class without a freemarker template. It seems that the only way to work without freemarker template is by extending the AbstractWebScript class.
If somebody can confirm that ?
Thanks,
Vincent

Vincent.

Declarativewebscript and

Declarativewebscript and Abstractwebscript both are the helper classes provided by the alfresco webscript framework for developing java backed webscripts in alfresco. Declarativewebscript provides execution assistance for the webscript and allows to building up the model object as required to render in the FTL template, possible to redirection based on error status codes etc. Webscript controller java class has to extend DeclarativeWebscript and override executeImpl method for using it. ftl template is required in this case.

About AbstractWebScript, it gives full control to the extending controller class to render the response and hence ftl template not required. DeclarativeWebscript is a good example of using this control provided by AbstractWebScript. It extends AbstractWebScript only and provides the mechanism to render the response through model object.
In the scenarios like streaming the content extending AbstractWebScript class can be used. However, generally for creating java backed webscript, DeclarativeWebscript is used.

Hope this helps.

Thanks & Regards,
Ramesh Chauhan
CIGNEX Datamatics

The organization I work at - CIGNEX Datamatics
My book contribution on Alfresco - Learning Alfresco Web Scripts
My blog - http://alfresco-for-developers.blogspot.in

webscript

Yes ,if you extend the DeclarativeWebScript class, a freemarker template is needed.
Although you can extend the AbstractWebScript class without freemarker template,I don't think it is a good approcach,because under certain circumstances template is still needed (for exmaple if your webscript need to support redirection).
So I suggest you still extend the DeclarativeWebScript class and provide a freemarker template.

If this post was helpful, please click Yes on the Post Rating

OK, thanks

OK, thanks

Vincent.

forums index