5 Replies Latest reply on Jul 26, 2010 5:40 PM by tunmang

    Help for deploying a mail node with MailTemplateRegistry

    tunmang
        • 1. Re: Help for deploying a mail node with MailTemplateRegistry
          rebody

          Hi Tung,

           

          I make a testcase based your mail activity configuration.  And there is no exception occured as your mention.  Here is the testcase:

           

          http://anonsvn.jboss.org/repos/jbpm/jbpm4/trunk/modules/test-db/src/test/java/org/jbpm/test/activity/mail/MailTest.java

          • 2. Re: Help for deploying a mail node with MailTemplateRegistry
            aguizar

            If the MailTemplateRegistry lookup returns null, it is possible that your jbpm.cfg.xml does not define any template, in which case MailTemplateRegistry is not injected into the environment.

             

            In version 4.4, jbpm.default.cfg.xml no longer contains the predefined notification and reminder templates. Instead, it imports a separate resource, jbpm.mail.templates.xml. An empty jbpm.mail.templates.xml file could be the cause of the WireException.

             

            Please attach your jBPM configuration file and any custom documents imported from it. As HuiSheng already pointed out, injecting a template into a custom mail producer is part of the test suite and should work with the adequate configuration.

            • 3. Re: Help for deploying a mail node with MailTemplateRegistry
              tunmang

              Hi HuiSheng and Alejandro :

               

              Thanks for your help, it is jbpm 4.3 deployed on our host, and we can not upgrade it to 4.4 (at least it needs stay for a long time before change).

               

              The following is our jbpm.default.cfg.xml, and I did not see where it defines to injected MailTemplateRegistry. So how do I define it in the xml?

               

              Thanks a lot again,

              Tun Mang

               

               

              <?xml version="1.0" encoding="UTF-8"?>
              <jbpm-configuration>
                <process-engine-context> 
                  <repository-service />
                  <repository-cache />
                  <execution-service />
                  <history-service />
                  <management-service />
                  <identity-service />
                  <task-service />
                 <object init="eager" />
                 <object>
                   <field name="commandService">
                     <ref object="newTxRequiredCommandService" />
                   </field>
                 </object>   
                <id-generator />
               
                <types resource="jbpm.variable.types.xml" />    
                  <command-service>
                    <retry-interceptor />
                    <environment-interceptor policy="requiresNew" />      
                    <standard-transaction-interceptor />
                  </command-service>
                  <hibernate-configuration>
                    <cfg resource="jbpm.hibernate.cfg.xml" />    
                  </hibernate-configuration>
                  <hibernate-session-factory />
                  <script-manager default-expression-language="juel"
                                  default-script-language="juel"
                                  read-contexts="execution, environment, process-engine"
                                  write-context="" >
                    <script-language name="juel" factory="org.jbpm.pvm.internal.script.JuelScriptEngineFactory" />
                  </script-manager>
                 
                  <authentication />   
                  <address-resolver />
                  <business-calendar>
                    <monday    hours="9:00-12:00 and 12:30-17:00"/>
                    <tuesday   hours="9:00-12:00 and 12:30-17:00"/>
                    <wednesday hours="9:00-12:00 and 12:30-17:00"/>
                    <thursday  hours="9:00-12:00 and 12:30-17:00"/>
                    <friday    hours="9:00-12:00 and 12:30-17:00"/>
                    <holiday period="01/07/2008 - 31/08/2008"/>
                  </business-calendar>
                 
                  <mail-template name='task-notification'>
                    <to users="${task.assignee}"/>
                    <subject>${task.name}</subject>
                    <text><![CDATA[Hi ${task.assignee},
              Task "${task.name}" has been assigned to you.
              ${task.description}
              Sent by JBoss jBPM
              ]]></text>
                  </mail-template>
               
                  <mail-template name='task-reminder'>
                    <to users="${task.assignee}"/>
                    <subject>${task.name}</subject>
                    <text><![CDATA[Hey ${task.assignee},
              Do not forget about task "${task.name}".
              ${task.description}
              Sent by JBoss jBPM
              ]]></text>
                  </mail-template>
               
                </process-engine-context>
                <transaction-context>
                  <repository-session />
                  <db-session />   
                  <identity-session />
                  <message-session />
                  <timer-session />
                  <history-session />
                  <mail-session>
                    <mail-server>
                      <session-properties resource="jbpm.mail.properties" />
                    </mail-server>
                  </mail-session>  
                </transaction-context>
              </jbpm-configuration>
              • 4. Re: Help for deploying a mail node with MailTemplateRegistry
                aguizar

                Thanks for your help, it is jbpm 4.3 deployed on our host, and we can not upgrade it to 4.4 (at least it needs stay for a long time before change).

                OK. This explains the problem. In jBPM 4.3 wire context lookups by class did not search the environment. Hence the MailTemplateRegistry lookup always returns null in that version. Unfortunately there is no workaround. You'll have to upgrade.

                The following is our jbpm.default.cfg.xml, and I did not see where it defines to injected MailTemplateRegistry. So how do I define it in the xml?

                MailTemplateRegistry is not injected directly. Instead, the first time a mail-template element is found in the configuration,  the registry is instantiated and put into the environment. Subsequent mail templates simply fetch the registry and add themselves.

                • 5. Re: Help for deploying a mail node with MailTemplateRegistry
                  tunmang
                  Hi Alejandro:
                  Thanks a lot for you help. But upgrading to 4.4 is really not an option for us now.
                  We tried the mail node in 4.3, but only the following one is OK:
                     Case (1) :   
                     <mail name="send mail" g="251,159,80,40"  template="task-notification"  >     
                        <transition to="end1"/>
                    </mail>
                  Other cases are all failed just in order to make the implemented MailProducer work:
                      Case (2): The exceptions are already posted in my previous post on Jul 23, 2010 4:58 PM. (We already make sure the template is defined in jbpm.default.cfg.xml, and also tried changing it to the task-notification template, but both throw the same exceptions.)
                  Based upon your last update, our questions are: is it possible to use an implemented MailProducer in a mail node in jbpm 4.3 and how ?
                  Thanks again