views:

29

answers:

2

Hi, one of our classes use the bundled jaxb api of jdk 1.6. When I try to compile this using maven (JAVA_HOME is set to JDK 1.6 and it shows in the IDE that maven runs using JDK 1.6) I get a class not found error for the jaxb library. the class in question is present in rt.jar under JDK 1.6 lib folder. Any ideas???

A: 

Try adding this plugin to your pom.xml Maven build section:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>

Update: That doesn't work.

Have you tried this?

<dependency>
    <groupid>javax.xml.bind</groupid>
    <artifactid>jaxb-api</artifactid>
    <version>2.1</version>
    <scope>system</scope>
    <systemPath>${java.home}/lib/rt.jar</systemPath>
</dependency>
SourceRebels
Nope... this doesnt work....
Manoj
Try my second solution. Im sorry but I'm not able to reproduce your problem at this moment :-)
SourceRebels
Hi SourceRebels, Thanks for the post. As specified in my answer, Using the internal class (com.sun.xml.internal.bind.marshaller.NamespacePrefixMapper) is not a good practice and thus rather than making it work as is, I removed the dependency on the internal jaxb implementation and changed my code to import from jaxb ri. This solved my problem.
Manoj
A: 

Well... the error was due to the usage of one of the sun's internal class which was not available during maven compile. Its an interesting scenario though...

My project uses NamespaceMapper provided by sun's internal JAXB libraries. It compiled in a non mavenized eclipse environment(with a warning) since the rt.jar was there in the classpath. We started to mavenize this project and all of a sudden I got a ClassNotFound for this. After some googling I came across these two posts which got me going in the right direction.

http://forums.java.net/jive/thread.jspa?threadID=24225

http://www-01.ibm.com/support/docview.wss?rs=180&amp;uid=swg1PK88316

BottomLine : Do not use internal libraries (the package names have internal in them).

Manoj