This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 179956 - JAXB generates code that does not compile in IDE without tweaking from existing projects
Summary: JAXB generates code that does not compile in IDE without tweaking from existi...
Status: RESOLVED DUPLICATE of bug 175436
Alias: None
Product: xml
Classification: Unclassified
Component: JAXB (show other bugs)
Version: 6.x
Hardware: PC Linux
: P1 normal (vote)
Assignee: _ gmpatil
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-28 06:36 UTC by wobster
Modified: 2010-02-08 10:30 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wobster 2010-01-28 06:36:18 UTC
I have a number of existing projects that have leveraged the JAXB generation capability in NetBeans. When I upgraded to 6.8 I noticed that the JAXB generated code will not compile since NetBeans apparently is using an internal version of JAXB (2.2) compared to the compiler that must default to using the version that is in the JDK. The compile error is related to a new "required" attribute in the XmlElementRef annotation:

@XmlElementRef(name = "Test", namespace = "http://www.mycompany.com/schemas/MySchema", type = JAXBElement.class, required = false)

The only way I've seen to fix it is to import the JAXB 2.2 libraries and then add 
the -Djava.endorsed.dirs=projectpath/lib/jaxb parameter to the compiler arguments.

I would rather use the JDK 1.6_17 or 18 version of JAXB so I do not have to bundle another version of JAXB with my applets and JEE projects. 

I've also noticed that if I don't import the JAXB libraries that the Ant task is not defined outside of NetBeans when compiling using ant from the command line. I realize that Sun has not bundled the Ant task with the JDK so it might be nice to allow just the jar that contains the Ant task to be bundled, but only used for compilation and not run time. It should not be bundled with the run time in the dist directory.

Please let me know if there is a way to force NetBeans to use the JDK's version of JAXB.
Comment 1 Milan Kuchtiak 2010-02-08 10:02:12 UTC
I expect this happens only to old projects containing JAXB bindings.
In new projects, we specify 
endorsed.classpath=\
    ${libs.JAXB-ENDORSED.classpath}

in order to avoid the compilation and execution problems you can set up this property manually.

To force projects using JAXB version from JDK, please replace :

jaxbwiz.xjcdef.classpath=${libs.jaxb.classpath}

to 

jaxbwiz.xjcdef.classpath=//classpath to com.sun.tools.xjc.XJCTask(related to JDK version)

... and Clean & Build the project

Also remove (or comment out) the endorsed.classpath property, if present:
 
# endorsed.classpath=\
#    ${libs.JAXB-ENDORSED.classpath}

Note: You can also completely override "xjc-typedef-target" (xml_binding_build.xml) in build.xml.  

To fix this issue we need to set up endorsed.classpath also for old projects containing JAXB bindings.
Comment 2 Milan Kuchtiak 2010-02-08 10:30:43 UTC
Note, the issue was fixed already, and should be present in 6.8_patch :

*** This bug has been marked as a duplicate of bug 175436 ***