File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create Attachment with SAAJ is problem

 
chinna sankar
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working for making Attachment with SOAP (we are making a SOAP Messages with Attachment and then sent via socket It�s not any web service). It�s very simple application

The below jar files are in my class path
saaj-ri.jar, saaj-api.jar, dom4j.jar,activation.jar,mail.jar,comman-logging.jar

My code is:
MessageFactory mf = MessageFactory.newInstance();
System.out.println(mf);
SOAPMessage _msg = mf.createMessage();
SOAPPart spart = _msg.getSOAPPart();
SOAPEnvelope senv = spart.getEnvelope();
SOAPBody soapbody = senv.getBody();
SOAPHeader sheaser = senv.getHeader();
_msg.writeTo(System.out);
FileDataSource fdsource = new FileDataSource(new File("C:/n.xml"));
DataHandler dhandler = new DataHandler(fdsource);
AttachmentPart apart = _msg.createAttachmentPart(dhandler);
_msg.addAttachmentPart(apart);
_msg.saveChanges();
_msg.writeTo(System.out);


I got below error


java.lang.NoClassDefFoundError at com.sun.xml.messaging.saaj.soap.MessageImpl.createAttachmentPart(MessageImpl.java:305)
at javax.xml.soap.SOAPMessage.createAttachmentPart(Unknown Source)
 
Peer Reynders
Bartender
Posts: 2934
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may be experiencing a mailcap issue � though I can't be certain.
When trying to find a DataContentHandler (DCH) JAF 1.0.2 checks for mailcap files in the following order
  • user.home/mailcap
  • java.home/lib/mailcap
  • META-INF/mailcap
  • META-INF/mailcap.default


  • Issues:
  • Some SAAJ implementations provide their own mailcap file. In that case it is necessary to make sure that the mail.jar (with its META-INF/mailcap file) occurs after the SAAJ implementation jar (which may have it's own META-INF/mailcap) in the class path. So move that mail.jar to the end of the classpath.
  • The user.home/mailcap or java.home/lib/mailcap may specify a DataContentHandler that is incompatible with the SAAJ-implementation and/or that is provided in a JAR not currently in your class path.


  • [ April 21, 2006: Message edited by: Peer Reynders ]
     
    chinna sankar
    Greenhorn
    Posts: 22
    • 0
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Peer Reynders ,

    Thank you, It's really Good information for me.

    I done accrodingly, I changed the order of Loading Jar files, Finally i suceeded to run my application with out any errors.

    Thanks again Peer Reynders.
     
    I agree. Here's the link: http://aspose.com/file-tools
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic