cancel
Showing results for 
Search instead for 
Did you mean: 

Create a simple behavior sample - alfresco 3.4

rantamplan2
Champ in-the-making
Champ in-the-making
I am trying to implement a very simple behavior sample in my alfresco, but it doesn't install it ok, it appears in the log the message:

Invalid property 'nodeService' of bean class [jeffpotts.Invoicing]: Bean property 'nodeService' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?


My bean dmr-invoice-context.xml is:

<beans>
   <bean id="dmr_dani_sample_invoice_dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
      <property name="models">
         <list>
            <value>alfresco/extension/dmr-invoiceModel.xml</value>
         </list>
      </property>
   </bean>
   <bean id="ratingBehavior" class="jeffpotts.Invoicing" init-method="init">
        <property name="nodeService">
             <ref bean="NodeService" />
         </property>
         <property name="policyComponent">
             <ref bean="policyComponent"/>
         </property>
    </bean>
</beans>


This is my java class:

package jeffpotts;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.policy.Behaviour;
import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;

public class Invoicing implements NodeServicePolicies.OnCreateNodePolicy
{
    private NodeService nodeService;
    private PolicyComponent policyComponent;
    private Behaviour onCreateNode;

    public void init()
    {
        this.onCreateNode = new JavaBehaviour(this, "onCreateNode", NotificationFrequency.TRANSACTION_COMMIT);
        QName qn1 = QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode");
       

        QName qn2 = QName.createQName(InvoiceModel.NAMESPACE_INVOICING_CONTENT_MODEL,
                InvoiceModel.TYPE_INVOICING.toString());

        this.policyComponent.bindClassBehaviour(qn1, qn2, this.onCreateNode);

    }

    @Override
    public void onCreateNode(ChildAssociationRef childAssocRef)
    {
        // Implement something

    }
}

Somebody can help me?. Thanks!
6 REPLIES 6

mitpatoliya
Star Collaborator
Star Collaborator
create getter setter method for nodeservice in your bean Invoicing

Ok, you are right, I needed both getters and setter for policyComponent and nodeService, so I have added both getters and setters. Now it appears another error:

Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (2) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'nodeService' threw exception; nested exception is java.lang.StackOverflowError
PropertyAccessException 2: org.springframework.beans.MethodInvocationException: Property 'policyComponent' threw exception; nested exception is java.lang.StackOverflowError

Do you know why it happens it?

mitpatoliya
Star Collaborator
Star Collaborator
could you post full log it seems some the details regarding error are missing?

/Library/Tomcat/Home/bin/catalina.sh: line 2: rtr: command not found
Using CATALINA_BASE:   /Library/Tomcat/Home
Using CATALINA_HOME:   /Library/Tomcat/Home
Using CATALINA_TMPDIR: /Library/Tomcat/Home/temp
Using JRE_HOME:        /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
Using CLASSPATH:       /Library/Tomcat/Home/bin/bootstrap.jar
java.lang.IllegalStateException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1566)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
   at org.jgroups.util.TimeScheduler2._run(TimeScheduler2.java:294)
   at org.jgroups.util.TimeScheduler2.run(TimeScheduler2.java:278)
   at java.lang.Thread.run(Thread.java:680)
Exception in thread "Timer runner-1,<CL-NAME>,Daniels-MacBook-Pro-8041" java.lang.NullPointerException
   at org.jgroups.logging.Log4JLogImpl.error(Log4JLogImpl.java:64)
   at org.jgroups.util.TimeScheduler2.run(TimeScheduler2.java:281)
   at java.lang.Thread.run(Thread.java:680)
