title: Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException / java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlException
body: <p>I am trying to save image to word but I am getting below error. I have also refereed some of the stack link and Apache blog but still didn't helped me. </p>
  
  <p>The Question is now marked as duplicate, when I have already mentioned I went through stack and apache which didn't helped me.Instead of marking it as duplicate SO should understand the problem of the question rather then just referring the title of the question.</p>
  
  <p>Now I have got negative rating great Stack. </p>
  
  <blockquote>
    <p>Caused by: java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException</p>
  </blockquote>
  
  <p>I have also added below jar</p>
  
  <blockquote>
    <p>poi-ooxml-3.9.jar, 
    xmlbeans-xpath-2.6.0.jar</p>
  </blockquote>
  
  <p>Below is the code</p>
  
  <pre><code>import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
  import org.apache.poi.xwpf.usermodel.*;
  import org.apache.poi.xwpf.usermodel.XWPFDocument;
  import org.apache.poi.xwpf.usermodel.XWPFParagraph;
  import org.apache.poi.xwpf.usermodel.XWPFRun;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  
  public class SimpleImages {
  public static void main(String[] args) throws IOException, InvalidFormatException {
      XWPFDocument docx = new XWPFDocument();
      XWPFParagraph par = docx.createParagraph();
      XWPFRun run = par.createRun();
      // run.setText("Hello, World. This is my first java generated docx-file.
      // Have fun.");
      run.setFontSize(13);
      InputStream pic = new FileInputStream("http://www.somedomain.com/wp-content/uploads/2013/03/DSC04745.jpg");
      // byte [] picbytes = IOUtils.toByteArray(pic);
      // run.addPicture(picbytes, Document.PICTURE_TYPE_JPEG);
      run.addPicture(pic, Document.PICTURE_TYPE_JPEG, "3", 0, 0);
      FileOutputStream out = new FileOutputStream("C:\\Users\\t\\Pictures\\finallyhurray.doc");
      docx.write(out);
      out.close();
      pic.close();
   }
  }
  </code></pre>