cancel
Showing results for 
Search instead for 
Did you mean: 

Java backed bean not called

gbur
Champ in-the-making
Champ in-the-making
Hi,

I have a problem with a java backed web script configuration, I use alfresco 3.0

this is my module-context.xml :


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

    <bean id="webscript.org.alfresco.demo.simple.get"
      class="org.alfresco.module.demoscripts.SimpleWebScript"
      parent="webscript">
    </bean>   

</beans>

the simple.get.desc.xml :

<webscript>
  <shortname>The World's Simplest Webscript</shortname>
  <description>Hands back a little bit of JSON</description>
  <url>/demo/simple</url>
  <authentication>none</authentication>
  <format default="html">argument</format>
</webscript>

Freemarker template

<html>
   ${res}
</html>

Java class

package org.alfresco.module.demoscripts;

import java.util.HashMap;
import java.util.Map;

import org.alfresco.web.scripts.DeclarativeWebScript;
import org.alfresco.web.scripts.WebScriptRequest;
import org.alfresco.web.scripts.WebScriptStatus;

public class SimpleWebScript extends DeclarativeWebScript
{
   @Override
   protected Map<String, Object> executeImpl(WebScriptRequest req, WebScriptStatus status)
    {
      Map<String, Object> model = new HashMap<String, Object>();
      model.put("res", "My result");

      return model;
    }
}

this is the error in th standard Tomcat output :
15:40:01,379 ERROR [freemarker.runtime]

Expression node is undefined on line 2, column 4 in simple.get.html.ftl.
The problematic instruction:
———-
==> ${res} [on line 2, column 4 in simple.get.html.ftl]
———-

what's wrong with my configuration ?

if someone can send me an example of a java backed web script working on Alfresco 3.0 !!
1 REPLY 1

pmonks
Star Contributor
Star Contributor
This issue usually indicates that the Web Script bean id doesn't match the location of the Web Script descriptor - more details on how these two need to match up is available at http://wiki.alfresco.com/wiki/Web_Scripts#Java-Backed_Implementations.  From looking at the Spring context file, the descriptor and Freemarker template should be located in "/alfresco/extension/templates/webscripts/org/alfresco/demo".

Examples of Java backed Web Scripts are available at http://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples.  Alfresco itself also uses a reasonably large number of Java backed Web Scripts too, so the source code (available from SVN - see http://wiki.alfresco.com/wiki/Alfresco_SVN_Development_Environment) is another good source of information.

Cheers,
Peter