cancel
Showing results for 
Search instead for 
Did you mean: 

Error Restarting Server after registering Java Based Web Script

mikeacain
Champ in-the-making
Champ in-the-making
After registering a Java Based Web Script I get the following error in the Alfresco Tomcat log

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 'webscript.org.alfresco.rydenscripts.propertyrecord.post' defined in class path resource [alfresco/web-scripts-application-context.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/alfresco/webservice/types/CML
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:946)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:890)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:416)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:261)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:192)
   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:3972)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
   at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
   at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
   at org.apache.catalina.core.StandardService.start(StandardService.java:519)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.NoClassDefFoundError: org/alfresco/webservice/types/CML
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
   at java.lang.Class.getConstructor0(Class.java:2699)
   at java.lang.Class.getDeclaredConstructor(Class.java:1985)
   at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:64)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:938)
   … 38 more
Caused by: java.lang.ClassNotFoundException: org.alfresco.webservice.types.CML
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
   … 44 more

Thanks

Mike
5 REPLIES 5

mitpatoliya
Star Collaborator
Star Collaborator
seems like issue with this file
web-scripts-application-context.xml
have you changed anything in that?
Please post content of that file

Hi Mits

I have add the following to declare the webscript.

   <bean id="webscript.org.alfresco.rydenscripts.propertyrecord.post"
      class="org.alfresco.module.rydenscripts.PropertyRecordPost"
      parent="webscript">
   </bean>

This is how java webscripts are declared and it works for other webscripts I have declared. Allow though they don't reference the SDK.

Mike

kaynezhang
World-Class Innovator
World-Class Innovator
Why do you call org.alfresco.webservice.types.CML in your Java Based Web Script ? org.alfresco.webservice.types.CML is a web service client class You don't need to call web service client to implement a java based  webscript.

By default  web service client will not be in classpath,so a ClassNotFoundException is throwed.

mitpatoliya
Star Collaborator
Star Collaborator
Yeah true,
It seems to be error because of that reference only.
You should be able to achieve your usecase with other services.
What you are trying to do in this script class?

mikeacain
Champ in-the-making
Champ in-the-making
Hi thanks Mits and kaynezhang

I have resolved my issue by adding alfresco-web-service-client-3.4.d.jar to the <Alfresco>\tomcat\webapps\alfresco\WEB-INF\lib directory.

I didn't write the original code and trying to upgrade an Alfresco Community installation to the latest version. So trying to make as little changes as possible.

The Webservice is used to create a folder in the Document Library from a button on the Share Dashboard.

If there is better way to do this please let me know.

Regards

Mike