JAXB 2.x inside OC4J

Introduction

As seen in previous post a combination of XSL-transformation and data binding isolated in a mapping layer gives decoupling of message producer and message consumer.
The pom.xml dependencies are seen below, using Apache Xalan for XSLT and Sun’s JAXB implementation.

<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2</version>
</dependency>

Problem

When deploying a mapping layer implementation using JAXB 2.x inside OC4J 10.1.3.x the error might be:
javax.xml.bind.JAXBException: Unable to locate jaxb.properties for package {0}
The reason for this is that the OC4J container comes with JAXB 1.0 runtime support. This is found in the shared
library named oracle.xml, and the javax.xml.bind.JAXBContext will be loaded from ORACLE_HOME/lib/xml.jar.
To get around this a separate shared library need to be defined, containing the jaxb-2.x libraries.

Shared library

Open the Application Server Control (ASC), and navigate to the oc4j-instance->Administration. Create a new shared library and give it a name and a version. Then pick the libraries you need. Note that there are some transitive dependencies for the jaxb-impl-2.2.jar from Sun. You need both activation-1.1.jar, jaxb-api-2.2.jar and stax-api-1.0-2.jar.

The next thing is to make sure your application actually loads and uses this shared library. To do this, edit orion-application.xml to import the shared library.

References

http://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.2/jaxb-impl-2.2.jar
http://repo2.maven.org/maven2/javax/activation/activation/1.1/activation-1.1.jar
http://repo2.maven.org/maven2/javax/xml/bind/jaxb-api/2.2/jaxb-api-2.2.jar
http://repo2.maven.org/maven2/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar

  • Trackback are closed
  • Comments (1)
    • Cristina Tilivea
    • July 18th, 2010

    Thanks so much, it helped me a lot.

Comment are closed.