Specifying jaxb version to wsgen - java

I'm suffering from the same error as this question, but I can't use that answer since I'm not using Maven, so I'm stuck on how to specify what version of jaxb to use with wsgen. I'm downloaded the 2.2.7 jars and added them to my classpath, but my generated files still say that they've been generated using 2.2.4b1, which I presume was included in the JDK.
Anybody know how to specify to wsgen what jaxb version I want to use?

Related

Intellij wrong xsd validation for Spring versionless xsd

As far as I understand, it is better to use Spring versionless xsd.
However, when using Intellij the validation is done based on a random xsd file.
When adding the version to the xsd file everything works as expected.
As you can see I use Spring 4.2.1 but Intellij chooses 3.1 version.
Is it a bug (or not yet implemented feature) in Intellij?
Is there a workaround?
If there is no place with version specification, then
yes, it is random, you can try the following test: add space in front of line (make some simple change) with xsd specification), after each change it jumps to another random xsd version
If you want to lock it on the latest lib version and don't specify it, you can use gradle build.
//use latest version of library with gradle:
compile 'org.springframework:spring-orm:+'
after that idea always points to latest version of xsd for schemaLocation

Can I replace the latest version mail.jar in Axis2 default download?

We are using in our library axis2 library. Axis2 latest version comes with mail.jar version 1.4. We need newer version of mail.jar in the classpath, so can I just replace latest version of mail.jar to Axis2 default download libs?
I have checked out the Axis2 src and recompiled by changing to version 1.5.0 of JavaMail and it compiles and tests run successfully.
Note also reading through the changelog as far as I can tell the changes described are additive.
https://javamail.java.net/docs/JavaMail-1.5-changes.txt
It looks like you can replace the jar but you should test it to be sure. It should really only matter if you are using the MailTransportSender in Axis2.
Btw you might want to consider switching away from Axis and use CXF as in my experience and in various benchmarks like http://www.ibm.com/developerworks/library/j-jws14/ CXF is a lot faster.

JAXB backward compatibility

