users@saaj.java.net

Store a SOAPMessage with AttachmentParts (SAAJ) into a database as a BLOB.

From: Marc Beckers <m.beckers_at_competent.nl>
Date: Fri, 17 Nov 2006 17:14:36 +0100

 
Hello,

I have to store a SOAPMessage with two AttachmentParts (SAAJ) into a
database (MySQL) as one BLOB, but I get an IOException:


java.io.IOException: Unable to run the JPEG Encoder on a stream


Here is my code:


            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            // dto.getInhoud() returns a javax.xml.soap.SOAPMessage with two

            // javax.xml.soap.AttachmentPart's (jpg images)

            dto.getInhoud().writeTo(baos); // here I get the IOException

            byte[] buffer = baos.toByteArray();

            ByteArrayInputStream bais = new ByteArrayInputStream(buffer);

            ps.setBinaryStream(10, bais, buffer.length);


Here is the output:

31-okt-2006 12:06:59 com.sun.xml.messaging.saaj.soap.MessageImpl saveChanges

SEVERE: SAAJ0540: Error during saving a multipart message

31-okt-2006 12:06:59 wo.wow.WOWController doPost

SEVERE: Er is een exceptie opgetreden in WOWController.doPost().

com.sun.xml.messaging.saaj.SOAPExceptionImpl: Error during saving a
multipart message

        at
com.sun.xml.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:110
4)

        at
com.sun.xml.messaging.saaj.soap.MessageImpl.writeTo(MessageImpl.java:1196)

        at wo.dao.BerichtDAO.create(BerichtDAO.java:67)

        at wo.wow.BerichtBeheerder.opslaan(BerichtBeheerder.java:169)

        at
wo.wow.dossier.BetalingsverzoekDoe.execute(BetalingsverzoekDoe.java:51)

        at wo.wow.WOWController.doPost(WOWController.java:222)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:237)

        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:157)

        at
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter
.java:362)

        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:186)

        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:157)

        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:214)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)

        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

        at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext
Valve.java:198)

        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:152)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)

        at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:462)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)

        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137
)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)

        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117
)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)

        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)

        at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:535)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)

        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)

        at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)

        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:790)

        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:709)

        at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:572)

        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:644)

        at java.lang.Thread.run(Thread.java:595)

Caused by: java.io.IOException: Unable to run the JPEG Encoder on a stream
[B

        at
com.sun.xml.messaging.saaj.soap.JpegDataContentHandler.writeTo(JpegDataConte
ntHandler.java:149)

        at javax.activation.ObjectDataContentHandler.writeTo(Unknown Source)

        at javax.activation.DataHandler.writeTo(Unknown Source)

        at
com.sun.xml.messaging.saaj.packaging.mime.internet.MimeBodyPart.writeTo(Mime
BodyPart.java:880)

        at
com.sun.xml.messaging.saaj.packaging.mime.internet.MimeMultipart.writeTo(Mim
eMultipart.java:245)

        at
com.sun.xml.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:109
2)

        ... 38 more

 

CAUSE:

 

java.io.IOException: Unable to run the JPEG Encoder on a stream [B

        at
com.sun.xml.messaging.saaj.soap.JpegDataContentHandler.writeTo(JpegDataConte
ntHandler.java:149)

        at javax.activation.ObjectDataContentHandler.writeTo(Unknown Source)

        at javax.activation.DataHandler.writeTo(Unknown Source)

        at
com.sun.xml.messaging.saaj.packaging.mime.internet.MimeBodyPart.writeTo(Mime
BodyPart.java:880)

        at
com.sun.xml.messaging.saaj.packaging.mime.internet.MimeMultipart.writeTo(Mim
eMultipart.java:245)

        at
com.sun.xml.messaging.saaj.soap.MessageImpl.saveChanges(MessageImpl.java:109
2)

        at
com.sun.xml.messaging.saaj.soap.MessageImpl.writeTo(MessageImpl.java:1196)

        at wo.dao.BerichtDAO.create(BerichtDAO.java:67)

        at wo.wow.BerichtBeheerder.opslaan(BerichtBeheerder.java:169)

        at
wo.wow.dossier.BetalingsverzoekDoe.execute(BetalingsverzoekDoe.java:51)

        at wo.wow.WOWController.doPost(WOWController.java:222)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)

        at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:237)

        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:157)

        at
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter
.java:362)

        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:186)

        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:157)

        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:214)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)

        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

        at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext
Valve.java:198)

        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:152)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)

        at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase
.java:462)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)

        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137
)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)

        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117
)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)

        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:109)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:104)

        at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:535)

        at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex
t.java:102)

        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

        at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)

        at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)

        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:790)

        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:709)

        at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:572)

        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:644)

        at java.lang.Thread.run(Thread.java:595)


Who can help me?

with kind regards,

Marc Beckers

P.S. When the SOAPMessage has no AttachmentParts it works fine.