Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 175436 - [68cat] JAXB not working
[68cat] JAXB not working
Status: RESOLVED FIXED
Product: webservices
Classification: Unclassified
Component: JAXB
6.x
PC Windows 7 x64
: P2 with 2 votes (vote)
: 6.x
Assigned To: issues@webservices
issues@webservices
68patch1-verified
:
: 179956 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-10-26 15:26 UTC by Peter Nabbefeld
Modified: 2013-04-01 07:54 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
Simple project tried with NB 6.8 nightly build (32.96 KB, application/x-compressed)
2009-10-29 01:34 UTC, _ gmpatil
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Nabbefeld 2009-10-26 15:27:01 UTC
[ JDK VERSION : 1.6.* ]

Cannot see how to resolve conflict between JAXB from JDK1.6 and JAXB2.2. I've tried different project configuration
(with or without adding JAXB2.2 library), but always get errors (searched with google, found implementation conflict as
the problem, but no solution :( ). Also couldn't find any option to set JAXB as endorsed lib.

Thus, JAXB is currently not usable at all.
There should be an option, which implementation to use.

As this doesn't work *completely*, setting prio to 1. IMHO, JAXB is sth. that ought to work properly in an IDE which
has started as "Forte for Java".
Comment 1 Michael Nazarov 2009-10-27 10:44:56 UTC
Would you please provide more details? Some steps to reproduce,
logs, screenshots.

Thank you.
Comment 2 Peter Nabbefeld 2009-10-27 10:59:18 UTC
Getting this output when trying to generate jaxb classes:

xjc-typedef-target:
jaxb-code-generation:
Compiling file:.../xml-resources/jaxb/Semiramis_0901/my.xsd
...\xml_binding_build.xml:17: 
java.lang.reflect.UndeclaredThrowableException
        at $Proxy35.required(Unknown Source)
        at com.sun.tools.xjc.generator.bean.field.AbstractField.annotateReference(AbstractField.java:187)
        at com.sun.tools.xjc.generator.bean.field.AbstractField.annotate(AbstractField.java:156)
        at com.sun.tools.xjc.generator.bean.field.AbstractFieldWithVar.createField(AbstractFieldWithVar.java:75)
        at com.sun.tools.xjc.generator.bean.field.SingleField.<init>(SingleField.java:89)
        at com.sun.tools.xjc.generator.bean.field.SingleField.<init>(SingleField.java:76)
        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 com.sun.tools.xjc.generator.bean.field.GenericFieldRenderer.generate(GenericFieldRenderer.java:64)
        at com.sun.tools.xjc.generator.bean.field.DefaultFieldRenderer.generate(DefaultFieldRenderer.java:79)
        at com.sun.tools.xjc.generator.bean.BeanGenerator.generateFieldDecl(BeanGenerator.java:747)
        at com.sun.tools.xjc.generator.bean.BeanGenerator.generateClassBody(BeanGenerator.java:535)
        at com.sun.tools.xjc.generator.bean.BeanGenerator.<init>(BeanGenerator.java:235)
        at com.sun.tools.xjc.generator.bean.BeanGenerator.generate(BeanGenerator.java:175)
        at com.sun.tools.xjc.model.Model.generateCode(Model.java:286)
        at com.sun.tools.xjc.XJC2Task._doXJC(XJC2Task.java:494)
        at com.sun.tools.xjc.XJC2Task.doXJC(XJC2Task.java:434)
        at com.sun.tools.xjc.XJC2Task.execute(XJC2Task.java:369)
        at com.sun.istack.tools.ProtectedTask.execute(ProtectedTask.java:55)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor73.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.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:278)
        at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:498)
        at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
Caused by: java.lang.NoSuchMethodException: javax.xml.bind.annotation.XmlElementRef.required()
        at java.lang.Class.getDeclaredMethod(Class.java:1937)
        at com.sun.codemodel.TypedAnnotationWriter.invoke(TypedAnnotationWriter.java:107)
        ... 36 more
BUILD FAILED (total time: 10 seconds)

Google says that this error message is the result of a jaxb version conflict. NetBeans doesn't give me a more detailed
message about why this happens, so I have to trust Google.

There should be some options to select a JAXB version to use (and also for JAX-WS - but it at least has a workaround).
Comment 3 _ gmpatil 2009-10-28 02:55:07 UTC
Can you give below information to reproduce?
- JDK version/Java Platform used. With JDK 1.6 update 13, unable to reproduce.
- Sample project used
- Also what kind of work around you are looking for. 

Did you try to change below property to point to JAXB version you would like to use in nbporject/project.properties ?
jaxbwiz.endorsed.dirs=${newJAXBJarDir}
jaxbwiz.gensrc.classpath=${newJAXBJars}
jaxbwiz.xjcdef.classpath=${newJAXBJars}
jaxbwiz.xjcrun.classpath=${newJAXBJars}
Comment 4 Peter Nabbefeld 2009-10-28 10:05:25 UTC
Found at least one configuration problem in project.properties:

