This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

JAXB 2 build error

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 package-info.java. Seems to me the package annotations are in package-info.java...any ideas? Thanks in advance.

The (generated) package-info.java:

@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-info.java:8: package annotations should be in file package-info.java
[javac] @javax.xml.bind.annotation.XmlSchema(namespace = "http://yaddayadda_v_0_7", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
 
Graham Wagg
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 package-info.java :

Package-info.java

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

package thepackage;



GeneratedClass.java
@XmlRootElement(name = "Generated-class")

public class GeneratedClass {


Instead, we have no package-info.java, and every generated class has the namespace inside as an annotation :

GeneratedClass.java

@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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 : package-info.java 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 package-info.java 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 ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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.
reply
    Bookmark Topic Watch Topic
  • New Topic