Mar 18, 2013 10:23:31 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
Mar 18, 2013 10:23:32 AM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
Mar 18, 2013 10:23:32 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 419 ms
Mar 18, 2013 10:23:32 AM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Mar 18, 2013 10:23:32 AM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.36
Mar 18, 2013 10:23:32 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor alfresco.xml
Mar 18, 2013 10:23:32 AM org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "org.apache.myfaces.webapp.StartupServletContextListener" is already configured for this context. The duplicate definition has been ignored.
10:23:36,768  INFO  [alfresco.config.JndiPropertiesFactoryBean] Loading properties file from class path resource [alfresco/repository.properties]
10:23:36,771  INFO  [alfresco.config.JndiPropertiesFactoryBean] Loading properties file from class path resource [alfresco/domain/transaction.properties]
10:23:36,771  INFO  [alfresco.config.JndiPropertiesFactoryBean] Loading properties file from file [/Library/Tomcat/apache-tomcat-6.0.36/webapps/alfresco/WEB-INF/classes/alfresco/module/test/alfresco-global.properties]
10:23:36,771  INFO  [alfresco.config.JndiPropertiesFactoryBean] Loading properties file from URL [file:/Library/Tomcat/apache-tomcat-6.0.36/shared/classes/alfresco-global.properties]
10:23:36,827  INFO  [alfresco.config.FixedPropertyPlaceholderConfigurer] Loading properties file from class path resource [alfresco/version.properties]
10:23:36,902  INFO  [alfresco.config.JndiPropertyPlaceholderConfigurer] Loading properties file from class path resource [alfresco/alfresco-shared.properties]
10:23:36,932  INFO  [alfresco.config.FixedPropertyPlaceholderConfigurer] Loading properties file from class path resource [alfresco/domain/cache-strategies.properties]
10:23:37,427  INFO  [management.subsystems.ChildApplicationContextFactory] Starting 'sysAdmin' subsystem, ID: [sysAdmin, default]
10:23:37,454  INFO  [alfresco.config.FixedPropertyPlaceholderConfigurer] Loading properties file from class path resource [alfresco/version.properties]
10:23:37,455  INFO  [alfresco.config.JndiPropertyPlaceholderConfigurer] Loading properties file from class path resource [alfresco/alfresco-shared.properties]
10:23:37,455  INFO  [alfresco.config.FixedPropertyPlaceholderConfigurer] Loading properties file from class path resource [alfresco/domain/cache-strategies.properties]
10:23:37,464  INFO  [management.subsystems.ChildApplicationContextFactory] Startup of 'sysAdmin' subsystem, ID: [sysAdmin, default] complete
10:23:47,247  INFO  [management.subsystems.ChildApplicationContextFactory] Stopping 'sysAdmin' subsystem, ID: [sysAdmin, default]
10:23:47,247  INFO  [management.subsystems.ChildApplicationContextFactory] Stopped 'sysAdmin' subsystem, ID: [sysAdmin, default]
10:23:47,252  ERROR [web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ratingBehavior' defined in file [/Library/Tomcat/apache-tomcat-6.0.36/shared/classes/alfresco/extension/dmr-invoice-context.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (2) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'nodeService' threw exception; nested exception is java.lang.StackOverflowError
PropertyAccessException 2: org.springframework.beans.MethodInvocationException: Property 'policyComponent' threw exception; nested exception is java.lang.StackOverflowError
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1341)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
   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:4206)
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
   at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)
   at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)
   at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
   at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
   at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
   at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
   at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
   at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
   at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
   at org.apache.catalina.core.StandardService.start(StandardService.java:525)
   at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
   at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
   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: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (2) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'nodeService' threw exception; nested exception is java.lang.StackOverflowError
PropertyAccessException 2: org.springframework.beans.MethodInvocationException: Property 'policyComponent' threw exception; nested exception is java.lang.StackOverflowError
   at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
   at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1338)
   … 38 more
Mar 18, 2013 10:23:47 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Mar 18, 2013 10:23:47 AM org.apache.catalina.core.StandardContext start
SEVERE: Context [/alfresco] startup failed due to previous errors
Mar 18, 2013 10:23:47 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/alfresco] appears to have started a thread named [net.sf.ehcache.CacheManager@73a51852] but has failed to stop it. This is very likely to create a memory leak.
Mar 18, 2013 10:23:47 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/alfresco] appears to have started a thread named [Timer runner-1,<CL-NAME>,Daniels-MacBook-Pro-58468] but has failed to stop it. This is very likely to create a memory leak.
Mar 18, 2013 10:23:47 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/alfresco] appears to have started a thread named [TransferQueueBundler,null,null] but has failed to stop it. This is very likely to create a memory leak.
Mar 18, 2013 10:23:47 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/alfresco] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@6225211b]) and a value of type [org.apache.cxf.bus.CXFBusImpl] (value [org.apache.cxf.bus.CXFBusImpl@73a0a5f3]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Mar 18, 2013 10:23:47 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/alfresco] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@37ef2fd3]) and a value of type [org.alfresco.util.CachingDateFormat] (value [yyyy-MM-dd]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Mar 18, 2013 10:23:47 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/alfresco] created a ThreadLocal with key of type [com.sun.xml.bind.v2.ClassFactory$1] (value [com.sun.xml.bind.v2.ClassFactory$1@abf5743]) and a value of type [java.util.WeakHashMap] (value [{class org.alfresco.repo.audit.model._3.GenerateValue=java.lang.ref.WeakReference@20c85c1f, class org.alfresco.repo.audit.model._3.DataExtractors=java.lang.ref.WeakReference@42180809, class org.alfresco.repo.audit.model._3.PathMap=java.lang.ref.WeakReference@37b7a8c5, class org.alfresco.repo.audit.model._3.DataGenerators=java.lang.ref.WeakReference@7aa93a16, class org.alfresco.repo.audit.model._3.DataExtractor=java.lang.ref.WeakReference@7c24b943, class org.alfresco.repo.audit.model._3.Audit=java.lang.ref.WeakReference@4eff1d61, class org.alfresco.repo.audit.model._3.AuditPath=java.lang.ref.WeakReference@4ee1f3cb, class org.alfresco.repo.audit.model._3.RecordValue=java.lang.ref.WeakReference@544cbce2, class org.alfresco.repo.audit.model._3.PathMappings=java.lang.ref.WeakReference@7a04c4aa, class java.util.ArrayList=java.lang.ref.WeakReference@4f0bb37b, class org.alfresco.repo.audit.model._3.Application=java.lang.ref.WeakReference@93478c8, class org.alfresco.repo.audit.model._3.DataGenerator=java.lang.ref.WeakReference@53e59730}]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Mar 18, 2013 10:23:47 AM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/alfresco] created a ThreadLocal with key of type [com.sun.xml.bind.v2.runtime.Coordinator$1] (value [com.sun.xml.bind.v2.runtime.Coordinator$1@628fb58]) and a value of type [com.sun.xml.bind.v2.runtime.Coordinator[]] (value [[Lcom.sun.xml.bind.v2.runtime.Coordinator;@6c8d5190]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
log4j:ERROR LogMananger.repositorySelector was null likely due to error in class reloading, using NOPLoggerRepository.
Mar 18, 2013 10:23:48 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor host-manager.xml
Mar 18, 2013 10:23:48 AM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor manager.xml
Mar 18, 2013 10:23:48 AM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive share.war
10:23:54,491  INFO  [extensions.webscripts.DeclarativeRegistry] Registered 269 Web Scripts (+0 failed), 279 URLs
10:23:54,492  INFO  [extensions.webscripts.DeclarativeRegistry] Registered 8 Package Description Documents (+0 failed)
10:23:54,492  INFO  [extensions.webscripts.DeclarativeRegistry] Registered 0 Schema Description Documents (+0 failed)
10:23:54,605  INFO  [extensions.webscripts.AbstractRuntimeContainer] Initialised Spring Surf Container Web Script Container (in 1779.098ms)
10:23:54,632  INFO  [extensions.webscripts.TemplateProcessorRegistry] Registered template processor freemarker for extension ftl
10:23:54,691  INFO  [extensions.webscripts.ScriptProcessorRegistry] Registered script processor javascript for extension js
10:23:54,700  INFO  [extensions.webscripts.TemplateProcessorRegistry] Registered template processor freemarker for extension ftl
10:23:54,703  INFO  [extensions.webscripts.ScriptProcessorRegistry] Registered script processor javascript for extension js
10:23:54,713  INFO  [extensions.webscripts.TemplateProcessorRegistry] Registered template processor freemarker for extension ftl
10:23:54,716  INFO  [extensions.webscripts.ScriptProcessorRegistry] Registered script processor javascript for extension js
Mar 18, 2013 10:23:54 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory docs
Mar 18, 2013 10:23:54 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory examples
Mar 18, 2013 10:23:54 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
Mar 18, 2013 10:23:55 AM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
Mar 18, 2013 10:23:55 AM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Mar 18, 2013 10:23:55 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/15  config=null
Mar 18, 2013 10:23:55 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 22938 ms
Mar 18, 2013 10:25:46 AM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already.  Could not load org.jgroups.util.TimeScheduler2$1.  The eventual following stack trace is caused by an error thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access, and has no functional impact.
java.lang.IllegalStateException
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1566)
   at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
   at org.jgroups.util.TimeScheduler2._run(TimeScheduler2.java:294)
   at org.jgroups.util.TimeScheduler2.run(TimeScheduler2.java:278)
   at java.lang.Thread.run(Thread.java:680)
Exception in thread "Timer runner-1,<CL-NAME>,Daniels-MacBook-Pro-58468" java.lang.NullPointerException
   at org.jgroups.logging.Log4JLogImpl.error(Log4JLogImpl.java:64)
   at org.jgroups.util.TimeScheduler2.run(TimeScheduler2.java:281)
   at java.lang.Thread.run(Thread.java:680)

mitpatoliya
Star Collaborator
Star Collaborator
oohhhho , okey it does not sounds any logical but could you please restart your machine (inorder to make sure that alfresco and all associated services terminate) and check it once again?

rantamplan2
Champ in-the-making
Champ in-the-making
It works ok, thanks