Two classes have the same xml type name
Asked Answered
W

2

10

When I try to publish my Workspace in RAD, I get this error "Two classes have the same xml type name", probably because the same class name exists in the same package, but in two different jars. And it seems like that the @XmlType annotation needs to have distinct values for its attributes name and namespace in the sources of these classes. I tried wsdl2java available in Apache CXF, but I'm not able to make it generate this namespace attribute. I tried fiddling with the -p package option, but that's only for placing the generated sources in the specified package.

Any ideas how to generate this namespace attribute for each element encountered in the wsdl? TIA.

Wordsmith answered 14/2, 2011 at 11:4 Comment(0)
U
13

thanks to Daniel's anwser:

CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements

i learned there is a parameter -xjc-npa for wsdl2java which helped me. This will add XmlType.name and XmlType.namespace annotations to the generated classes so it won't be a problem if you have same class names but in different namespaces

Uncinus answered 3/6, 2011 at 7:35 Comment(1)
Thanks! I never thought I would get an answer.Wordsmith
C
1

I ran into this for an object named "SubmitDataResponse" that I was using as a return object from my web service method named "submitData". When I tried renaming the object, the error went away. It seems to me that CXF is creating its own return object based on the method name (in this case submitData() -> "SubmitDataResponse"). You may want to try renaming the class and see if you are having the same issue. Perhaps someone can chime in with a way to keep our class named the way we want them to (probably with some annotation).

I hope this helps.

Chunk answered 21/3, 2011 at 20:45 Comment(3)
Follow-up: I added @XmlType(namespace="com.company.example") to my original return object class and it worked. So I didn't need to rename my return object class as long as I use the XmlType.namespace annotation.Chunk
HawkeyeFan, Thanks for your answer, but, no, this is not the issue i was facing. It was about two classes which were there in two jars with same package names. Eventually, I had to remove one of them and live with it. Yeah, the namespace attribute seems to fix this, but can wsdl2java generate it? maybe I need to specify/configure something?Wordsmith
Also, there were a whole lot of other classes duplicated in those two jars (probably because of two WSDLs being very similar). So I got an updated WSDL and hence the generated jar didn't contain any duplicates.Wordsmith

© 2022 - 2024 — McMap. All rights reserved.