cancel
Showing results for 
Search instead for 
Did you mean: 

DeclarativeWebScript

xsp
Champ in-the-making
Champ in-the-making
Hi,

I followed "Creating a Folder Listing Java-backed web script" as per http://docs.alfresco.com/4.0/index.jsp

The issues is that the class org.alfresco.web.scripts.DeclarativeWebScript does not exist in the SDK. (…in fact is the whole package that does not exist org.alfresco.web.scripts)

I changed it to the following package.


import org.springframework.extensions.webscripts.DeclarativeWebScript


This allowed me to compile my java backed webscript. However once I deployed it to the alfresco servcer, it complained that the class cannot be found.

So it seems that the alfresco SDK is expecting one package for the DeclarativeWebScript and the alfresco server another. ?

Can someone please confirm, or let me know what is wrong with this?

thanks
4 REPLIES 4

jpotts
World-Class Innovator
World-Class Innovator
What version of Alfresco are you running? Where did you put your compiled class?

Jeff

xsp
Champ in-the-making
Champ in-the-making
Alfresco version: Community - v4.2.0 (4576)
SDK version: alfresco-community-sdk-4.2.c

This is what I followed / did:

  • I added javadir.get.desc.xml and javadir.get.html.ftl in the web scripts extension using alfresco.
  • In \Alfresco\tomcat\shared\classes I created the folders: org\example and put there the compiled class
  • In \Alfresco\tomcat\shared\classes\alfresco\extension i created javadir-context.xml
Then when I start Alfresco I got this error in alfrescotomcat.stdout file:


2013-02-20 07:18:37,932  ERROR [web.context.ContextLoader] [localhost-startStop-1] Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.example.JavaDir] for bean with name 'webscript.org.example.javadir.get' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\javadir-context.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/extensions/webscripts/DeclarativeWebScript
   at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1253)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
   at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1319)
   at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:885)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
   at org.alfresco.web.app.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:63)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791)
   at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285)
   at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:618)
   at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:963)
   at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1600)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
   at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
   at java.util.concurrent.FutureTask.run(FutureTask.java:166)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
   at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoClassDefFoundError: org/springframework/extensions/webscripts/DeclarativeWebScript
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
   at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:264)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
   at org.springframework.util.ClassUtils.forName(ClassUtils.java:257)
   at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1271)
   at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1242)
   … 24 more
Caused by: java.lang.ClassNotFoundException: org.springframework.extensions.webscripts.DeclarativeWebScript
   at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
   … 43 more

xsp
Champ in-the-making
Champ in-the-making
Hi Jeff,

Have you had the change to look at the versions and setps I done as described above?

…I think both the versions ans steps I've done are the right ones.

Thanks
Xavi

xsp
Champ in-the-making
Champ in-the-making
Hi Jeff,

You can leave it as finally I've got it working. …I put the files in the wrong place as you suggested. …I've found it following http://wiki.alfresco.com/wiki/Java-backed_Web_Scripts_Samples#Writing_the_Web_Script_.28Java.29 …where it stays the right locations.

thanks
Xavi