1 2 Previous Next 19 Replies Latest reply on Feb 25, 2011 7:10 AM by helal jean-noel

    Unable to set the mail configuration properties in JBPM 4.3

    virendra agarwal Newbie

      Hi,

      I am Using teh same jbpm.mail.properties file

       

      mail.smtp.host    smtp.gmail.com
      mail.smtp.port    465
      mail.smtp.socketFactory.port 465
      mail.smtp.auth  true
      mail.from       mymail@gmail.com
      mail.user        mymail
      mail.password    viren123
      mail.debug      true

       

      My process.jdpl.xml is

       

      <?xml version="1.0" encoding="UTF-8"?>

      <process name="InlineMail" xmlns="http://jbpm.org/4.3/jpdl">

        <start g="20,25,80,40">
          <transition to="send rectify note" />
        </start>

       

        <mail name="send rectify note" language="juel" g="99,25,115,45">
          <to addresses="virendag@rsgsystems.com" />
          <cc users="bb" groups="innerparty" />
          <bcc groups="thinkpol" />
          <subject>rectify ${newspaper}</subject>
          <text>${newspaper} ${date} reporting bb dayorder doubleplusungood
            refs unpersons rewrite fullwise upsub antefiling</text>

          <transition to="end" />
        </mail>

       

        <state name="end" g="240,25,98,45"/>

       

      </process>

       

      and my test case is

       

      public class InlineMailTest extends JbpmTestCase {

       

        Wiser wiser = null;
       
        String groupId1;
       
        String groupId2;

       

        protected void setUp() throws Exception {
          super.setUp();

       

          // deploy process
          String deploymentId = repositoryService.createDeployment()
              .addResourceFromClasspath("org/jbpm/examples/mail/inline/process.jpdl.xml")
              .deploy();
          registerDeployment(deploymentId);

       

          // create actors
          identityService.createUser("bb", "Big Brother", null, "virendag@rsgsystems.com");
          identityService.createUser("obrien", null, "O'Brien", "virendag@rsgsystems.com");
          identityService.createUser("charr", null, "Charrington", "virendag@rsgsystems.com");
          groupId1 = identityService.createGroup("thinkpol");
          groupId2 = identityService.createGroup("innerparty");
          identityService.createMembership("obrien", groupId2);
          identityService.createMembership("charr", groupId1);
          identityService.createMembership("obrien", groupId1);

       

        }

       

        protected void tearDown() throws Exception {
         // wiser.stop();

       

          // delete actors
          identityService.deleteUser("bb");
          identityService.deleteUser("obrien");
          identityService.deleteUser("charr");
         
          identityService.deleteGroup(groupId1);
          identityService.deleteGroup(groupId2);
         
          super.tearDown();
        }

       

        public void testInlineMail() throws MessagingException, IOException {
          // prepare dynamic values
          String newspaper = "times";
          Calendar calendar = Calendar.getInstance();
          calendar.clear();
          calendar.set(1983, Calendar.DECEMBER, 3);
          Date date = calendar.getTime();
          // assemble variables
          Map<String, Object> variables = new HashMap<String, Object>();
          variables.put("newspaper", newspaper);
          variables.put("date", date);
          // start process instance

          executionService.startProcessInstanceByKey("InlineMail", variables);
        }
      }

       

      But when run this test it always throw

       

      Caused by: javax.mail.AuthenticationFailedException

       

      Once i removed the mail.smtp.auth  true it works fine but can send mail to other domain server apart from gmail

      Please tell em what point i am missing here.

      I am really stuck with.

      Thanks

        • 1. Re: Unable to set the mail configuration properties in JBPM 4.3
          HuiSheng Xu Master

          Hi Virendra,

           

          If your mail server need authority.  You should provide a PasswordAuthentication.  It is a standard javamail api.  So you could google it. 

          • 2. Re: Unable to set the mail configuration properties in JBPM 4.3
            virendra agarwal Newbie

            Hey thanks for your quick reply.

            I have used that password aythenticator in java code as a test and it works fine. BUt my problem what i have to do in jbpm to use the same.

            My actual problem is i can send mail to any gmail id when i dont use mail.smtp.auth but when i use this attribute i have to give password and user id for my gmail account as we do in standard java api. BUt i dont know how to use this in jbpm. I saw the forums and every one is using it through mail.properties file as i have used but it didnt worked for me

            • 3. Re: Unable to set the mail configuration properties in JBPM 4.3
              virendra agarwal Newbie

              Hi Huisheng,

               

              I think while sending mails jbpm is not reading user name and password from my jbpm.mail.properties file.

              I saw the debug log it reads all other things from file.

              So can you tell me wher i have to provide user name and password so that jbpm can read it.

              mail.user=virendag
              mail.password=viren123

              These two properties.

              Thanks

              Virendra

              • 4. Re: Unable to set the mail configuration properties in JBPM 4.3
                Alejandro Guizar Master
                I think while sending mails jbpm is not reading user name and password from my jbpm.mail.properties file.

                I saw the debug log it reads all other things from file.

                So can you tell me wher i have to provide user name and password so that jbpm can read it.

                mail.user=virendag
                mail.password=viren123

                These two properties.

                jBPM does not read the mail.properties file directly, it is passed verbatim to the javax.mail.Session.getInstance(Properties) method. The JavaMail API documentation does not document a mail.password property. I believe this explains why the password is being ignored.

                 

                The mail session binding provides the means  to create a javax.mail.Authenticator from a wire description, although this is undocumented and untested. Would you please create a JIRA issue for this?

                • 5. Re: Unable to set the mail configuration properties in JBPM 4.3
                  Maciej Swiderski Master

                  As both Alejandro and HuiSheng mentioned you shall use javax.mail.Authenticator to achieve what you described.

                   

                  I have made few tests with that and it seems to work properly but it is not documented officially anywhere.

                  Following is brief description of steps needed to configure and use it:

                  1. Create custom implementation of Authenticator interface:

                   

                  import javax.mail.Authenticator;
                  import javax.mail.PasswordAuthentication;
                  
                  public class MyAuthenticator extends Authenticator {
                  
                       protected PasswordAuthentication getPasswordAuthentication() {
                         return new PasswordAuthentication("your user name", "your password");
                       }
                  }
                  

                   

                  2. Configure jbpm to use your custom Authenticator, extend default jbpm configuration:

                   

                      <mail-session>
                        <mail-server>
                          <session-properties resource="jbpm.mail.properties" />
                          <authenticator class="MyAuthenticator" auto-wire="true"/>
                        </mail-server>
                      </mail-session>
                  

                   

                  3. mail settings (jbpm.mail.properties):

                   

                  mail.smtp.auth=true
                  mail.smtp.host=smtp.gmail.com
                  mail.smtp.port=465
                  mail.smtp.socketFactory.port=465
                  mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
                  

                   

                  After these steps I was able to send emails from my gmail account to any email address.

                   

                  HTH

                  Maciej

                  1 of 1 people found this helpful
                  • 6. Re: Unable to set the mail configuration properties in JBPM 4.3
                    virendra agarwal Newbie

                    Hi Maciej,

                    Thanks for your effort. I tried your approach but it didnt work for me i got the same response.

                    Here it is what i did.

                    jbpm.mail.properties

                     

                    mail.transport.protocol=smtp
                    mail.smtp.auth=true
                    mail.smtp.host=smtp.rsgsystems.com
                    mail.smtp.port=25
                    mail.from=virendag@rsgsystems.com
                    mail.smtp.quitwait=false
                    mail.debug=true

                     

                    jbpm.cfg.xml

                     

                    <?xml version="1.0" encoding="UTF-8"?>

                     

                    <jbpm-configuration>

                     

                      <import resource="jbpm.default.cfg.xml" />
                      <import resource="jbpm.businesscalendar.cfg.xml" />
                      <import resource="jbpm.tx.hibernate.cfg.xml" />
                      <import resource="jbpm.jpdl.cfg.xml" />
                      <import resource="jbpm.bpmn.cfg.xml" />
                      <import resource="jbpm.identity.cfg.xml" />
                      <!-- Job executor is excluded for running the example test cases. -->
                      <!-- To enable timers and messages in production use, this should be included. -->
                      <!--
                      <import resource="jbpm.jobexecutor.cfg.xml" />
                      -->
                      <import resource="jbpm.mail.templates.examples.xml" />
                      <mail-session>
                          <mail-server>
                            <session-properties resource="jbpm.mail.properties" />
                            <authenticator auto-wire="true"/>
                          </mail-server>
                        </mail-session>
                    </jbpm-configuration>

                     

                    And my authenticator class

                    package org.jbpm.examples;

                     

                    import javax.mail.Authenticator;
                    import javax.mail.PasswordAuthentication;

                     

                    public class MyAuthenticator extends Authenticator {
                        
                        protected PasswordAuthentication getPasswordAuthentication() {
                            System.err.println("Testing working");
                          return new PasswordAuthentication("xxxx", "xxxx");

                     

                        }

                     

                    }

                     

                    Other things are same.

                    But when i run this code it didnt work i saw that it is not calling MyAuthenticator

                     

                    Here are the logs

                     

                    DEBUG: JavaMail version 1.4.1ea-SNAPSHOT
                    DEBUG: not loading file: C:\Program Files\Java\jre6\lib\javamail.providers
                    DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jre6\lib\javamail.providers (The system cannot find the file specified)
                    DEBUG: !anyLoaded
                    DEBUG: not loading resource: /META-INF/javamail.providers
                    DEBUG: successfully loaded resource: /META-INF/javamail.default.providers
                    DEBUG: Tables of loaded providers
                    DEBUG: Providers Listed By Class Name: {com.sun.mail.smtp.SMTPSSLTransport=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc], com.sun.mail.imap.IMAPSSLStore=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3SSLStore=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]}
                    DEBUG: Providers Listed By Protocol: {imaps=javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Sun Microsystems, Inc], imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc], smtps=javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc], pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc], pop3s=javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc], smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]}
                    DEBUG: successfully loaded resource: /META-INF/javamail.default.address.map
                    DEBUG: !anyLoaded
                    DEBUG: not loading resource: /META-INF/javamail.address.map
                    DEBUG: not loading file: C:\Program Files\Java\jre6\lib\javamail.address.map
                    DEBUG: java.io.FileNotFoundException: C:\Program Files\Java\jre6\lib\javamail.address.map (The system cannot find the file specified)
                    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
                    DEBUG SMTP: useEhlo true, useAuth true
                    10:32:46,047 SEV | [BaseJbpmTestCase]
                    ### EXCEPTION ###########################################
                    10:32:46,047 SEV | [BaseJbpmTestCase] TEST THROWS EXCEPTION: could not send email: javax.mail.internet.MimeMessage@9a18a0
                    org.jbpm.api.JbpmException: could not send email: javax.mail.internet.MimeMessage@9a18a0
                        at org.jbpm.pvm.internal.email.impl.MailSessionImpl.send(MailSessionImpl.java:60)
                        at org.jbpm.jpdl.internal.activity.MailActivity.perform(MailActivity.java:44)
                        at org.jbpm.jpdl.internal.activity.JpdlAutomaticActivity.execute(JpdlAutomaticActivity.java:15)
                        at org.jbpm.pvm.internal.model.op.ExecuteActivity.perform(ExecuteActivity.java:60)
                        at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperationSync(ExecutionImpl.java:656)
                        at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperation(ExecutionImpl.java:616)
                        at org.jbpm.pvm.internal.model.ExecutionImpl.start(ExecutionImpl.java:217)
                        at org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd.execute(StartProcessInstanceInLatestCmd.java:65)
                        at org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd.execute(StartProcessInstanceInLatestCmd.java:38)
                        at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)
                        at org.jbpm.pvm.internal.tx.StandardTransactionInterceptor.execute(StandardTransactionInterceptor.java:54)
                        at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)
                        at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)
                        at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
                        at org.jbpm.pvm.internal.svc.SkipInterceptor.execute(SkipInterceptor.java:43)
                        at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.startProcessInstanceByKey(ExecutionServiceImpl.java:70)
                        at org.jbpm.examples.mail.inline.InlineMailTest.testInlineMail(InlineMailTest.java:97)
                        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                        at java.lang.reflect.Method.invoke(Unknown Source)
                        at junit.framework.TestCase.runTest(TestCase.java:164)
                        at org.jbpm.test.BaseJbpmTestCase.runTest(BaseJbpmTestCase.java:80)
                        at junit.framework.TestCase.runBare(TestCase.java:130)
                        at junit.framework.TestResult$1.protect(TestResult.java:106)
                        at junit.framework.TestResult.runProtected(TestResult.java:124)
                        at junit.framework.TestResult.run(TestResult.java:109)
                        at junit.framework.TestCase.run(TestCase.java:120)
                        at junit.framework.TestSuite.runTest(TestSuite.java:230)
                        at junit.framework.TestSuite.run(TestSuite.java:225)
                        at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
                        at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
                        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
                    Caused by: javax.mail.AuthenticationFailedException
                        at javax.mail.Service.connect(Service.java:319)
                        at javax.mail.Service.connect(Service.java:169)
                        at javax.mail.Service.connect(Service.java:118)
                        at org.jbpm.pvm.internal.email.impl.MailSessionImpl.send(MailSessionImpl.java:50)
                        ... 35 more
                    ### EXCEPTION ###########################################
                    10:32:46,047 SEV | [BaseJbpmTestCase]

                     

                    Please suggest me how can i make this working using this code.

                    Thanks and Regards

                    Virendra

                    • 7. Re: Unable to set the mail configuration properties in JBPM 4.3
                      Maciej Swiderski Master

                      When you mentioned that I recall I tested that on 4.4 version perhaps it was fixed/added support for authenticator. Could you please give a try with trunk version? It is going to be release quite soon.

                       

                      Please refer to this thread for details on how to get it (without building it yourself): http://community.jboss.org/thread/153283

                      1 of 1 people found this helpful
                      • 8. Re: Unable to set the mail configuration properties in JBPM 4.3
                        virendra agarwal Newbie

                        Ok let me try this.

                        It means we need not to call myauthenticator function it will be called directly from cfg.xml file

                        Which means our configuration is correct.

                        Hey i went thorugh the link but i couldnot find download link to get the example folder which i am running with jbpm 4.3

                        I have serach all the links given on forum and i could find latest 4.3 folder already which i am already using.

                        Can you help me in this.

                        Thanks

                        • 9. Re: Unable to set the mail configuration properties in JBPM 4.3
                          Maciej Swiderski Master

                          virendra agarwal wrote:

                           

                          Ok let me try this.

                          It means we need not to call myauthenticator function it will be called directly from cfg.xml file

                          Which means our configuration is correct.

                          Yes, jBPM will take care of all the stuff required for authentication  when authenticator was configured.

                           

                          virendra agarwal wrote:

                           


                          Hey i went thorugh the link but i couldnot find download link to get the example folder which i am running with jbpm 4.3

                          I have serach all the links given on forum and i could find latest 4.3 folder already which i am already using.

                          I am not sure what you're trying to do here but I think you can use the same examples on 4.4 as you did with 4.3

                          • 10. Re: Unable to set the mail configuration properties in JBPM 4.3
                            virendra agarwal Newbie

                            Hi Maciej,

                            I tried this with jbpm4.4 but it didnot work i got the same exception while running my test case.

                            MyAuthenticator is not called in any case.

                            Can you please tell me what exactly you have applied to make it run.

                            I am really stuck with code.

                            Thanks & Regards

                            Virendra

                            • 11. Re: Unable to set the mail configuration properties in JBPM 4.3
                              Maciej Swiderski Master

                              Have you tried that with gmail account?

                               

                              Please post your jbpm configuration and your test case for it, that would make it easier for me to trace the inconsistencies.

                              • 12. Re: Unable to set the mail configuration properties in JBPM 4.3
                                virendra agarwal Newbie

                                Ok,

                                 

                                I have attached my classes with this post. Please find them and tell me what is the problem.

                                I am using libraries from the jbpm4.4 snapshot folder.

                                Please verify it and tell me the exact problem.

                                I tried it with gmail account also but it didnt work

                                Thanks

                                • 13. Re: Unable to set the mail configuration properties in JBPM 4.3
                                  Maciej Swiderski Master

                                  ok, I see the problem, you added mail configuration bit wrong, perhaps it is due to my not clear enough instruction. mail-session stuff should be enclosed within transaction-context tags. Please take a look at attached full jbpm configuration file (including your authenticator) that is based on default one that is embedded in jbpm jar.

                                  Please use this one while building your process engine and that should do the trick.

                                   

                                  HTH

                                  • 14. Re: Unable to set the mail configuration properties in JBPM 4.3
                                    virendra agarwal Newbie

                                    Hi ,

                                    i tried your config file but it did not work .

                                     

                                    <jbpm-configuration>

                                     

                                      <import resource="jbpm.default.cfg.xml" />
                                      <import resource="jbpm.businesscalendar.cfg.xml" />
                                      <import resource="jbpm.tx.hibernate.cfg.xml" />
                                      <import resource="jbpm.jpdl.cfg.xml" />
                                      <import resource="jbpm.bpmn.cfg.xml" />
                                      <import resource="jbpm.identity.cfg.xml" />

                                     

                                    <import resource="jbpm.default.scriptmanager.xml" />

                                     


                                      <transaction-context>
                                      
                                        <mail-session>
                                          <mail-server>
                                            <session-properties resource="jbpm.mail.properties" />
                                        <authenticator class="org.jbpm.examples.java.MyAuthenticator" auto-wire="true" />
                                          </mail-server>
                                        </mail-session>

                                     

                                      </transaction-context>

                                     


                                    </jbpm-configuration>

                                     

                                    PLease tell me now what i need .

                                    I can not not use your config file as it is because it gives me null pointer exception

                                    1 2 Previous Next