Supporting Oracle’s xmltype column using Java and Spring – Issues -Part 2

My adventure with Oracle’s XMLType and ojdc6.jar (Oracle Thin driver, Type 4, pure java implementation) continues from my previous post…..

I was advised to use ojdbc6.jar and xdb6.jar to deal with Oracle’s XMLType in tandem or be ready to run into problems. Even after using them, i ran into problems when my application’s build moved to a higher environment(QA) in SDLC.
1. The first issue which we faced is below:


Caused by: java.lang.NoClassDefFoundError: oracle/xml/parser/v2/XMLParseException
	at org.springframework.data.jdbc.support.oracle.OracleXmlTypeValue.setValue(OracleXmlTypeValue.java:106)
	at org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:270)
	at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:216)
	at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:144)

Caused by: java.lang.ClassNotFoundException: oracle.xml.parser.v2.XMLParseException
	at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:296)
	at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:269)
	at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

The reason for this is that xmlparserv2.jar was missing as part of application build. Actually, this is supposed to be loaded by Weblogic/Websphere/JBOSS as part of configuration with Oracle 11g database. As this was missing, i included Oracle 10g’s xmlparserv2.jar unknowingly and deployed the application. Come insertion into XMLType column, it failed again with another error.

Note: For an enterprise Oracle 11g edition these jars will be located under {ORACLE_HOME}/oracle/produce/{VERSION_NUMBER}/lib/xmlparserrv2.jar (and a whole lot of other jars too)

2. The second error which we will face is below:


java.lang.NoClassDefFoundError: oracle/xml/binxml/BinXMLMetadataProvider
	at org.springframework.data.jdbc.support.oracle.OracleXmlTypeValue.setValue(OracleXmlTypeValue.java:106)
	at org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:270)
	at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:216)
	at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:144)
	at org.springframework.jdbc.core.BatchUpdateUtils.setStatementParameters(BatchUpdateUtils.java:63)
............
Caused by: java.lang.ClassNotFoundException: oracle.xml.binxml.BinXMLMetadataProvider
	at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:296)
	at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:269)
	at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56)

The reason for this is that Oracle has updated xmlparserv2.jar for Oracle 11g. But, how a developer is supposed to know it? There is neither any documentation for this nor a naming convention for the jar in question.When you compare the jar sizes, you will realize that the xmlparserv2.jar which comes with Oracle 11g is about 1350 KB compared to the old jar of size, 1183 KB. And, they have included a new package oracle.xml.binxml to deal with binary XML.

There are a whole set of jars which also have been modifed in Oracle 11g. i.e.,classgen.jar, xsqlserializers.jar, xschema.jar, xmlmesg.jar, ojcr.jar, etc

Courtesy: Sandeep Molath(simplyblogmadi.blogpost.com) for giving me the basic understanding to get started on this issue.

Advertisements

4 thoughts on “Supporting Oracle’s xmltype column using Java and Spring – Issues -Part 2

  1. Is there any location on the web to download the required JAR? I couldn’t find a JAR which containsoracle/xml/binxml/BinXMLMetadataProvider. My xmlparserv2.jar does not contain this binxml package.

    • It is difficult to find the jar anywhere in the web. The xmlparserv2.jar is a proprietary jar of Oracle. If you are using Oracle as your database, you can find the jar @ {ORACLE_HOME}/oracle/product/{VERSION_NUMBER}/lib/. You might try registering in the Oracle developer web-site and give it a try.

  2. That xmlparserv2.jar is very hard to find. It’s not part of my 11g R2 XE installation. I found it in a JDveloper download (http://www.oracle.com/technetwork/developer-tools/jdev/downloads/index.html). Downloaded the Generic Release Java Edition: 11.1.2.2.0 and found it at jdeveloper/modules/oracle.xdk_11.1.0/xmlparserv2.jar once I unzipped the download. This one works with the latest 11.2.0.3 ojdbc6.jar and xdb6.jar downloads.

    BTW, working on the final release of the Spring Data JDBC Extensions project. Currently at RC3 and expect to have 1.0.0.RELEASE out in a couple of weeks.

    -Thomas

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s