04-01-2011 05:54 AM
package org.alfresco.module.demoscripts;
import java.io.IOException;
import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
import org.json.JSONException;
import org.json.JSONObject;
public class SimpleWebScript extends AbstractWebScript
{
public void execute(WebScriptRequest req, WebScriptResponse res)
throws IOException
{
try
{
// 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();
res.getWriter().write(jsonString);
}
catch(JSONException e)
{
throw new WebScriptException("Unable to serialize JSON");
}
}
}
<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="">argument</format>
</webscript>
<bean id="webscript.demo.simple.get"
class="alfresco.lib"
parent="webscript">
</bean>
Note that the bean id is made up of:
* prefix = webscript (must always start with this value)
* packageId = org.alfresco.sample
* serviceId = helloworld
* httpMethod = get
From this we can determine that the descriptor for this Web Script is called helloworld.get.desc.xml and is located in the directory org/alfresco/sample (either in the repository or in the classpath, as described in Deciding Where to place Web Script Implementation).
These files need to be stored in a folder somewhere. They can live in either the Alfresco Repository or the Java ClassPath. The following folders are listed in the sequence in which Alfresco searches for Web Script implementation files:
1. repository folder: /Company Home/Data Dictionary/Web Scripts Extensions
2. repository folder: /Company Home/Data Dictionary/Web Scripts
3. class path folder: /alfresco/extension/templates/webscripts
4. class path folder: /alfresco/templates/webscripts
04-06-2011 04:41 AM
04-06-2011 05:24 AM
SEVERE: Exception sending context initialized event to listener instance of class org.alfresco.web.app.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'LuceneFullTextSearchIndexer' defined in class path resource [alfresco/core-services-context.xml]: Cannot resolve reference to bean 'luceneFullTextSearchIndexer' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'luceneFullTextSearchIndexer' defined in class path resource [alfresco/core-services-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.alfresco.module.demoscripts.SimpleWebScript] for bean with name 'webscript.org.alfresco.demo.simple.get' defined in file [/home/<name>/alfresco
04-06-2011 05:30 AM
04-06-2011 07:11 AM
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.alfresco.module.demoscripts.SimpleWebScript] for bean with name 'webscript.org.alfresco.demo.simple.get' defined in file [/home/henril/alfresco-3.4.d/tomcat/webapps/alfresco/WEB-INF/classes/org/springframework/extensions/webscripts/web-scripts-application-context.xml]; nested exception is java.lang.ClassNotFoundException: org.alfresco.module.demoscripts.SimpleWebScript
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1208)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:568)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:381)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:375)
at org.alfresco.repo.search.impl.lucene.fts.FullTextSearchIndexerImpl.setBeanFactory(FullTextSearchIndexerImpl.java:296)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1422)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1389)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
… 46 more
Caused by: java.lang.ClassNotFoundException: org.alfresco.module.demoscripts.SimpleWebScript
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1229)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1200)
… 55 more
04-06-2011 08:06 AM
04-06-2011 08:32 AM
04-06-2011 08:34 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.