cancel
Showing results for 
Search instead for 
Did you mean: 

Custom action: ClassNotFound ActionExecuterAbstractBase

iblanco
Confirmed Champ
Confirmed Champ
I'm trying to deploy a custom action. I've developed the custom action as explained in the Wiki, extending ActionExecuterAbstractBase.

But when I restart tomcat to load the new action I get this error:


16:46:40,723 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [es.binovo.alfresco.action.LegalXMLParser] for bean with name
'legal-xml-parser' defined in file [/var/lib/tomcat5.5/shared/classes/alfresco/extension/legal-xml-parser-context.xml]: problem  with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/alfresco/repo/action/executer/ActionExecuterAbstractBase
Caused by: java.lang.NoClassDefFoundError: org/alfresco/repo/action/executer/ActionExecuterAbstractBase

ActionExecuterAbstractBase does exist, in fact all the preconfigured actions reference this bean in the same way I'm doing, using the action-executer name. This bean seems already configured as the code "knows" that is needs the ActionExecuterAbstractBase so … Why isn't this working ?

The class looks like this:

package es.binovo.alfresco.action;

import java.util.List;

import org.alfresco.repo.action.ParameterDefinitionImpl;
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.model.FileFolderService;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;

import org.apache.log4j.Logger;

/**
* @author iblanco
*
*/
public class LegalXMLParser extends ActionExecuterAbstractBase {
   
   public final static String NAME = "legal-xml-parse";
   
   /** The NodeService to be used by the bean */
   protected NodeService nodeService;

   /** The FileFolderService to be used by teh bean */
   protected FileFolderService fileFolderService;

   private static Logger logger = Logger.getLogger(LegalXMLParser.class);
   
   @Override
   protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
      // TODO Auto-generated method stub
      if (logger.isDebugEnabled()) logger.debug("Inside executeImpl");
      
      //Map<QName, Serializable> properties = nodeService.getProperties(actionedUponNodeRef);
      
      ContentReader rawXML = fileFolderService.getReader(actionedUponNodeRef);
      rawXML.setMimetype("text/xml");
      String message = rawXML.getContentString();
      logger.debug(message);
      
   }

   /* (non-Javadoc)
    * @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
    */
   @Override
   protected void addParameterDefinitions(List<ParameterDefinition> paramList) {
      // TODO Auto-generated method stub
      logger.debug("Inside addParameterDefinitions");
   }
   
   /**
   * @param nodeService The NodeService to set.
   *
   * Este método es el que proporciona un enganche para que con la configuración
   * Spring que hagamos de esta acción de podamos pasar el servicio de nodos
   * de Alfresco.
   * 
   */
   public void setNodeService(NodeService nodeService) {
      this.nodeService = nodeService;
   }

   public void setFileFolderService(FileFolderService fileFolderService){
      this.fileFolderService = fileFolderService;
   }
}

I've compiled it and placed the class in a {tomcat_directory}/shared/classes/es/binovo/alfresco/action/LegalXMLParser.class.

I also created legal-xml-parser-context.xml and placed it in {tomcat_directory}/shared/classes/alfresco/extension/, with content:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
   <!– Parse generated XML –>
   <bean id="legal-xml-parser" class="es.binovo.alfresco.action.LegalXMLParser" parent="action-executer">
      <property name="nodeService">
         <ref bean="NodeService" />
      </property>
      <property name="fileFolderService">
         <ref bean="FileFolderService" />
      </property>
      <property name="publicAction">
         <value>true</value>
      </property>
   </bean>   
</beans>
2 REPLIES 2

iblanco
Confirmed Champ
Confirmed Champ
Well, I was just copying my classes to alfresco extension's class directory, I have packed them in a JAR file and placed it in Alfresco's webapp's lib path and it works.

It seems that the classpath is not the same when the classes are loaded from the extension's path and the webapp's lib path. Maybe it is obvious for all live long Java guy, but I was formerly a PHP guy.

jlabuelo
Champ on-the-rise
Champ on-the-rise
Hi there… it 's been a while since you have posted this issue, but now we are facing the same situation in this post

https://forums.alfresco.com/forum/developer-discussions/alfresco-explorer-development/error-creating...

Could you take a quick look to it and let us know why  our Action Class is not beeing visible to Alfresco?

Thanks a lot!!