Years ago I wrote an application that used JAXB to generate Java bindings for an XML schema. The application code and the schema have been updated quite a lot over the years, but the JAXB jars remained the same since 2008, which was when I started using JAXB for this application. I've been using Ant to build the application, including generating and compiling bindings, and everything worked fine on at least two XP Pro development machines. I made some changes to the schema and never had to think about JAXB.
Recently I tried to rebuild the application from scratch on a new laptop, and the build keeps failing. The new 64-bit laptop is running windows 7 Pro, it had a newer JDK (1.7.0_45) and a new version of Ant (1.9.3). I was able to get around some weird problems by switching to a yet newer version of ant (1.9.4) and switching to latest JAXB jars. At this point, I don't even remember what those issues were (but I can recreate them by reverting to older JAXB jars in SVN).
After upgrading JAXB, I ran into new problems. First of all, the xjc task in ant seems to be interpreting the target attribute differently; it threw some error and apparently the destdir has the semantic meaning that target used to have.
Second, this task no longer generates the impl package with the implementation classes whose names were supposed to end with Type, so the rest of my code fails with a bunch of compilation problems.
Is there a way to make the new JAXB version backward-compatible? My other options are try updating the code to work with the new bindings, which seems like a lot of unnecessary work, or reverting to old JDK and Ant.
This is a late reply to the original post. But should be good as a reference for other folks. I met the same problem. Here is what worked for me after going through much of the same struggles trying to rebuild JAXB 1.0 scheme/binding using later JDKs (8 and 7).
My goal is to build with latest JDKs without the hassle of upgrading JAXB, if possible.
JDK 7&8 failed building with JAXB 1.0 due to ClassCastException thrown from <xjc> possibly due to incompatible language features. JDK 5&6 work, however.
I went through several attempts trying to upgrade to the latest JAXB 2.11.12,
Update ant build file <xjc> task to replace target attribute with deskdir
Change binding files syntax - bindingStyle attribute was removed in <jxb:globalBindings> in the latest JAXB - we use modelGroupBinding
Adjust binding class files suffix to avoid name conflicts. Update sources for the new type names generated.
There were still remaining name conflicts and source upgrades required.
I decided to stop going further down the rabbit hole making all these changes and focus on finding just one version of JAXB that generates JDK 7&8 compatible sources but still support JAXB 1.0 schema and binding.
Newer <xjc> task supports version specification by source attribute. However, as the original poster found out, support of "1.0" was removed in later JAXB distributions
The "Illgal version 1.0" error message when using <xjc> is due to support for version 1.0 was removed in since JAXB 2.2.7 (https://jaxb.java.net/nonav/2.2.11/docs/ch02.html#a-2-2-7)
However, JAXB 2.2.6 doesn't work either. There seems to be a bug in that "jaxb-xjc.jar" version not generating sources correctly based on the attribute, resulting in the certain ClassNotFoundException during build.
I read reports on JAXB 2.1.18 failing to respect "1.0" source as well
Eventually I found JAXB 2.0.5 is to be one version that can generate JDK 7&8 compatible sources using JAXB 1.0 source schema and binding.
Drop in the JAXB-RI 2.0.5 libs and remove old jaxb-libs.jar
Add source="1.0" attribute the <xjc> task
No need to convert <xjc> "target" attribute to "deskdir" in this version
I have not tested more versions beyond 2.0.5 but it's possible there are higher versions that does the same
Your old project seems to use JAXB 1 whereas all the tools now have JAXB 2.x by default.
Try the following in the XJC task:
source="1.0"
target="1.0"
See these documents:
https://jaxb.java.net/2.2.4/docs/xjcTask.html
https://jaxb.java.net/2.2.4/docs/jaxb-1_0.html

JAXB Ant Task - Where to get JARs?

There is a number of sources, explaining the JAXB Ant Task. For example, Oracle itself: http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/1.6/jaxb/ant.html.
Apparently however, none of the sources seem to provide the JAXB libraries, particularly jaxb-xjc.jar, or at least give a hint for where to download it.
The XJC JABX compiler of my JDK 1.6.0_24 is of version 2.1.10. There doesn't seem to be any JAXB library provided in the JDK.
I tried out things like the jaxb-builder Eclipse Plugin (http://sourceforge.net/projects/jaxb-builder), but i keep running into version conflicts.
Am i missing something out here? Any clues where i can obtain a proper v2.1.10 release of the JABX libraries, especially the Ant Task?
Thanks a lot for your comments!
The link you mention is for an ancient version of JAXB - ignore it, it's not relevant.
Java6 does come with JAXB 2.1, but doesn't (as far as I'm aware) come with any Ant tasks for XJC. If you want to use the XJC that comes with the JDK, you need to use the xjc.exe command-line utility (which of course, you can use from Ant).
Alternatively, get the JAXB reference implementation from http://jaxb.java.net/, which does have an Ant task, or use another JAXB implementation such as MOXy, which should have comparable tools.
I use www.findjar.com
For jaxb-xjc, it returns
http://www.findjar.com/jar/com.sun.xml.bind/jars/jaxb-xjc-2.0.1.jar.html

How to use jaxp 3 with jdk 1.6?

I'm trying to migrate application from jdk 1.5 to jdk 1.6 without introducing any changes visible to the end user.
Application's output is an xml generated using jaxp which is a part of the jdk libraries. Since jaxp versions are different in jdk 1.5 and 1.6, the resulting xml looks different in each version.
An example: DatatypeFatory.newInstance().newDuration(60) produces 'PT2H17M0.000S' in jdk 1.5 and 'P0Y0M0DT2H17M0.000S' in jdk 1.6. Both are correct, but i want to avoid any visible changes.
Classes like DatatypeFactory have a mechanism which allows specifying which implementation should be used, but it relies on specifying full qualified class name. So theoretically i could download jaxp jars with the same version which is used in jdk 1.5 and let the application use them. Unfortunately the package and class names are the same in both versions, so i would have to somehow tell java to load classes from jar and not jdk. I was trying to put jaxp jars at the beginning of the classpath, but it didn't help.
Is it possible to tell java to load classes from external jar and not jdk libraries? Can i solve this problem in any other way?
Thanks in advance
Unfortunately the package and class names are the same in both versions, so i would have to somehow tell java to load classes from jar and not jdk.
it is all decide by classLoader.
1. you can't except the jdk lib.
2. your third jar has the same name and class name.
other thing you can do,rewrite with the third jar's packageName,and recompile.

Categories