users@jaxb.java.net

compiling jaxb 1.0 with jaxb 2.0

From: edward pedersson <cpsmadness_at_googlemail.com>
Date: Tue, 22 May 2007 13:50:51 +0100

Hi

I am developing a project that needs to use jaxb 1.0 and jaxb 2.0 for
legacy reasons. I have downloaded 2.1.3 an managed to use xjc to
generate the new code (2.1) but when I try and generate the 1.0
classes I get this error

java.lang.NoClassDefFoundError: com/sun/xml/bind/JAXBAssertionError
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1225)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1185)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultEx
cutor.java:40)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1068)
        at org.apache.tools.ant.Main.runBuild(Main.java:668)
        at org.apache.tools.ant.Main.startAnt(Main.java:187)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:246)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:67)
Caused by: java.lang.NoClassDefFoundError: com/sun/xml/bind/JAXBAssertionError
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:164)
        at com.sun.tools.xjc.Options.class$(Options.java:154)
        at com.sun.tools.xjc.Options.findServices(Options.java:482)
        at com.sun.tools.xjc.Options.<clinit>(Options.java:154)
        at com.sun.tools.xjc.XJCTask.<init>(XJCTask.java:49)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method

        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruc
orAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Delegating
onstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
        at java.lang.Class.newInstance0(Class.java:350)
        at java.lang.Class.newInstance(Class.java:303)
        at com.sun.istack.tools.ProtectedTask.execute(ProtectedTask.java:49)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:341)
        at org.apache.tools.ant.Target.performTasks(Target.java:369)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216)


And this is the ant build file

<?xml version="1.0" encoding="windows-1252"?>
<project name="jaxb" default="compile" basedir=".">

<path id="classpath">
<pathelement location="activation.jar"/>
<pathelement location="jaxb-api.jar"/>
<pathelement location="jaxb-impl.jar"/>
                <pathelement location="jaxb1-impl.jar"/>
<pathelement location="jaxb-xjc.jar"/>
                <pathelement location="jsr173_1.0_api.jar"/>
</path>

<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
<classpath refid="classpath"/>
</taskdef>

        <target name="compile">
                <xjc schema="import.xsd" destdir="generated"
package=".jaxb.importxsd" source="1.0" target="1.0" />
</target>
</project>


I have checked the classpath and there is nothing untoward there and
all the jars are in the same folder as the ant file. I thought jaxb
2.1 is meant to be backwards compatible?

many thanks for your help
-- 
-- e