users@jaxb.java.net

Re: JAXB 2.1.8 XJCTask issue with source="1.0"

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Mon, 15 Sep 2008 19:41:07 +0200

Yes, I can reproduce this. It's clear that the source="1.0" is the bogey
man.

Here I quote from some man page for xjc:
<quote>
Summary of Deprecated and Removed Command Line Options
 ...
 -source
       The -source compatibility switch was introduced in the first
       JAXB 2.0 Early Access release. We have decided to remove this
       switch from future releases of JAXB 2.0. If you need to gener-
       ate 1.0.x code, please use an installation of the 1.0.x code-
       base.
 ...
</quote>

Running xjc from 1.6.0_03 doesn't even accept the -source option. It's
strange that the JAXB distributions contain code that accept the option
and then run into some error, depending on the Java version.

Back to your essential problem: Is there a chance that you can compile
without
that "-source" option? What's keeping you from fully migrating to JAXB 2.0?

Wolfgang

On Fri, Sep 12, 2008 at 9:29 PM, Philip A. Culver <
pculver_at_bostonatlantic.net> wrote:

> That's works fine for simple experiments. However jdk 1.6.0_03 came with
> a flavor of JAXB 2.0.x. The problem arises when using JAXB 1.6.0_07 and
> the source="1.0" attribute. Even when using all the proper class paths etc.
> the XJCTask executed by ant seems to be the 2.1.3 one bundled with the JDK
> not the XJCTask that is in the classpath from 2.1.8.
>
>
>
> A simple test is to upgrade to jdk 1.6.0_07 and modify the
> unmarshal-validate example build.xml xjc compile to contain the source="1.0"
> attribute and rename the destdir attribute to target. You will see the
> exception immediately when you try to compile. This will not happen if
> using jdk 1.5.0 as there is no bundled XJCTask in the jdk.
>
>
>
> Phil
>
>
> ------------------------------
>
> *From:* Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
> *Sent:* Friday, September 12, 2008 1:33 PM
>
> *To:* users_at_jaxb.dev.java.net
> *Subject:* Re: JAXB 2.1.8 XJCTask issue with source="1.0"
>
>
>
> This is how I use 2.1.7 with jdk1.6.0 with ant to run xjc
> for simple experiments. It also works with 2.1.8.
> My current Java is jdk1.6.0_03.
>
> Let's say that JAXB_HOME is /extra/jaxb-ri-2.1.8
> Create a directory $JAXB_HOME/samples/foo, copy your
> schema file into it and create a build.xml according
> to the one in some sibling directory (unmarshal-validate
> contains a simple one).
>
> Calling ant should compile the schema.
>
> Notice that for running your application after compiling
> everything you will have to call java like this:
>
> java -Djava.endorsed.dirs=/extra/jaxb-ri-2.1.8/lib ...
>
> If this works for you, then you should be able to set
> things up at some other place as well.
>
> -W
>
>
> On Fri, Sep 12, 2008 at 6:09 PM, Philip A. Culver <
> pculver_at_bostonatlantic.net> wrote:
>
> Yes it is. Some additional information I have found: The code compiles
> and generated correctly with Java 1.5 and Jaxb 2.1.8 with source="1.0". I
> think the problem is Java 1.6. I am using JDK 1.6.0_07 which comes with
> Jaxb 2.1.3 albeit with class packages renamed. Was the XJCTask class
> package renamed in that JDK? I am guessing not because I saw a mail message
> in the archive from Kohsuke that the problem I am experiencing was a bug in
> 2.1.3. Is there any way to force the JDK to use the XJCTask instance
> from the classpath and not the JDK itself?
>
>
>
> Thanks,
> Phil
>
>
> ------------------------------
>
> *From:* Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
> *Sent:* Friday, September 12, 2008 4:16 AM
> *To:* users_at_jaxb.dev.java.net
> *Subject:* Re: JAXB 2.1.8 XJCTask issue with source="1.0"
>
>
>
> Is the jaxb1-impl.jar that comes with JAXB 2.x in your classpath?
> -W
>
> On Fri, Sep 12, 2008 at 3:10 AM, Philip A. Culver <
> pculver_at_bostonatlantic.net> wrote:
>
> Hello,
>
>
>
> I am attempting to migrate to JAXB 2.1.8 from JAXB 1.0. I initially need
> to compile and run the code using the 1.0 source/target attributes of
> jaxb. However I can not compile my schema in this manner. I get the error
> at the bottom of this email while using JDK 1.6.0_07 and jaxb 2.1.8:
>
>
>
> I thought this might be a problem in my code so I modified the build.xml
> for the sample project: datatypeconverter so that the xjc execution had the
> attributes source="1.0" and target="1.0" and received the same error as
> earlier. I don't know if I am doing something run. Some web searches seem
> to indicate this was a bug in 2.1.3 but was supposedly fixed. FYI: My
> schema compiles correctly in jaxb 2.0.5 with the source="1.0" attribute.
>
>
>
> java.lang.NoClassDefFoundError: com/sun/xml/bind/JAXBAssertionError
>
> at java.lang.Class.forName0(Native Method)
>
> at java.lang.Class.forName(Class.java:169)
>
> 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(NativeConstructorAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>
> at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>
> at java.lang.Class.newInstance0(Class.java:355)
>
> at java.lang.Class.newInstance(Class.java:308)
>
> at
> com.sun.istack.tools.ProtectedTask.execute(ProtectedTask.java:49)
>
> at
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
>
> at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:597)
>
> at
> org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
>
> at org.apache.tools.ant.Task.perform(Task.java:348)
>
> at org.apache.tools.ant.Target.execute(Target.java:357)
>
> at org.apache.tools.ant.Target.performTasks(Target.java:385)
>
> at
> org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
>
> at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
>
> at
> org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
>
> at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
>
> at org.apache.tools.ant.Main.runBuild(Main.java:758)
>
> at org.apache.tools.ant.Main.startAnt(Main.java:217)
>
> at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
>
> at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
>
> Caused by: java.lang.ClassNotFoundException:
> com.sun.xml.bind.JAXBAssertionError
>
> at
> com.sun.istack.tools.ParallelWorldClassLoader.findClass(ParallelWorldClassLoader.java:71)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>
> at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
>
>
>
>
>
> Thanks,
>
> Phil
>
>
>
>
>
>
>