AnsweredAssumed Answered

Custom evaluator for Share

Question asked by plastiko on Jan 2, 2012
Latest reply on Jan 3, 2018 by Aleksey Bykov
Some preliminary words:
I use Alfresco 4.0.b community edition and Alfresco and Share are running in the same tomcat application server (default installation).
I extended Share to show a custom icon (indicator) for all files that implement a custom aspect i have defined (dw:signed). I started from Maven archetype "maven-alfresco-share-module-archetype" for building an Alfresco Share Modules as JAR and i have wrote my custom share-config-custom.xml and custom-slingshot-digsigShare-context.xml.

share-config-custom.xml

<alfresco-config>
   <config evaluator="string-compare" condition="DocumentLibrary">
      <indicators>
   <indicator id="signed" index="10" icon="signed-16.png" label="Signed">
            <evaluator>evaluator.doclib.indicator.signed</evaluator>
         </indicator>
      </indicators>
   </config>
</alfresco-config>


custom-slingshot-digsigShare-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="evaluator.doclib.indicator.signed" class="org.alfresco.web.evaluator.HasAspectEvaluator">
      <property name="aspects">
         <list>
            <value>dw:signed</value>
         </list>
      </property>
   </bean>
</beans>

I've packaged all this stuff in a jar with maven and i put my digsigShare.jar in /ALFRESCO_HOME/tomcat/shared/lib
It works.


At this time i would like to write a more complex custom evaluator. I've wrote my java bean that extends org.alfresco.web.ui.common.component.evaluator.BaseEvaluator

DigsigEvaluator.java

import org.alfresco.web.ui.common.component.evaluator.BaseEvaluator;

public class DigsigEvaluator extends BaseEvaluator {

   @Override
   public boolean evaluate() {
      // TODO Auto-generated method stub
      return false;
   }

}

i've changed custom-slingshot-digsigShare-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="evaluator.doclib.indicator.signed" class="it.drwolf.alfresco.share.digsig.evaluator.DigsigEvaluator"/>
</beans>

I've packaged and put the jar in the same place but Share does not start, i got this exception:

2011-12-23 15:51:28,891  ERROR [web.context.ContextLoader] [main] Context initialization failed
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [it.drwolf.alfresco.share.digsig.evaluator.DigsigEvaluator] for bean with name 'evaluator.doclib.indicator.signed' defined in URL [jar:file:/home/drwolf/alfresco-4.0.b/tomcat/webapps/share/WEB-INF/lib/digsigShare-0.0.1-SNAPSHOT.jar!/alfresco/web-extension/custom-slingshot-digsigShare-context.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/alfresco/web/ui/common/component/evaluator/BaseEvaluator
   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.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.deployWAR(HostConfig.java:905)
   at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500)
   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/web/ui/common/component/evaluator/BaseEvaluator
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
   at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2527)
   at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1010)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1483)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
   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)
   … 33 more
Caused by: java.lang.ClassNotFoundException: org.alfresco.web.ui.common.component.evaluator.BaseEvaluator
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
   … 45 more

Someone can help me?

tnx

Samuele

Outcomes