jaxbwiz.endorsed.dirs="${netbeans.home}/../ide9/modules/ext/jaxb/api"

(ide9 instead of ide12)

But it doesn't fix this issue. The properties now are:
jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"
jaxbwiz.gensrc.classpath=${libs.jaxb.classpath}
jaxbwiz.xjcdef.classpath=${libs.jaxb.classpath}
jaxbwiz.xjcrun.classpath=${libs.jaxb.classpath}

with libs.jaxb.classpath=C\:\\Programme\\NetBeans Dev
200910270201\\ide12\\modules\\ext\\jaxb\\activation.jar;C\:\\Programme\\NetBeans Dev
200910270201\\ide12\\modules\\ext\\jaxb\\api\\jaxb-api.jar;C\:\\Programme\\NetBeans Dev
200910270201\\ide12\\modules\\ext\\jaxb\\jaxb-impl.jar;C\:\\Programme\\NetBeans Dev
200910270201\\ide12\\modules\\ext\\jaxb\\jaxb1-impl.jar;C\:\\Programme\\NetBeans Dev
200910270201\\ide12\\modules\\ext\\jaxb\\jaxb-xjc.jar;C\:\\Programme\\NetBeans Dev
200910270201\\ide12\\modules\\ext\\jaxb\\api\\jsr173_api.jar

(selected output from <echoproperties/>)

Going to clear caches (var/cache and var/filehistory)
Comment 5 Peter Nabbefeld 2009-10-28 10:26:14 UTC
Cleaning the caches didn't help, either :(
Comment 6 Peter Nabbefeld 2009-10-28 10:49:34 UTC
Found already one bug here:
org.netbeans.modules.xml.jaxb.util.ProjectHelper / line 810:
        String ret = "\"${netbeans.home}/../ide9/modules/ext/jaxb/api\""; //NOI18N
(ide9 instead of ide12)

Did You really test with current daily build?
Comment 7 _ gmpatil 2009-10-28 18:53:59 UTC
I tried with JDK 1.6 update 13, using NB 6.7.1. I am not actively involved in NB 6.8, that is the reason for asking for
details on environment used.

Will try to simulate using nb 6.8 build and commit the fix.
Comment 8 _ gmpatil 2009-10-29 01:32:47 UTC
Tried with NB 6.8 nightly build1[1]  with attached simple project in/with JDK 1.6.0_16, unable to reproduce the error.
Even the "ide9" in endorsed property though wrong did not any effect while running the Hello class.

Please attach non-proprietary project to simulate this issue.

[1]
Product Version: NetBeans IDE Dev (Build 200910280201)
Java: 1.6.0_16; Java HotSpot(TM) Client VM 14.2-b01
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Userdir: C:\Documents and Settings\gpatil\.netbeans\dev

[2] jaxbwiz.endorsed.dirs="${netbeans.home}/../ide9/modules/ext/jaxb/api"
Comment 9 _ gmpatil 2009-10-29 01:34:47 UTC
Created attachment 90191 [details]
Simple project tried with NB 6.8 nightly build
Comment 10 Peter Nabbefeld 2009-10-29 15:25:20 UTC
Just a little change in line 9 results in the error:
    <xsd:element name="ssn" minOccurs="0" nillable="true" type="xsd:string"></xsd:element>

I've found out, this should result in a declaration like
protected JAXBElement<String> ssn;

Further, it usually seems to work (googled for "nillable jaxb" and found a question about this behavior, so somebody
must have been able to produce this).

So, the question is:
Does JAXB need a parameter to be set, and why isn't it set by the JAXB module?
Comment 11 _ gmpatil 2009-10-29 19:51:53 UTC
How is this Netbeans JAXB Wizard issue? 
I see JAXB RI issue for this at https://jaxb.dev.java.net/issues/show_bug.cgi?id=692 .
Is it not this a JAXB RI issue?

What parameter JAXB Wizard should pass to XJC?

Comment 12 _ gmpatil 2009-10-29 22:53:36 UTC
As mentioned in JAXB RI issue[1] as a work around, copied the JAXB API jar to <JRE 1.6>/lib/endorsed/ directory. Able to
build the project with the Schema file changed as suggested. Also able to run the Hello class by changing code (note not
a Netbeans module issue) as below.

cq.setSsn(new JAXBElement(new QName("http://xml.netbeans.org/schema/CreditReport", "ssn"), String.class, "12345678"));

If there is an work which we can implement in NB tooling, please file separate enhancement ticket.

