AttachmentTest failure
rebody Apr 22, 2010 1:34 AMHi Alejandro,
I had updated current trunk. The org.jbpm.test.activity.mail.AttachmentTest failed. The test case reported as below:
### EXCEPTION ########################################### 13:20:12,799 INF | [DefaultCommandService] exception while executing command org.jbpm.pvm.internal.cmd.StartProcessInstanceInLatestCmd@1613b53 org.jbpm.api.JbpmException: could not send email: javax.mail.internet.MimeMessage@1aa0a15 at org.jbpm.pvm.internal.email.impl.MailSessionImpl.send(MailSessionImpl.java:60) at org.jbpm.jpdl.internal.activity.MailActivity.perform(MailActivity.java:46) 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:657) at org.jbpm.pvm.internal.model.ExecutionImpl.performAtomicOperation(ExecutionImpl.java:617) at org.jbpm.pvm.internal.model.ExecutionImpl.start(ExecutionImpl.java:218) 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.test.activity.mail.AttachmentTest.testVariableAttachment(AttachmentTest.java:84) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:164) at org.jbpm.test.BaseJbpmTestCase.runTest(BaseJbpmTestCase.java:87) 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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127) at org.apache.maven.surefire.Surefire.run(Surefire.java:177) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345) at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009) Caused by: javax.mail.MessagingException: IOException while sending message; nested exception is: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type image/gif at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:676) at org.jbpm.pvm.internal.email.impl.MailSessionImpl.send(MailSessionImpl.java:51) ... 43 more Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type image/gif at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:896) at javax.activation.DataHandler.writeTo(DataHandler.java:317) at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1403) at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:874) at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:444) at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:102) at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:894) at javax.activation.DataHandler.writeTo(DataHandler.java:317) at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1403) at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1745) at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:636) ... 44 more
The activation cannot find DataContentHandler(DCH) for Mime-Type image/gif. jBPM 4 are using activition-1.1.jar to provider javamail attach. When I change it to activation-1.1.1.jar, the attachmenttest could pass successfully.
I digg deeper and find out that activition-1.1.1.jar decide the dataContent's type, when the class of data content is byte[], it will write it to the content directly.
I saw there is a mailcap file in the mail-1.4.1.jar at META/mailcap. Here is the content.
# # @(#)mailcap 1.8 05/04/20 # # Default mailcap file for the JavaMail System. # # JavaMail content-handlers: # text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain text/html;; x-java-content-handler=com.sun.mail.handlers.text_html text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed; x-java-fallback-entry=true message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822 # # can't support image types because java.awt.Toolkit doesn't work on servers # #image/gif;; x-java-content-handler=com.sun.mail.handlers.image_gif #image/jpeg;; x-java-content-handler=com.sun.mail.handlers.image_jpeg
As we can see, the image/gif and image/jpeg parts have been commented, so they won't be effect.
At the last, how could we solve this exception? Could we update activation-1.1.jar to activation-1.1.1.jar? Or we should do some other things to prevent the exception?
Any reply will be appreciate. Thank you.