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

You are here

11 posts / 0 new
Last post
cannot be cast to org.alfresco.web.scripts.AbstractWebScript


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";
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;


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


<shortname>Class list</shortname>
<description>Get all sub contents of cm:content</description>
<format default="json">argument</format>

Alex Lu
Senior Developer
Ixxus Ltd

Re: cannot be cast to org.alfresco.web.scripts.AbstractWebSc

Turned out it's because I'm using 3.2. It's now all fine with 3.3.3.

A bit of rubber ducky here! :D

Alex Lu
Senior Developer
Ixxus Ltd

Re: cannot be cast to org.alfresco.web.scripts.AbstractWebSc

I've got the same error "cannot be cast to org.springframework.extensions.webscripts.AbstractWebScript"

My class

package org.alfresco.wftaskproperties;
import java.io.IOException;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.namespace.QName;
import org.apache.log4j.Logger;
import org.alfresco.repo.jscript.BaseScopableProcessorExtension;
public class UpdateTaskProperties extends BaseScopableProcessorExtension{
private Logger logger = Logger.getLogger(UpdateTaskProperties.class);
private WorkflowService workflowService;
public void setWorkflowService(WorkflowService workflowService) {
this.workflowService = workflowService;
public void setTaskAssignee(String taskId, String owner) throws IOException {
logger.debug("Start to update task");
Map<QName, Serializable> params = new HashMap<QName, Serializable>();
params.put(ContentModel.PROP_OWNER, owner);
workflowService.updateTask(taskId, params, null, null);
logger.debug("Task updated");

I use a jdk compliance of 1.6,

My bean:

<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="webscript.org.alfresco.Iphone.iPhoneFormwftasks.get"
<property name="extensionName">
<property name="workflowService" ref="WorkflowService" />

I work on Alfresco 3.4e.
Any idea to solve this error?

Re: cannot be cast to org.alfresco.web.scripts.AbstractWebSc


If you extend UpdateTaskProperties from DeclartiveWebScript, it should work.

Alex Lu
Senior Developer
Ixxus Ltd

Re: cannot be cast to org.alfresco.web.scripts.AbstractWebSc

Hi, thanks for your fast answer!

With my webscript, I'de like to extend the Alfresco Javascript Api and not make a basic webscript called with its url.

I'm not familiar with Java, so i mainly followed this topic :http://blog.starxpert.fr/?p=255

I'm not sure but if i extend my class from "DeclartiveWebScript" i'll can't declare my bean with "baseJavaScriptExtension" as parent, isn't it?
Using your class error effectively disappear but if i keep my bean, i've got an other error:
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'processor' of bean class [org.alfresco.wftaskproperties.UpdateTaskProperties]: Bean property 'processor' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

Re: cannot be cast to org.alfresco.web.scripts.AbstractWebSc

you need to expose the java class as a javascript object instead of making it a webscript.

Remove webscript bean you declared and declare a spring bean of UpdateTaskProperties like below.

<bean id="updateTaskProperties" parent="baseJavaScriptExtension" 
<property name="extensionName">
<property name="workflowService">
<ref bean="WorkflowService"/>

In a javascript webscript, you can simply do something like


Alex Lu
Senior Developer
Ixxus Ltd

Re: cannot be cast to org.alfresco.web.scripts.AbstractWebSc

Woaa, wonderfull!

It's exactly what i've needed, and it works!
Thanks a lot!

Re: cannot be cast to org.alfresco.web.scripts.AbstractWebSc

I have exception while realize these schema:


Where are problem ?

Alfresco Professional Integration: http://fdline.ru

AbstractWebScript class error

Hi, I am extending AbstractWebScript class in my class implementation. I am trying to import it using import org.springframework.extensions.webscripts.
I searched everywhere to find the right jar but still couldn't locate one. Can anyone please help and tell me the right jar to be added for this class.


This class is defined in spring webscript framework, in spring-webscripts-***.jar.
So you can add all spring-surf lib into your classpath.


If this post was helpful, please click Yes on the Post Rating

Thanks a lot

Hi kaynezhang, thanks a lot. It worked !

forums index