NullPointerException when using EmailRouter in SOA-P 5.3
Environment
- Red Hat JBoss SOA Platform
- 5.3.1
Issue
We often get the following stack trace which leads to messages going to the DLQ. It looks to be caused by a null email address, however if you look at the first line of the log, there are 'from' and 'to' fields set in the message properties, so I don't know why that would be the case. The error also appears to happen sporadically and is exacerbated under high load - although I've never seen a NPE due to high load before.
ERROR [org.jboss.resource.adapter.jms.inflow.JmsServerSession] Unexpected error delivering message ObjectMessage={ JMSCorrelationID:1a7d743a,JMSDeliveryMode:2,JMSDestination:Queue 'queue/email-queue',JMSExpiration:0,JMSMessageID:ID:130,JMSPriority:0,JMSRedelivered,JMSTimestamp:1415890730845,JMSProperties:{sendTo:support@redhat.com,subject:Test Mail from JBossESB],from:foo@bar.com},Payload:{Binary Attachment:len=3747} }
java.lang.NullPointerException
at javax.mail.internet.InternetAddress.parse(InternetAddress.java:615)
at javax.mail.internet.InternetAddress.parse(InternetAddress.java:575)
at javax.mail.internet.InternetAddress.<init>(InternetAddress.java:107)
at org.jboss.soa.esb.helpers.Email.addMessageAddressing(Email.java:401)
at org.jboss.soa.esb.helpers.Email.createMailMessage(Email.java:386)
at org.jboss.soa.esb.helpers.Email.getMailMessage(Email.java:239)
at org.jboss.soa.esb.helpers.Email.sendMessage(Email.java:229)
at org.jboss.soa.esb.actions.routing.email.Emailer.sendEmail(Emailer.java:184)
at org.jboss.soa.esb.actions.routing.email.Emailer.sendEmail(Emailer.java:141)
at org.jboss.soa.esb.actions.routing.email.EmailRouter.route(EmailRouter.java:78)
at org.jboss.soa.esb.actions.routing.AbstractRouter.process(AbstractRouter.java:80)
at org.jboss.soa.esb.actions.routing.email.EmailRouter.process(EmailRouter.java:70)
at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:667)
at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:614)
at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:442)
at org.jboss.soa.esb.listeners.jca.JcaMessageAwareListener.process(JcaMessageAwareListener.java:163)
at org.jboss.soa.esb.listeners.jca.JcaJMSInflowMessageProcessorAdapter.onMessage(JcaJMSInflowMessageProcessorAdapter.java:44)
at sun.reflect.GeneratedMethodAccessor728.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.soa.esb.listeners.jca.BaseJcaInflow$1.invoke(BaseJcaInflow.java:210)
at org.jboss.soa.esb.listeners.jca.EndpointProxy.delivery(EndpointProxy.java:271)
at org.jboss.soa.esb.listeners.jca.EndpointProxy.invoke(EndpointProxy.java:163)
at $Proxy631.onMessage(Unknown Source)
at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:179)
Resolution
If the EmailRouter action is used in a dynamic fashion - fields such as from, to, etc. are populated on a per message basis - it is required to limit the thread count on the service to 1 to avoid multi-threading issues.
Root Cause
The EmailRouter action is thread safe only if used in a static context, when all fields of the email are defined in jboss-esb.xml at design time. A bugzilla1 has been created to ensure thread safety when used in a dynamic fashion, to be implemented in a future SOA-P version.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
