AnsweredAssumed Answered

Custom Action within jar

Question asked by jackson on Jul 6, 2011
Latest reply on Aug 5, 2011 by fitzybhoy
Hello all!
Sorry if chose wrong topic branch.
I have a problem:
I created a custom action and put all files in jar. I copied jar file to webapps/alfresco/WEB-INF/lib and restarted server.
Alfresco shown me an error :(  :

14:22:57,158  INFO  [alfresco.config.JndiPropertyPlaceholderConfigurer] Loading
properties file from class path resource [alfresco/alfresco-shared.properties]
14:23:44,886  ERROR [web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find clas
s [org.alfresco.sample.CustomActionExecuter] for bean with name 'custom-action'
defined in URL [jar:file:/D:/servers/alfresco-community-tomcat-3.2/tomcat/webapp
s/alfresco/WEB-INF/lib/custom-action.jar!/alfresco/extension/custom-action-conte
xt.xml]; nested exception is java.lang.ClassNotFoundException: org.alfresco.samp
le.CustomActionExecuter
Caused by: java.lang.ClassNotFoundException: org.alfresco.sample.CustomActionExe
cuter
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1387)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
der.java:1233)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:229)
        at org.springframework.beans.factory.support.AbstractBeanDefinition.reso
lveBeanClass(AbstractBeanDefinition.java:327)
        at org.springframework.beans.factory.support.AbstractBeanFactory.resolve
BeanClass(AbstractBeanFactory.java:1073)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:283)
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:352)
        at org.springframework.web.context.ContextLoader.createWebApplicationCon
text(ContextLoader.java:246)
        at org.springframework.web.context.ContextLoader.initWebApplicationConte
xt(ContextLoader.java:189)
        at org.springframework.web.context.ContextLoaderListener.contextInitiali
zed(ContextLoaderListener.java:49)
        at org.alfresco.web.app.ContextLoaderListener.contextInitialized(Context
LoaderListener.java:69)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContex
t.java:3843)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
342)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase
.java:791)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:77
1)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)

        at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.ja
va:627)
        at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.j
ava:553)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488
)
        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(Lifecycl
eSupport.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:5
16)
        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(DelegatingMethodAcces
sorImpl.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)
Jul 6, 2011 2:23:44 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Jul 6, 2011 2:23:44 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [/alfresco] startup failed due to previous errors

custom-action.jar have follow structure:
alfresco
- extension
- - custom-action-context.xml
META-INF
- MANIFEST.MF
org
- alfresco
- - sample
- - - CustomActionExecutor.class
- - - custom-action-messages.properties


custom-action-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="custom-action" class="org.alfresco.sample.CustomActionExecuter" parent="action-executer" >
      <property name="nodeService">
         <ref bean="nodeService" />
      </property>
   </bean>
   
   <bean id="custom-action-messages" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
      <property name="resourceBundles">
         <list>
            <value>org.alfresco.sample.custom-action-messages</value>
         </list>
      </property>
   </bean>
</beans>

CustomActionExecutor.java:

package org.alfresco.sample;

import java.util.List;

import org.alfresco.repo.action.executer.ActionExecuterAbstractBase;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;

public class CustomActionExecutor extends ActionExecuterAbstractBase {

    public static final String NAME = "custom-action";
    private NodeService nodeService;
   
    public void setNodeService(NodeService nodeService){
        this.nodeService = nodeService;
    }
   
    public CustomActionExecutor(){
        System.out.println("Class EXIST!!!!!!!!!!");
    }
   
    @Override
    protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
        // TODO Auto-generated method stub
        if (this.nodeService.exists(actionedUponNodeRef) == true){
            System.out.println("Custom Action executed: node exist");
        }
        else{
            System.out.println("Custom Action executed: node NOT exist");
        }
    }

    @Override
    protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
        // TODO Auto-generated method stub
       
    }

}


custom-action-messages.properties:

custom-action.title=Add tags to item
custom-action.description=This action adds tags to the matched item


What did I do wrong? Why Alfresco can't found org.alfresco.sample.CustomActionExecuter?
I use alfresco-community-tomcat-3.2
Thank You for any help!

Outcomes