[1] https://jaxb.dev.java.net/issues/show_bug.cgi?id=692
Comment 13 Peter Nabbefeld 2009-10-30 08:28:39 UTC
No. It's not the same bug - there's no "nillable='true'"
Comment 14 Milan Kuchtiak 2009-11-09 05:58:28 UTC
Problems with endorsed libraries can be solved by setting the 
endorsed.classpath property in project.properties file.

e.g.
endorsed.classpath=my_path/jaxb-api.jar:my_path/jaxws-api.jar,...

Note, in Java EE 6 web/ejb projects the property is set up automatically:

endorsed.classpath=${libs.javaee-endorsed-api-6.0.classpath}
Comment 15 Peter Nabbefeld 2009-11-09 08:19:37 UTC
Editing project.properties is a hack, not a solution. If the property has to be edited, it's the task of the JAXB module to solve this, not the user's one.
Comment 16 marianomd 2009-12-16 13:45:10 UTC
Same problem here with Netbeans 6.8.

When trying to compile I get:

java.lang.NoClassDefFoundError: de
Caused by: java.lang.ClassNotFoundException: de
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: de.  Program will exit.
Exception in thread "main" Java Result: 1

After removing this line:

jaxbwiz.endorsed.dirs=C:\\Archivos de programa\\NetBeans 6.8\\ide12\\modules\\ext\\jaxb\\api

from nbproject\private\private.properties 

everything works OK, but Netbeans keeps adding that line afterwards.
Comment 17 _ henriquemeira 2009-12-16 18:27:20 UTC
I've a collection of webservices that worked fine on Netbeans 6.7.1! Since I updated to 6.8 I got this error:

"You are running on JDK6 which comes with JAX-WS 2.1 API, but this tool requires JAX-WS 2.2 API. Use the endorsed standards override mechanism (http://java.sun.com/javase/6/docs/technotes/guides/standards/), or set xendorsed="true" on <wsimport>."

I set xendorsed=true (in properties of webservice reference), and generates without errors, but it don't work, I get the exception: 

"javax.xml.ws.WebServiceException: Cannot find 'https://nfe.fazenda.sp.gov.br/nfeweb/services/nfestatusservico.asmx?wsdl' wsdl. Place the resource correctly in the classpath."

Debugging, I discovered the problem, the "JAX-WS RI 2.2-hudson-752-" generates a diferent code from previous 2.1 version, wich (2.2 version) try to init URL location by this way: 

NFESTATUSSERVICO_WSDL_LOCATION = NfeStatusServico.class.getResource("https://nfe.fazenda.sp.gov.br/nfeweb/services/nfestatusservico.asmx?wsdl"); 

This resource is not found. Ie., getResource() returns null value. 

From 2.1 version, the JAX code auto-generated, do the load URL by this form: 

URL url = new URL("https://nfe.fazenda.sp.gov.br/nfeweb/services/nfestatusservico.asmx?wsdl") 

Now, until this moment, I don't know how to solve, because, if I edit this generated file, this will work, but if I "clean and build" the project, the NetBeans will regenerate the bad code again.
Comment 18 Milan Kuchtiak 2009-12-17 04:14:03 UTC
I agree the issue is pretty serious.
Please, temporarily, as a workaround, insert this line into nbproject/project.properties:

endorsed.classpath=${libs.jaxb.classpath}
Comment 19 Lukas Jungmann 2009-12-17 06:34:27 UTC
this should be fixed for 6.8 patch 1
Comment 20 _ henriquemeira 2009-12-17 16:24:16 UTC
(In reply to comment #18)
> I agree the issue is pretty serious.
> Please, temporarily, as a workaround, insert this line into
> nbproject/project.properties:
> 
> endorsed.classpath=${libs.jaxb.classpath}

Didn't work.

I inserted the endorsed.classpath=${libs.jaxb.classpath} at end the nbproject/project.properties and I got this compilation exeption:

...NfeStatusServico.java:44: cannot find symbol
symbol  : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])
location: class javax.xml.ws.Service
        super(__getWsdlLocation(), NFESTATUSSERVICO_QNAME, features);
...NfeStatusServico.java:52: cannot find symbol
symbol  : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])
location: class javax.xml.ws.Service

Code taken from NfeStatusServico.java:

#43 public NfeStatusServico(WebServiceFeature... features){
#44     super(__getWsdlLocation(), NFESTATUSSERVICO_QNAME, features);
#45 }


#51 public NfeStatusServico(URL wsdlLocation, WebServiceFeature... features){
#52     super(wsdlLocation, NFESTATUSSERVICO_QNAME, features);
#53 }

I'm analising the error, but if you have any hint, I'll appreciate.
Comment 21 Milan Kuchtiak 2009-12-18 02:43:23 UTC
It has something to do with web services.

So instead of 
endorsed.classpath=${libs.jaxb.classpath}

you should use :
endorsed.classpath=${libs.JAX-WS-ENDORSED.classpath}
(this is added automatically when you create a web service client in your project)

