07-08-2016 04:55 PM
10-06-2016 09:46 AM
Your class looks fine, so it must be the Spring context file that is not correct.
I suspect it is your bean ID. As it says in my tutorial, the syntax for the bean ID is:
webscript.package.service-id.method
But yours is "webscript.sudo". Alfresco has no way of knowing which web script you intend to use that class with unless that ID follows the convention. You need to change it to:
webscript.sudo.sudorename.get
Be sure to restart Alfresco after that change.
07-18-2016 11:04 AM
10-05-2016 11:01 AM
Hi Jeff Potts,
I followed the principle and structure of your tutorial and that of the official Alfresco document tutorial, but still get the following error.
<blockcode>
2016-10-05 16:34:25,500 ERROR [freemarker.runtime] [http-apr-8080-exec-2] Error executing FreeMarker template
FreeMarker template error:
The following has evaluated to null or missing:
==> data [in template "sudo/sudorename.get.html.ftl" at line 6, column 22]
Tip: If the failing expression is known to be legally null/missing, either specify a default value with myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthessis: (myOptionVar.foo)!myDefault, (myOptionVar.foo)??
The failing instruction (FTL stack trace):
----------
==> ${data} [in template "sudo/sudorename.get.html.ftl" at line 6, column 20]
----------
</blockcode>
The webscript is fully registered and only when I invoke it do I get that error message. The Java class is a simple class to return a text (business logic to be done later).
My files:
tomcat\webapps\alfresco\WEB-INF\classes\za\gov\parliament\sudowebscripts\SudoChildNode.class
<blockcode>
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
Map<String, Object> model = new HashMap<String, Object>();
model.put("data", "Data retrieved");
logger.debug("Sudo webscript execution complete");
return model;
}
</blockcode>
tomcat\shared\classes\alfresco\extension\templates\webscripts\sudo\sudorename.get.desc.xml
tomcat\shared\classes\alfresco\extension\templates\webscripts\sudo\sudorename.get.html.xml
tomcat\shared\classes\alfresco\extension\sudorename-context.xml
<blockcode>
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN 2.0//EN' 'http://www.springframework.org/dtd/spring-beans-2.0.dtd'>
<beans>
<bean id="webscript.sudo" class="za.gov.parliament.sudowebscripts.SudoChildNode" parent="webscript" />
</beans>
</blockcode>
In all the above is there something that I am missing?
Using Alfresco 5.2 201609 Nightly build
Much thanks.
~Vusani
10-05-2016 05:01 PM
Can you provide the full class signature of your Java class so I can see what it extends/implements?
10-06-2016 03:15 AM
Hi @Jeff
Here is the full class:
package za.gov.parliament.sudowebscripts;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptRequest;
public class SudoChildNode extends DeclarativeWebScript
{
private Log logger = LogFactory.getLog(SudoChildNode.class);
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
Map<String, Object> model = new HashMap<String, Object>();
model.put("data", "Data retrieved");
logger.debug("Sudo webscript execution complete");
return model;
}
}
Much Thanks
~Vusani
10-06-2016 09:46 AM
Your class looks fine, so it must be the Spring context file that is not correct.
I suspect it is your bean ID. As it says in my tutorial, the syntax for the bean ID is:
webscript.package.service-id.method
But yours is "webscript.sudo". Alfresco has no way of knowing which web script you intend to use that class with unless that ID follows the convention. You need to change it to:
webscript.sudo.sudorename.get
Be sure to restart Alfresco after that change.
10-06-2016 10:29 AM
Much thanks,
Indeed it was the bean ID, made the change and worked. It was an oversight while I was working through the tutorial.
~Vusani
10-06-2016 10:42 AM
Awesome, glad you got it working!
10-05-2016 10:50 PM
And you'd better check if a variable exists in FreeMarker template before using it,like this
<#if data??>
${data}
</#if>
Or display a default text when the variable is null ,like this
${(data)!"default text"}
10-06-2016 09:58 AM
Your issue is due to reasons given by Jeff and and kyne. Error is because you are trying print value of "data" which is null and you do not have any null check in your ftl.
Reason your data is null is because your java class is not getting called.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.