The classes' Javadoc that's produced by cxf-codegen-plugin:3.4.2:wsdl2java looks like the following here:
/**
* <p>Java class for RequestType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="RequestType">
* <complexContent>
which, of course, is rendered to the following in Eclipse's Javadoc view, for instance:
<p>Java class for RequestType complex type. <p>The following schema fragment specifies the expected content contained within this class. <pre> <complexType name="RequestType"> <complexContent>
Is this a bug in the plugin?
UPDATE
I filed a bug in https://issues.apache.org/jira/browse/CXF-8577.
Comments from https://issues.apache.org/jira/browse/CXF-8577:
This is a known issue fo JAXB 2.3.3, JAXB 2.3.4 has fixed this up.
Please find related discussion here
https://github.com/eclipse-ee4j/jaxb-ri/issues/1471
The released CXF 3.4.4 has already upgraded to use jaxb-xjc 2.3.4, so no such issue with CXF 3.4.4 anymore
Related
When the Spring Integration does the Http.outboundGateway call with the HttpMethod.PATCH operation there comes the exception:
Caused by: java.net.ProtocolException: Invalid HTTP method: PATCH
at java.base/java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:487)
at java.base/sun.net.www.protocol.http.HttpURLConnection.setRequestMethod(HttpURLConnection.java:569)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestMethod(HttpsURLConnectionImpl.java:365)
at org.springframework.http.client.SimpleClientHttpRequestFactory.prepareConnection(SimpleClientHttpRequestFactory.java:226)
at org.springframework.http.client.SimpleClientHttpRequestFactory.createRequest(SimpleClientHttpRequestFactory.java:146)
at org.springframework.http.client.support.HttpAccessor.createRequest(HttpAccessor.java:87)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:719)
This is the problem in the Java class HttpURLConnection, because it doesn't support the PATCH operation.
I must use the PATCH method. What are the best ways to handle this situation?
The RestTemplate by default uses a SimpleClientHttpRequestFactory based on the Java HttpURLConnection. Consider to use some other ClientHttpRequestFactory, e.g. HttpComponentsClientHttpRequestFactory. When you declare such a bean you can inject it into the Http.outboundGateway().requestFactory():
/**
* Set the {#link ClientHttpRequestFactory} for the underlying {#link RestTemplate}.
* #param requestFactory The request factory.
* #return the spec
*/
public HttpMessageHandlerSpec requestFactory(ClientHttpRequestFactory requestFactory) {
I'm using Android Studio 3.0.1. I can hit fix doc comment to insert comment of method quickly in Java, but not effective in Kotlin. How can I solve it?
When you're typing # inside a kdoc, you'll see auto complete for #param, and after #param you'll see all parameters, and currently you cannot complete all parameters within one click.
Mention the /** */ comments are called kdoc in Kotlin, which is not javadoc.
Kotlin and especially KDoc encourage a different documentation style. As stated in this discussion:
The reason is that we found that referring to parameter names from the documentation text allows to write documentation that is more concise and easier to read compared to the traditional javadoc style where every parameter is documented in a separate tag. Therefore, we do not generate the template with parameter names by default. (D. Jemerov, Kotlin in Action Author)
Here’s an example of let, which is part of the standard library:
/**
* Calls the specified function [block] with `this` value as its argument and returns its result.
*/
#kotlin.internal.InlineOnly
public inline fun <T, R> T.let(block: (T) -> R): R
I'm using the maven-jaxb2-plugin to generate JAXB classes from a WSDL file. Unfortunately the automatically generated Javadoc is not Java 8 compliant as it generates the following invalid links:
/**
* Create an instance of {#link JAXBElement }{#code <}{#link byte[]}{#code >}}
*
*/
#XmlElementDecl(namespace = "http://schemas.microsoft.com/2003/10/Serialization/", name = "base64Binary")
public JAXBElement<byte[]> createBase64Binary(byte[] value) {
return new JAXBElement<byte[]>(_Base64Binary_QNAME, byte[].class, null, ((byte[]) value));
}
The #link byte[] reference fails as a missing reference. Unfortunately I don't know if this is being generated by the maven plugin, or JAXB itself.
I don't want to turn of Javadoc linting for my project. Any help on how to fix this without having to resort to adding jxb:javadoc elements all over my WSDL would be appreciated. Thanks
In my case, the erroneous javadoc tags were in the file ObjectFactory.java, and I don't use the ObjectFactory class. So I modified my build script to delete the file after it was generated and before running javadoc.
Cutting the Gordian knot, or using a hammer since it was the only tool I had? You decide.
I am attempting to use JAXB to unmarshall an XML files whose schema is defined by a DTD (ugh!).
The external provider of the DTD has specified one of the element attributes as xml:lang:
<!ATTLIST langSet
id ID #IMPLIED
xml:lang CDATA #REQUIRED
>
This comes into the xjc-generated class (standard generation; no *.xjb magic) as:
#XmlAttribute(name = "xml:lang", required = true)
#XmlJavaTypeAdapter(NormalizedStringAdapter.class)
protected String xmlLang;
However, when unmarshalling valid XML files with JAXB, the xmlLang attribute is always null.
When I edited the XML file, replacing xml:lang with lang and changed the #XmlAttribute to match, unmarshalling was successful (i.e. attributes were non-null).
I did find this http://old.nabble.com/unmarshalling-ignores-element-attribute-%27xml%27-td22558466.html. But, the resolution there was to convert to XML Schema, etc. My strong preference is to go straight from an un-altered DTD (since it is externally provided and defined by an ISO standard).
Is this a JAXB bug? Am I missing something about "namespaces" in attribute names?
FWIW, java -version = "build 1.6.0_20-b02" and xjc -version = "xjc version "JAXB 2.1.10 in JDK 6""
Solved the issue by changing replacing xml: with a namespace declaration in the JAXB-generated class:
#XmlAttribute(name = "lang", namespace="http://www.w3.org/XML/1998/namespace", required = true)
Which makes sense, in a way.
Without this kind of guidance, how would JAXB know how to interpret the otherwise-undefined namespace xml:? Unless, of course, it implemented some special-case internal handling to xml: as done in http://java.sun.com/javase/6/docs/api/javax/xml/stream/XMLStreamReader.html#getNamespaceURI%28java.lang.String%29 (see the first NOTE:)
Whether it's a bug in xjc's generation of the annotated objects or a bug in the unmarhaller, or simply requires a mapping somewhere in the xjc process is still an open question in my mind.
For now, it's working and all it requires is a little xjc magic, so I'm reasonably happy.
Disclaimer: Although 8 years late, I am adding this answer for lost souls such as myself trying to understand auto generation of java files from a DTD.
You can set project wide namespaces for the unmarshaller to work with directly in the project-info.java file via the #XmlSchema option.
This file should be automatically generated by xjc when generating classes from a schema, however it appears xjc does not automatically generate the package-info.java file when generating from a DTD!
However, you can manually make this file, and add it to the same package as the files generated by xjc.
The file would look like the following:
package-info.java :
#XmlSchema(
elementFormDefault=XmlNsForm.QUALIFIED,
xmlns = {
#XmlNs(prefix="xlink", namespaceURI="http://www.w3c.org/1999/xlink"),
#XmlNs(prefix="namespace2", namespaceURI="http://www.w3c.org/1999/namespace2")
})
package your.generated.package.hierarchy;
import javax.xml.bind.annotation.*;
You can add as many namespaces as required, simply add a new line in the form:
#XmlNs(prefix="namespace", namespaceURI="http://www.uri.to.namespace.com")
The benefit of doing it this way, rather than compared to editing the generated #XmlAttribute is that you do not need to change each generated XmlAttribute, and you do not need to manually remove the namespaces from the XmlAttribute name variable.
First attempt to use this cool site - after searching for 2 hours:
So I have a Java Bean that is given (I can only annotate not change) and need to map it to XML using JAXB. I would like primitives types not to be printed when they contain their language default, or a user-defined default.
As said I cannot change the java bean, and therefore change the primitive types into their Object Wrappers counterparts.
How do you do that best?
Sample bean:
class Foo {
public String name;
// -1 is user defined default, to indicate field is not set.
public long someIdx=-1;
// ...
}
Foo f = new Foo();
f.name = "Duke";
for this instantiation, what I would like is the following output:
<foo><name>Duke</name></foo>
You could use JAXB's XmlAdapters. Availible since JAXB 2.0 (JDK 6.0)
Using the adapter, you let the bean alone and annotate/change a completely different class. This should be not a problem in your case.
See my reply here
See JAXB's author's blog post