or 

endorsed.classpath=${libs.javaee-endorsed-api-6.0.classpath}
(this is added automatically in JavaEE 6 project types)
Comment 22 Milan Kuchtiak 2009-12-18 09:14:13 UTC
Fixed.

Implemented JAXB_ENDORSED classpath for projects containing JAXB bindings.

Details:
http://hg.netbeans.org/main/rev/fc4a7af7418c
Comment 23 _ henriquemeira 2009-12-18 19:00:27 UTC
Hello, didn't work.

Maybe you prefer I open a new issue, but this

endorsed.classpath=${libs.JAX-WS-ENDORSED.classpath}
or
endorsed.classpath=${libs.javaee-endorsed-api-6.0.classpath}

do not solved the problem.

As I said before, the problem is on URL class load.

The jax-ws source generated of the JAX-WS RI 2.2-hudson-752- makes use of the follow code to initiate the URL object:

// Sample:
NFESTATUSSERVICO_WSDL_LOCATION = package.MyWebService.class.getResource("https://myserverwebservice/mywebservice.asmx?wsdl");

I discovered that this problem happen just with remote webservices, ie, schemas did catch from HTTP or HTTPS protocols. If I use a local wsdl schema file, this error does not happen, ie, with schemas from file with FILE:// protocol.

I do return to NetBeans 6.7.1 and all works fine. The NB 6.7.1 do use JAX-WS RI 2.1, wich initiate the URL object by this way:

URL url = new URL("https://myserverwebservice/mywebservice.asmx?wsdl");

I think so the problem is in getResource method from generated class MyWebService, wich cannot found the resource.

Running the project, I got this error message:

javax.xml.ws.WebServiceException: Cannot find 'https://https://myserverwebservice/mywebservice.asmx?wsdl' wsdl. Place the resource correctly in the classpath.
        at package.MyWebService.<clinit>(MyWebService.java:34)

Exactly in the getResource method! 

I'll attempt to found a public webservice to reproduce a step-by-step tutorial.

henrique.
Comment 24 Quality Engineering 2009-12-19 00:25:22 UTC
Integrated into 'main-golden', will be available in build *200912190200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/fc4a7af7418c
User: mkuchtiak@netbeans.org
Log: #175436: add JAXB-ENDORSE classpath to projects containing JAXB bindings, remove obsolete code
Comment 25 Milan Kuchtiak 2009-12-21 01:40:09 UTC
Peter, please, open a new issue for your problem, with the detailed steps to reproduce. Your problem is related more to JAX-WS not JAXB, isn't it ?
The original - JAXB problem related to endorsed mechanism was fixed.

Actually, I am a little bit lost what's your problem. The best would be to attach the wsdl file to that new issue. 
Thank You.
Comment 26 Milan Kuchtiak 2009-12-21 06:31:09 UTC
One another fix (incorrect test statement):
http://hg.netbeans.org/main/rev/49521873de65

Note: this is just code cleanup for JAXB support.
Comment 27 Quality Engineering 2009-12-21 23:39:39 UTC
Integrated into 'main-golden', will be available in build *200912220201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/49521873de65
User: mkuchtiak@netbeans.org
Log: #175436: fixing incorrect if statement
Comment 28 Jaroslav Pospisil 2010-01-12 01:56:01 UTC
v.
Comment 29 pgebauer 2010-01-14 02:50:49 UTC
The fix has been ported into the release68_fixes repository.
http://hg.netbeans.org/release68_fixes/rev/604bc914fe57
Comment 30 Milan Kuchtiak 2010-02-08 10:30:43 UTC
*** Bug 179956 has been marked as a duplicate of this bug. ***
Comment 31 stefvz1 2013-03-26 02:24:59 UTC
Hi,
when, i can see that in release 7.3 are still problems with jaxb 2.0... When I'm generating the asynchronous web service client in GUI application, IDE generate me web service classes with  
@XmlElementRef(name = "DSAKeyValue", namespace = "http://www.w3.org/2000/09/xmldsig#", type = JAXBElement.class, required = false),

... Unfortunetly Netbeans doesn't support jaxb 2.2. so I'm getting error in part of required method cause XmlElementRef is from 2.0 api and generated method is related against 2.2. api.. I used Jaxb 2.2.5 library module from netbeans but still with no sucess.. Any other suggestions ?
Comment 32 Sergey Petrov 2013-04-01 07:54:28 UTC
I'm not sure it was good idea to reopen two years old issue, please file new one instead.
This one issue is also about 2.2 and is not about 2.0, if you are referring diffeent issues in your comment, please file several issues also (one for "problems with jaxb 2.0", another for "Netbeans doesn't support jaxb 2.2. so I'm getting error in" etc. if necessary).
close this one back as fixed for a few releases and restore some other fields.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo