Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
a beanFactoryReference already exists for key jbpmConfiguration Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • a beanFactoryReference already exists for key jbpmConfiguration

    Hi,

    I'm new on this forum and I have a big problem to solve (ASAP).
    This is a problem I often see in this forum (sorry for all my grammatical faults).

    Anyway, the exception I had is this one

    2007-03-08 10:41:37,316 ERROR [org.jboss.soa.esb.listeners.message.ActionProcessi ngPipeline] (pool-4-thread-1) Premature termination of action processing pipeline [Ljava.lang.String;@4bce6c]. ActionProcessor [com.Bidule.fop.commun.EsbDemarreurProcessus] method not found
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:494)
    at org.jboss.soa.esb.listeners.message.ActionProcessi ngPipeline.run(ActionProcessingPipeline.java:77)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run Task(ThreadPoolExecutor.java:650)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:675)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'fop.demarrer.traiterCommande.Bidule' defined in class path resource [spring/applicationContextJbpm.xml]: Cannot resolve reference to bean 'fop.jbpmTemplate.traiterCommande' while setting constructor argument with index 0; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'fop.jbpmTemplate.traiterCommande' defined in class path resource [spring/applicationContextJbpm.xml]: Cannot resolve reference to bean 'fop.jbpmConfiguration' while setting constructor argument with index 0; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'fop.jbpmConfiguration' defined in class path resource [spring/applicationContextJbpm.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: a beanFactoryReference already exists for key fop.jbpmConfiguration
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:190)
    at org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:106)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.resolveConstructorArgum ents(AbstractAutowireCapableBeanFactory.java:739)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.autowireConstructor(Abs tractAutowireCapableBeanFactory.java:644)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:358)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
    at org.springframework.context.support.AbstractApplic ationContext.getBean(AbstractApplicationContext.ja va:537)
    at com.Bidule.commun.esb.SpringListenerAction.<init>( SpringListenerAction.java:58)
    at com.Bidule.commun.esb.SpringListenerAction.<init>( SpringListenerAction.java:43)
    at com.Bidule.fop.commun.EsbDemarreurProcessus.<init> (EsbDemarreurProcessus.java:28)
    ... 8 more

    Caused by: java.lang.IllegalArgumentException: a beanFactoryReference already exists for key fop.jbpmConfiguration
    at org.springmodules.workflow.jbpm31.JbpmFactoryLocat or.addToMap(JbpmFactoryLocator.java:113)
    at org.springmodules.workflow.jbpm31.JbpmFactoryLocat or.setBeanFactory(JbpmFactoryLocator.java:81)
    at org.springmodules.workflow.jbpm31.LocalJbpmConfigu rationFactoryBean.setBeanFactory(LocalJbpmConfigur ationFactoryBean.java:88)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:391)
    ... 28 more
    We use the :

    Spring-modules 0.7 (But I tried to replace the spring-modules-jbpm31.jar by the one of the 0.8, but it did not solve my problem).
    JBOSS 4.0.4.GA

    I don't know which information you need in order to help me to solve this problem, but ask me, and I will provides you immediatly

  • #2
    We have an applicationContextJbpm.xml file

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

    <!-- Datasource specifique jBpm -->


    <bean id="sessionFactory.biduleV2.oracle.jbpm"
    class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean"
    lazy-init="true">
    <property name="dataSource">
    <description>
    Session Factory specifique a la base hibernate de jBpm
    </description>
    <ref bean="ds.biduleV2.oracle" />
    </property>
    <!-- Pour tester BUG 4 en unitaire <property name="hibernateProperties">
    <props>
    <prop key="cache.provider_class">org.hibernate.cache.NoC acheProvider</prop>
    <prop key="hibernate.cache.use_second_level_cache">false </prop>
    <prop key="hibernate.cache.use_query_cache">false</prop>
    </props>
    </property> -->
    <property name="mappingResources">
    <list>
    <value>jbpm/org/jbpm/db/hibernate.queries.hbm.xml</value>
    <value>jbpm/org/jbpm/instantiation/Delegation.hbm.xml</value>
    <value>jbpm/org/jbpm/logging/log/ProcessLog.hbm.xml</value>
    <value>jbpm/org/jbpm/logging/log/CompositeLog.hbm.xml</value>
    <value>jbpm/org/jbpm/logging/log/MessageLog.hbm.xml</value>
    <value>jbpm/org/jbpm/file/def/FileDefinition.hbm.xml</value>
    .......
    .......
    </list>

    </property>
    </bean>




    <!-- jBPM configuration -->
    <bean id="fop.jbpmConfiguration"
    class="org.springmodules.workflow.jbpm31.LocalJbpm ConfigurationFactoryBean"
    lazy-init="true">
    <!--<constructor-arg index="0">
    <bean class="com.bidule.fop.commun.biduleJbpmFactoryLoca tor">
    </bean>
    </constructor-arg>
    --><property name="sessionFactory" ref="sessionFactory.biduleV2.oracle.jbpm" />
    <property name="configuration" value="classpath:bpm/jbpm.cfg.xml" />
    <property name="processDefinitions">
    <list>
    <ref local="fop.workflowTraiterCommande" />
    </list>
    </property>
    <property name="createSchema" value="${bidule.fop.jbpm.creation.schema}" />
    <property name="dropSchema" value="false" />
    <property name="contextName" value="fop.jbpm.context" />
    <!--<property name="beanFactory">
    <bean class="com.bidule.fop.commun.biduleJbpmFactoryLoca tor" lazy-init="true" />
    </property>
    --><!--
    <property name="processDefinitionsResources">
    <list>
    <value>
    classpath:/org/springmodules/workflow/jbpm31/someOtherWorkflow.xml
    </value>
    </list>
    </property>
    --></bean>
    <!-- Deuxieme fabrique
    class="com.bidule.fop.commun.biduleLocalJbpmConfig urationFactoryBean"
    class="org.springmodules.workflow.jbpm31.LocalJbpm ConfigurationFactoryBean"
    -->
    <!-- jBPM configuration -->
    <bean id="fop.jbpmConfigurationRetour"
    class="org.springmodules.workflow.jbpm31.LocalJbpm ConfigurationFactoryBean"
    lazy-init="true">
    <!--<constructor-arg index="0">
    <bean class="com.bidule.fop.commun.biduleJbpmFactoryLoca tor">
    </bean>
    </constructor-arg>
    --><property name="sessionFactory" ref="sessionFactory.biduleV2.oracle.jbpm" />
    <property name="configuration" value="classpath:bpm/jbpm.cfg.xml" />
    <property name="processDefinitions">
    <list>
    <ref local="fop.workflowTraiterRetour" />
    </list>
    </property>
    <property name="createSchema" value="${bidule.fop.jbpm.creation.schema}" />
    <property name="dropSchema" value="false" />
    <property name="contextName" value="fop.jbpm.context" />
    <!--<property name="beanFactory">
    <bean class="com.bidule.fop.commun.biduleJbpmFactoryLoca tor" lazy-init="true" />
    </property>
    --><!--
    <property name="processDefinitionsResources">
    <list>
    <value>
    classpath:/org/springmodules/workflow/jbpm31/someOtherWorkflow.xml
    </value>
    </list>
    </property>
    --></bean>

    <!-- LISTE des Definitions de Processus -->
    <!-- helper for reading jBPM process definitions -->
    <bean id="fop.workflowTraiterCommande"
    class="org.springmodules.workflow.jbpm31.definitio n.ProcessDefinitionFactoryBean">
    <property name="definitionLocation"
    value="classpathrocessus/traitercommande/processdefinition.xml" />
    </bean>
    <!-- helper for reading jBPM process definitions -->
    <bean id="fop.workflowTraiterRetour"
    class="org.springmodules.workflow.jbpm31.definitio n.ProcessDefinitionFactoryBean">
    <property name="definitionLocation"
    value="classpathrocessus/traiterRetourFT/processdefinition.xml" />
    </bean>

    <!-- Ajouter ici les beans correspondants aux autres processus -->

    <!-- Liste des Templates jBPM (Un par processus ) -->
    <bean id="fop.jbpmTemplate.traiterCommande"
    class="org.springmodules.workflow.jbpm31.JbpmTempl ate">
    <constructor-arg index="0" ref="fop.jbpmConfiguration" />
    <constructor-arg index="1" ref="fop.workflowTraiterCommande" />
    <property name="contextName" value="fop.jbpm.context" />
    </bean>

    <bean id="fop.jbpmTemplate.traiterRetour"
    class="org.springmodules.workflow.jbpm31.JbpmTempl ate">
    <constructor-arg index="0" ref="fop.jbpmConfigurationRetour" />
    <constructor-arg index="1" ref="fop.workflowTraiterRetour" />
    <property name="contextName" value="fop.jbpm.context" />
    </bean>


    <!-- Le Bean a mettre dans l'ESB pour démarrer le processus -->

    <bean id="fop.demarrer.traiterCommande.BiduleChouette" class="com.bidule.fop.commun.DemarrerProcessusImpl "
    lazy-init="true">
    <constructor-arg index="0" ref="fop.jbpmTemplate.traiterCommande"/>
    <constructor-arg index="1" value="AX_NOM_FICHIER" />
    <constructor-arg index="2" value="BiduleChouette" />
    </bean>



    </beans>
    I tried to break down this file into files :
    applicationContextJbpm.xml which contains the datasource bean (the jbpm datasource), the JbpmConfiguration, the JbpmTemplate, and the process definition
    and applicationContextBean.xml which contains the the definition of all my beans.

    But it does not solve the problem. In fact, I tried the solution describes within the discussion between Julian and shashankm posted yesterday.

    Comment


    • #3
      Can you post your web.xml? I imagine you must be having the same issue with the ContextLoaderListener that I mentioned in the post to which you are referring (e.g. the ApplicationContext is starting twice).

      Comment


      • #4
        Hi Julian,

        In fact, I think it's maybe the same issue but in a différent context. We don't use any webapp in our context (no servlet). We don't use any explicit call to the context. Our application only process files in the input of the Jbpm workflow. The exception happens where we try to process a second file.

        The beginning of our workflow is a class named DemarrerProcessusImpl.java.
        It's within this class that the context is loaded and this class is called each time we try to process a file (the first work well, but to the second call to this class make the exception appears).

        My class is this one :

        /**
        *
        */
        package com.bidule.fop.commun;

        import org.jboss.soa.esb.message.Message;
        import org.jbpm.graph.def.ProcessDefinition;
        import org.jbpm.graph.exe.ProcessInstance;
        import org.jbpm.graph.exe.Token;
        import org.springmodules.workflow.jbpm31.JbpmTemplate;

        import com.bidule.commun.erreur.Logger;

        /**
        * Cette classe déclenche la création d'un nouveau processus au sens jBpm, a partir d'un nom de fichier (AX_NOM_FICHIER) et transfert celui ci
        * depuis le message ESB vers le processus jBpm (variable nomLot)
        * @author bobleponge
        *
        */
        public class DemarrerProcessusImpl extends ProcessusAbstract implements DemarrerProcessus {

        private final static Logger LOG = Logger.getLogger(DemarrerProcessusImpl.class);
        private final String nomProprieteFichier;
        private final String demandeur;
        private final static String NOM_PROPRIETE_FICHIER_DEFAUT = "AX_NOM_FICHIER";
        private final static String NOM_VARIABLE_NOM_FICHIER = "nomLot";
        private final static String NOM_VARIABLE_CONTENU_FICHIER = "contenuLot";
        private final static String NOM_VARIABLE_DEMANDEUR = "demandeur";
        /**
        * Call super
        * @param template
        * @param nomPropFichier nom de la propriété du Message ESB qui contient le nom du fichier
        */
        public DemarrerProcessusImpl(JbpmTemplate template, String nomPropFichier, String demandeur) {
        super(template);
        nomProprieteFichier = nomPropFichier;
        this.demandeur = demandeur;
        }

        /**
        * Call super
        * @param template
        */
        public DemarrerProcessusImpl(JbpmTemplate template) {
        this(template,NOM_PROPRIETE_FICHIER_DEFAUT, null);
        }

        /* (non-Javadoc)
        * @see com.bidule.fop.commun.DemarrerProcessus#instancier Processus(org.jboss.soa.esb.message.Message)
        */
        public Message instancierProcessus(Message message) {
        if (LOG.isDebugEnabled()) {
        LOG.debug("instancierProcessus(" + message + ")");
        }
        ProcessInstance instanceDeProcessus = getDefinitionProcessus().createProcessInstance();
        if (LOG.isDebugEnabled()) {
        LOG.debug("processus instancie : " + instanceDeProcessus +" definition utilisee :" + getDefinitionProcessus().getName());
        }
        // Recupere le nom du fichier
        String nomFichier = (String)message.getProperties().getProperty(nomPro prieteFichier);
        if (LOG.isDebugEnabled()) {
        LOG.debug("nomFichier : property(" + nomProprieteFichier +")=" + nomFichier);
        }
        // Recupere le contenu du fichier
        String contenuFichier = new String(message.getBody().getContents());
        if (LOG.isDebugEnabled()) {
        LOG.debug("contenuFichier :" + contenuFichier);
        }
        // Recupere le demandeur

        if (LOG.isDebugEnabled()) {
        LOG.debug("demandeur :" + demandeur);
        }

        // Enregistrement du nom du fichier en tant que variable d'instance jBPM
        instanceDeProcessus.getContextInstance().setVariab le(NOM_VARIABLE_NOM_FICHIER, nomFichier);
        // Enregistrement du contenu du fichier en tant que variable d'instance jBPM
        instanceDeProcessus.getContextInstance().setVariab le(NOM_VARIABLE_CONTENU_FICHIER, contenuFichier);
        // Enregistrement du demandeur en tant que variable d'instance jBPM
        instanceDeProcessus.getContextInstance().setVariab le(NOM_VARIABLE_DEMANDEUR, demandeur);


        Long idProcessus = instanceDeProcessus.getId();
        if (LOG.isDebugEnabled()) {
        LOG.debug("process id :" + instanceDeProcessus.getId());
        }
        Token token = instanceDeProcessus.getRootToken();
        token.signal();
        message.getProperties().setProperty(NOM_PROPERTY_P ROCESS_ID, idProcessus);
        return message;
        }

        }

        Comment


        • #5
          It's within this class that the context is loaded
          So you have me a bit confused as to what is going on since I don't see the Spring ApplicationContext code in the class you posted (or any for that matter). The real question is how is your ApplicationContext is getting started? Either way, the final conclusion will likely be that your ApplicationContext is starting twice....so you need to hunt down the startup and see if it's getting called twice within the same JVM. As far as I can see your configs look ok (I don't think the lazy-init parameters you have will have an effect, but perhaps someone else is better positioned to address that).

          Comment

          Working...
          X