aspose file tools
The moose likes XML and Related Technologies and the fly likes JAXB 2 build error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB 2 build error" Watch "JAXB 2 build error" New topic

JAXB 2 build error

Graham Wagg

Joined: Apr 30, 2008
Posts: 4
Hi. I'm using JAXB 2.1.7 for the first time, and am managing to generate the required files, but I seem to get a compile error in the generated Seems to me the package annotations are in ideas? Thanks in advance.

The (generated)

@javax.xml.bind.annotation.XmlSchema(namespace = "http://yaddayadda_v_0_7", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package thepackage;

The error :

Compiling 1602 source files to rarara\services\target\classes
[javac] thepackage/ package annotations should be in file
[javac] @javax.xml.bind.annotation.XmlSchema(namespace = "http://yaddayadda_v_0_7", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
Graham Wagg

Joined: Apr 30, 2008
Posts: 4
OK, sorted it.
Or rather, got round it, using the XJC Ant Task's nested argument �-npa� to suppress the creation of the package level annotations.

So, instead of the (bizarrely) problematic :

@javax.xml.bind.annotation.XmlSchema(namespace = "namespace", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)

package thepackage;
@XmlRootElement(name = "Generated-class")

public class GeneratedClass {

Instead, we have no, and every generated class has the namespace inside as an annotation :

@XmlRootElement(name = "Generated-Class", namespace = "namespace")

public class GeneratedClass{

Cheers to anyone that looked, and hope that helps anyone.

PS. I still don't know WHY this happens, so if anyone can offer up a solution, that'd be grand.
Bob Marty

Joined: Aug 14, 2008
Posts: 1
Hi there,

I have encountered a similar problem when I compile generated classes with ant, then I tried your XJC trick by passing the -npa agrument via the wsimport -B argument.
I clarify :

The problem is that I do not see any difference in the generated code : files are still there with their annoying annotations .

My way to got round it was to use a v6 JVM, in fact I have no more annotations errors but this one :

I believe it has something to do with a difference between the embedded jax-ws version in java6 distrib (2.0 I guess) and the one I downloaded separately to use with the java5 release (2.1.3).

I have found something that could explain our common problem here, concerning the use of the javac command from jdk5.
I guess it could be a good explanation of our worries as the eclipse compiler seems to not be annoyed by the files.

Any idea of the less dirty solution to apply ?
Thanks by advance for your help, your two precedent post were yet very helpful.

I am using :
ant 1.7.0 with eclipse 3.3.2
JRE 1.5.0_12 or JRE 1.6.0_03
Windows XP SP3
[ August 14, 2008: Message edited by: Bob Marty ]
Ciprian Radu

Joined: Feb 23, 2009
Posts: 1

I just encountered the same problem. I think it is just a matter of JDK version...

With 1.5.0_16 it gives me the error.
With 1.5.0_17 it doesn't give me the error!

Also I tested with 1.6 and it works.

So use 1.5.0 update 17 or above
Don't get me started about those stupid light bulbs.
subject: JAXB 2 build error
It's not a secret anymore!