2 Replies Latest reply on Dec 17, 2004 10:28 AM by p_nevilleuk

    jboss-saaj attachmentpart problem

    p_nevilleuk

      Hi,
      I'm using jboss 4.0.0. and am having problems with attachments when using saaj. The only success I have is if I attach using MIME type text/plain and set content to a String.
      If I try to set MIME type to application/xml or text/xml and set content to be JDOMSource then I get IllegalArgument exception:



      If I try to set MIME type to application/xml or text/xml and set content to javax.xml.transform.stream.StreamSource then I get null pointer exception :

      13:40:03,032 ERROR [EBXMLTransportActivatorBean] java.lang.NullPointerException
      13:40:03,032 INFO [STDOUT] java.lang.NullPointerException
      13:40:03,042 INFO [STDOUT] at org.apache.axis.attachments.ManagedMemoryData
      Source.<init>(ManagedMemoryDataSource.java:202)
      13:40:03,042 INFO [STDOUT] at org.apache.axis.attachments.AttachmentPartImp
      l.setContent(AttachmentPartImpl.java:491)

      13:47:57,683 ERROR [EBXMLTransportActivatorBean] java.lang.IllegalArgumentExcep
      ion: Cannot content type 'text/xml' for: org.jdom.transform.JDOMSource@2fe64a
      13:47:57,723 INFO [STDOUT] java.lang.IllegalArgumentException: Cannot content
      ype 'text/xml' for: org.jdom.transform.JDOMSource@2fe64a
      13:47:57,763 INFO [STDOUT] at org.apache.axis.attachments.AttachmentPartIm
      l.setContent(AttachmentPartImpl.java:486)



      I would gratefully appreciate it if someone has some experience to offer on adding a StreamSource as an attachment with jboss-saaj.

      Thanks.


        • 1. Re: jboss-saaj attachmentpart problem
          p_nevilleuk

          Does this relate to
          https://sourceforge.net/tracker/?func=detail&atid=376685&aid=1039881&group_id=22866?

          If so, is when will able stable version of 4.0.1 be available?

          Thanks

          • 2. Re: jboss-saaj attachmentpart problem
            p_nevilleuk

            Okay, I have a solution. I was using:

            AttachmentPart attachmentPart = message.createAttachmentPart();
            attachmentPart.setContentId("<payload-1>");
            attachmentPart.setMimeHeader("Content-Type", "text/xml");
            attachmentPart.setContent(new JDOMSource(document), "text/xml");
            message.addAttachmentPart(attachmentPart);


            Now I am successfully using:
            org.jdom.Document document = new Document();
            document.setRootElement(new org.jdom.Element("PayloadTest"));
            javax.activation.DataHandler handler = new javax.activation.DataHandler(new JDOMSource(document), "text/xml");
            AttachmentPart attachmentPart = message.createAttachmentPart(handler);
            attachmentPart.setContentId("<payload-1>");
            attachmentPart.setMimeHeader("Content-Type", "text/xml");
            


            I guess it must be the DataHandlers in use by Axis?
            If anyone has an explanation, I would like to know!