AnsweredAssumed Answered

Java Class not invoking in web-scripts

Question asked by mazhar_shaukat on May 11, 2012
Latest reply on Jul 19, 2016 by risharommi

I'm new to web-scripts. I'm trying to successfully run an example.
My Java Class is as follow;

package org.alfresco.module.demoscripts;


import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;

public class SimpleWebScript extends AbstractWebScript {

   public void execute(WebScriptRequest req, WebScriptResponse res)
         throws IOException {
          // build a json object
          JSONObject obj = new JSONObject();
          // put some data on it
          obj.put("field1", "data1");
          // build a JSON string and send it back
          String jsonString = obj.toString();
       catch(JSONException e)
          throw new RuntimeException("Unable to serialize JSON");



Descriptor simple.get.desc.xml
  <shortname>The World's Simplest Webscript</shortname>
  <description>Hands back a little bit of JSON</description>
  <format default="">argument</format>
  <family>Alfresco Java-Backed WebScripts Demo</family>

When I access it like this;
I get the following error:
org.springframework.extensions.webscripts.WebScriptException: 04110003 Web Script format '' is not registered

when I try following

I get this error:

org.springframework.extensions.webscripts.WebScriptException: 04110002 Cannot locate template processor for template org/alfresco/demo/simple.get.json

please help