Home

DeclarativeWebScript not executed

You are here

2 posts / 0 new
Last post
DeclarativeWebScript not executed

Hi all

I'm facing issues with backend webscript when implementing the DeclarativeWebScript helper class.
The facts:
When using DeclarativeWebScript, the class is NOT executed.
-> no log entry
-> variables a not recognized by ftp template
When using AbstractWebScript, the class is executed.
-> log entry OK

I'm using stricly the same xml description, class declaration and file locations.
details are below.
COuld please tell me what if I'm missing something ?

Another question: I can't have any debug log in catalina.out file (only logger.error) even
with these settings in log4j.properties
log4j.logger.org.springframework.extensions.webscripts=debug
log4j.logger.org.springframework.extensions.webscripts.ScriptLogger=debug
log4j.logger.org.springframework.extensions.webscripts.ScriptDebugger=off

Thanks a lot for your help !

class using DeclarativeWebScript (not executed)

package org.alfresco.module.ks2.dlockws;
 
import .....
 
	public class lock extends org.springframework.extensions.webscripts.DeclarativeWebScript
	{
		private Logger logger = Logger.getLogger(lock.class);
 
		public Map<String, Object> executeImpl (WebScriptRequest req, WebScriptResponse res)
		throws IOException   {
 
			Map<String, Object> model = new HashMap<String, Object>();
			String txt = "";
			try
	    	{		    	    		
				txt = "String from java";
 
	        	logger.debug("----- test log debug -------");
	        	logger.info("----- test log info -------");
	        	logger.warn("----- test log warn -------");
	        	logger.error("----- test log error2-------");
 
	    	}
	    	catch(WebScriptException e)
	    	{
	    		throw e ;
	    	}
 
    		model.put("servertext", txt);
			return model;
 
	    }
 
		public Logger getLogger() {
			return logger;
		}
 
		public void setLogger(Logger logger) {
			this.logger = logger;
		} 
	}
 

class using AbstractWebScript (works fine)

package org.alfresco.module.ks2.dlockws;
 
import ...
 
	public class lock extends org.springframework.extensions.webscripts.AbstractWebScript
	{
 
		private Logger logger = Logger.getLogger(lock.class);
 
		public void execute (WebScriptRequest req, WebScriptResponse res)
		throws IOException
 
	    {
			try
	    	{
 
 
	        	logger.debug("----- test log debug -------");
	        	logger.info("----- test log info -------");
	        	logger.warn("----- test log warn -------");
	        	logger.error("----- test log error2-------");
 
	    	}
	    	catch(WebScriptException e)
	    	{
	    		throw e ;
	    	}
 
	    }
 
		public Logger getLogger() {
			return logger;
		}
 
		public void setLogger(Logger logger) {
			this.logger = logger;
		} 
	}
class declaration in tomcat/webapps/core/WEB-INF/classes/alfresco/web-scripts-application-context.xml

<bean  id="webscript.org.alfresco.ks2.dlockws.lock.get"
       class="org.alfresco.module.ks2.dlockws.lock"
       parent="webscript">
</bean>

Description file: tomcat/webapps/core/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/ks2/dlockws/lock.get.desc.xml

<webscript>
  <shortname>lock</shortname>
  <description>dLock Web Service, methode lock</description>
  <url>/ks2/dlockws/lock</url>
  <authentication>admin</authentication>
  <format default="html">argument</format>
  <family>ks2 Web Scripts</family>
</webscript>

FTL template file: tomcat/webapps/core/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/ks2/dlockws/lock.get.html.ftl

<html>
 <head>
   <title>dLock Web Script, method lock()</title>
 </head>
 <body>
   <table>
     <tr>
       <td><img src="${url.context}/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
       <td><nobr>dLockWS Web Script, method lock</nobr></td>
     </tr>
     <tr><td></td></tr>
     <tr><td>test string: ${servertext}</td></tr>
   </table>
 </body>
</html>

Thanks for your help.
Vincent

4.2.e

Vincent.

solution found

I finally found my problem after days working around !!

It was a beginners mistake: (hope it can help other beginners)
I was not implementing correctly the DeclarativeWebScript interface (see below).
Because I was missing the @Override instruction, type error was not shown in Eclipse.

Correct implementation:

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
 

Incorrect implementation:

public Map<String, Object> executeImpl (WebScriptRequest req, WebScriptResponse res)
throws IOException
 

Vincent

Vincent.