AnsweredAssumed Answered

error creating a new Action in Explorer

Question asked by magarcia_sm on Apr 20, 2015
Hi there

We are practicing trying to create our first new action following the instructions of Chapter 4 at Alfresco Developer Guide book created by J.Potts. We have just created a new project in Eclipse using the same code and structure than from the book, however after creating the amp file and applying it to the alfresco.war, when we try to launch the alfresco explorer we get this error:


14:17:24,458 INFO  [org.alfresco.config.xml.XMLConfigService$PropertyConfigurer] Loading properties file from class path resource [alfresco/file-servers.properties]
14:17:31,724 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.someco.web.action.executer.SetWebFlag] for bean with name 'SetWebFlag' defined in file [D:\Alfresco_temp2\tomcat\webapps\alfresco\WEB-INF\classes\alfresco\extension\someco-actions-context.xml]; nested exception is java.lang.ClassNotFoundException: org.someco.web.action.executer.SetWebFlag
Caused by: java.lang.ClassNotFoundException: org.someco.web.action.executer.SetWebFlag
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1387)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1233)
   at org.springframework.util.ClassUtils.forName(ClassUtils.java:201)
   at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:327)
   at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1075)
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:282)
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
   at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
   at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
   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:525)
   at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:830)
   at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:719)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
   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:516)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
   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:288)
   at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
14:17:35,467 INFO  [org.alfresco.web.site.FrameworkHelper] Successfully Initialized Web Framework
14:17:37,626 INFO  [org.alfresco.web.scripts.DeclarativeRegistry] Registered 67 Web Scripts (+0 failed), 71 URLs
14:17:42,358 INFO  [org.alfresco.web.scripts.AbstractRuntimeContainer] Initialised Presentation Web Script Container (in 5033.1367ms)
14:18:43,314 INFO  [org.alfresco.web.scripts.DeclarativeRegistry] Registered 101 Web Scripts (+0 failed), 105 URLs
14:18:43,315 INFO  [org.alfresco.web.scripts.AbstractRuntimeContainer] Initialised WebFramework Web Script Container (in 60920.15ms)
14:18:43,376 INFO  [org.alfresco.web.site.FrameworkHelper] Successfully Initialized Web Framework


As far as we can see the error means that the system is not able to find the class "SetWebFlag"
However once we have created the amp file and it has been applied to the war file, after deploying this new war file, we are able to find the class in the jar file added in the path "tomcat\webapps\alfresco\WEB-INF\lib"  and also the path is right

This is our someco-actions-context.xml


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
   <bean id="SetWebFlag" class="com.someco.web.action.executer.SetWebFlag" parent="action-executer">
      <property name="nodeService">
         <ref bean="NodeService" />
      </property>
      <property name="publicAction">
         <value>true</value>
      </property>
   </bean>
   <bean id="extension.actionResourceBundles" parent="actionResourceBundles">
      <property name="resourceBundles">
         <list>
            <value>alfresco.extension.somecoactions</value>
         </list>
      </property>
   </bean>
</beans>


and as you can see in the pic we attach to this post, the route of the class is right

We have been hours thinking about this error, but we have not been able to find why is not working. Any quick ideas please?

Sure it must be quite silly, however we are not able to find it.

Thanks a lot in advance mates!

Attachments

Outcomes