AnsweredAssumed Answered

cannot be cast to org.alfresco.web.scripts.AbstractWebScript

Question asked by alex.lu on Nov 3, 2010
Latest reply on Jun 20, 2014 by juilee
Hello,

I've created a java backend webscript. I'm getting "cannot be cast to org.alfresco.web.scripts.AbstractWebScript" error. Not sure where I'm doing wrong. Can anyone help please?

Java class

package com.alfresco.tutorial;

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

import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.namespace.QName;
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 ClassList extends DeclarativeWebScript {

   private DictionaryService dictionaryService;

   private static final String CM_CONTENT_NAMESPACE = "cm";
   private static final String CM_CONTENT = "content";

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

      Map<String, Object> model = new HashMap<String, Object>();
      
      QName rootNode = QName.createQName(CM_CONTENT_NAMESPACE, CM_CONTENT);
      
      Collection<QName> contentTypes = this.dictionaryService.getSubTypes(rootNode, true);
      model.put("contentTypes", contentTypes);
      
      return model;
   }

   public void setDictionaryService(DictionaryService dictionaryService) {
      this.dictionaryService = dictionaryService;
   }

}


webscript-context.xml

<bean id="webscript.butterfly.metadata.classlist.get"
         class="com.alfresco.tutorial.ClassList" parent="webscript">
        <property name="dictionaryService" ref="DictionaryService"/>
      </bean>

classlist.get.desc.xml

<webscript>
    <shortname>Class list</shortname>
    <description>Get all sub contents of cm:content</description>
    <url>/metadata/classlist</url>
    <format default="json">argument</format>
    <authentication>user</authentication>
    <transaction>required</transaction>
</webscript>

Outcomes