title: Exception in thread "main" java.lang.reflect.InvocationTargetException
body: <p>I am using iText PDF 5.5.11 to convert PDF to XML.I already checked similar answers on stackoverflow. I am getting below error when I run jar file using command line on ubuntu. java version "1.8.0_101"</p>
  
  <pre><code> Exception in thread "main" java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
  Caused by: java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1Encodable
      at com.itextpdf.text.pdf.PdfEncryption.&lt;init&gt;(PdfEncryption.java:147)
      at com.itextpdf.text.pdf.PdfReader.readDecryptedDocObj(PdfReader.java:1063)
      at com.itextpdf.text.pdf.PdfReader.readDocObj(PdfReader.java:1469)
      at com.itextpdf.text.pdf.PdfReader.readPdf(PdfReader.java:751)
      at com.itextpdf.text.pdf.PdfReader.&lt;init&gt;(PdfReader.java:198)
      at com.itextpdf.text.pdf.PdfReader.&lt;init&gt;(PdfReader.java:236)
      at com.itextpdf.text.pdf.PdfReader.&lt;init&gt;(PdfReader.java:224)
      at com.itextpdf.text.pdf.PdfReader.&lt;init&gt;(PdfReader.java:214)
      at test.pdfreader.readXml(pdfreader.java:34)
      at test.pdfreader.main(pdfreader.java:30)
  </code></pre>
  
  <p>I am not much familiar with java. I call this jar file from PHP using PHP exec function.
  Below is the code I use to convert PDF to XML.</p>
  
  <pre><code>import com.itextpdf.text.DocumentException;
  import com.itextpdf.text.pdf.AcroFields;
  import com.itextpdf.text.pdf.PdfReader;
  import com.itextpdf.text.pdf.XfaForm;
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import javax.xml.transform.Transformer;
  import javax.xml.transform.TransformerException;
  import javax.xml.transform.TransformerFactory;
  import javax.xml.transform.dom.DOMSource;
  import javax.xml.transform.stream.StreamResult;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  
  public class pdfreader {
      public static void main(String[] args) throws IOException, DocumentException, TransformerException {
          String SRC = "";
          String DEST = "";
  
          for (String s : args) {
              SRC = args[0];
              DEST = args[1];
          }
          File file = new File(DEST);
          file.getParentFile().mkdirs();
          new pdfreader().readXml(SRC, DEST);
      }
  
      public void readXml(String src, String dest) throws IOException, DocumentException, TransformerException {
          PdfReader reader = new PdfReader(src);
  
          AcroFields form = reader.getAcroFields();
          XfaForm xfa = form.getXfa();
          Node node = xfa.getDatasetsNode();
          NodeList list = node.getChildNodes();
          for (int i = 0; i &lt; list.getLength(); ++i) {
              if ("data".equals(list.item(i).getLocalName())) {
                  node = list.item(i);
  
                  break;
              }
          }
          list = node.getChildNodes();
  
          Transformer tf = TransformerFactory.newInstance().newTransformer();
          tf.setOutputProperty("encoding", "UTF-8");
          tf.setOutputProperty("indent", "yes");
          FileOutputStream os = new FileOutputStream(dest);
  
          tf.transform(new DOMSource(node), new StreamResult(os));
          reader.close();
      }
  }
  </code></pre>