Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-15156

org.apache.camel.component.mail.MailBinding.populateMailMessage java.lang.NullPointerException:

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Bug
    • 3.2.0, 3.3.0
    • None
    • camel-mail
    • None
    • Unknown

    Description

      There is an issue with smtp endpoint, it fails with a null pointer exception when the project is run as a standalone jar file.   

      NOTE: This is not an issue when I use the mvn compile exec:java. 

      Steps to replicate:

      1. create a simple maven project with apache-camel arch (Here is bare bone code sample https://github.com/drkaleem/test_camel_mail)
      2. Use any fake smtp server running on port 25. Or run "sudo python -m smtpd -n -c DebuggingServer localhost:25" to fire up one on your local machine.
      3. THE GOOD - Run the code with "mvn compile exec:java".  This runs successfully.
      4. Generate a standalone jar with the command "mvn clean package". This will generate required jar files in target folder.
      5. THE BAD - Run the java jar file with "java -jar .\target\TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.jar". It fails with "java.lang.NullPointerException"

      Stacktrace
      ---------------------------------------------------------------------------------------------------------------------------------------
      java.lang.NullPointerException: null
      at org.apache.camel.component.mail.MailBinding.populateMailMessage(MailBinding.java:133) ~[TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.jar:
      ?]
      at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:66) ~[TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
      at org.apache.camel.processor.SendDynamicProcessor.lambda$process$0(SendDynamicProcessor.java:197) ~[TestCamelMail-1.0-SNAPSHOT-jar-with-depende
      ncies.jar:?]
      at org.apache.camel.impl.engine.DefaultProducerCache.doInAsyncProducer(DefaultProducerCache.java:309) ~[TestCamelMail-1.0-SNAPSHOT-jar-with-depe
      ndencies.jar:?]
      at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:182) ~[TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.jar
      :?]
      at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:395) [TestCamelMail-1.0-SNAPSHOT-ja
      r-with-dependencies.jar:?]
      at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148) [TestCamelMail-1.0-SNAPSHOT-jar-with-d
      ependencies.jar:?]
      at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:60) [TestCamelMail-1.0-SNAPSHOT-jar-with-depen
      dencies.jar:?]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:147) [TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:286) [TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.
      jar:?]
      at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:198) [TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.ja
      r:?]
      at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:78) [TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
      at java.util.TimerThread.mainLoop(Timer.java:555) [?:1.8.0_161]
      at java.util.TimerThread.run(Timer.java:505) [?:1.8.0_161]
      [1) thread #2 - timer://mytimer] TimerConsumer WARN Error processing exchange. Exchange[ID-DEMHAS-KA-1591558798961-0-1]. Caused by: [j
      ava.lang.NullPointerException - null]
      java.lang.NullPointerException: null
      at org.apache.camel.component.mail.MailBinding.populateMailMessage(MailBinding.java:133) ~[TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.jar:
      ?]
      at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:66) ~[TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
      at org.apache.camel.processor.SendDynamicProcessor.lambda$process$0(SendDynamicProcessor.java:197) ~[TestCamelMail-1.0-SNAPSHOT-jar-with-depende
      ncies.jar:?]
      at org.apache.camel.impl.engine.DefaultProducerCache.doInAsyncProducer(DefaultProducerCache.java:309) ~[TestCamelMail-1.0-SNAPSHOT-jar-with-depe
      ndencies.jar:?]
      at org.apache.camel.processor.SendDynamicProcessor.process(SendDynamicProcessor.java:182) ~[TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.jar
      :?]
      at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:395) ~[TestCamelMail-1.0-SNAPSHOT-j
      ar-with-dependencies.jar:?]
      at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:148) [TestCamelMail-1.0-SNAPSHOT-jar-with-d
      ependencies.jar:?]
      at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:60) [TestCamelMail-1.0-SNAPSHOT-jar-with-depen
      dencies.jar:?]
      at org.apache.camel.processor.Pipeline.process(Pipeline.java:147) [TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
      at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:286) [TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.
      jar:?]
      at org.apache.camel.component.timer.TimerConsumer.sendTimerExchange(TimerConsumer.java:198) [TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.ja
      r:?]
      at org.apache.camel.component.timer.TimerConsumer$1.run(TimerConsumer.java:78) [TestCamelMail-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
      at java.util.TimerThread.mainLoop(Timer.java:555) [?:1.8.0_161]
      at java.util.TimerThread.run(Timer.java:505) [?:1.8.0_161]

      Attachments

        1. TestCamelMail.zip
          8.21 MB
          kaleem ahmed

        Activity

          People

            Unassigned Unassigned
            drkaleem kaleem ahmed
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: