title: Java: Returning XMLType Data from StoredProcedure, Usage of ojdbc6.jar xdb6.jar xmlparserv2.jar for Java to PLSQL interaction
body: <p>I am following  the below tutorial to retrieve XMLType data from a stored procedure</p>
  
  <p><a href="http://docs.oracle.com/cd/B19306_01/appdev.102/b14259/xdb11jav.htm#g1039140" rel="nofollow noreferrer">http://docs.oracle.com/cd/B19306_01/appdev.102/b14259/xdb11jav.htm#g1039140</a>
  <em>Example 13-4 XMLType Java: Returning XMLType Data</em></p>
  
  <p>When I run the code, I get this <strong>error</strong>,</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: oracle/xml/parser/v2/XMLParseException
      at oracle.xdb.XMLTypeFactory.create(XMLTypeFactory.java:67)
      at oracle.sql.OPAQUE.toClass(OPAQUE.java:328)
      at oracle.sql.OPAQUE.toJdbc(OPAQUE.java:278)
      at oracle.sql.OPAQUE.toJdbc(OPAQUE.java:259)
      at oracle.jdbc.driver.NamedTypeAccessor.getObject(NamedTypeAccessor.java:190)
      at oracle.jdbc.driver.NamedTypeAccessor.getObject(NamedTypeAccessor.java:117)
      at oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:1579)
      at oracle.jdbc.driver.OracleCallableStatementWrapper.getObject(OracleCallableStatementWrapper.java:815)
      at com.example.TestXMLDAO.main(TestXMLDAO.java:48)
  Caused by: java.lang.ClassNotFoundException: oracle.xml.parser.v2.XMLParseException
      at java.net.URLClassLoader$1.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
      at java.lang.ClassLoader.loadClass(Unknown Source)
      ... 9 more
  </code></pre>
  
  <p><strong>Java code snippet:</strong></p>
  
  <pre><code>import java.io.IOException;
  import java.sql.CallableStatement;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  
  import oracle.jdbc.OracleTypes;
  import oracle.xdb.XMLType;
  </code></pre>
  
  <p>.............</p>
  
  <pre><code>            // Prepare to call the stored procedure get_group_details.
  
              String sql = "{call mypackage.get_records(?,?,?,?,?,?,?,?)}";
  
              callableStatement = conn.prepareCall(sql);
  
              callableStatement.setString(1, "");
              callableStatement.setString(2, "");
              callableStatement.setString(3, "");
              callableStatement.setString(4, "");
              callableStatement.setString(5, "abb%");
              callableStatement.setString(6, "F");
              callableStatement.setString(7, "F");
              callableStatement.registerOutParameter(8, OracleTypes.OPAQUE,
                      "SYS.XMLTYPE");
  
              // execute get_group_details
              // callableStatement.executeQuery();
  
              callableStatement.executeQuery();
  
              callableStatement.getObject(8);
  
              // get cursor and cast it to ResultSet
              xml = (XMLType) callableStatement.getObject(8);
  
              System.out.println(xml.getStringVal());
  
          } catch (Exception ex) {
              ex.printStackTrace();
          } finally {
              // Close the statement
              callableStatement.close();
              // Close the connection
              conn.close();
          }
  </code></pre>
  
  <p><strong>PLSQL Procedure snippet</strong></p>
  
  <pre><code>PROCEDURE get_records
     (
        grp1     IN a.name%TYPE DEFAULT NULL
       ,grp2 IN a.name%TYPE DEFAULT NULL
       ,grp3        IN a.name%TYPE DEFAULT NULL
       ,grp4          IN a.name%TYPE DEFAULT NULL
       ,grp5               IN a.name%TYPE DEFAULT NULL
       ,flag1     IN a.flag%TYPE DEFAULT 'F'
       ,flag2       IN a.flag%TYPE DEFAULT 'F'
       ,xml_type_out        OUT xmltype
     );
  </code></pre>
  
  <p>Jars included: ojdbc6.jar, xdb.jar</p>
  
  <p>Any idea what I am missing?</p>
  
  <p>This issue is resolved. But when deployed in JBoss server, another issue - please refer here if you have any ideas - <a href="https://stackoverflow.com/questions/26370270/xmlparserv2-error-while-application-deployed-in-jboss">Xmlparserv2 error while application deployed in jboss, Installing Oracle ojdbc module in JBoss for Java web application</a></p>