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
Related
My RCP application makes calls to SOAP web services and has been using the built-in JAXB/JEE components in Java 1.8. I have set up the build process to force the use of Java 1.8 and this had been working well.
Recently, the build stopped working because the builder (Tycho) now has a component which only works with later Java versions. If I compile with the later version I get 100's of JEE-related errors such as JaxbElement not found or #WebMethod not found.
At some point we will have to move away from Java 1.8 and use a Java version which does not provide those JEE components, so forcing the use of 1.8 can only be a short-term solution.
Is there an eclipse plugin which already provides those missing components? (I have searched but not found anything) Or do I need to create my own helper plugin which contains the necessary libraries? Is there perhaps a JAXB alternative which I could use for the SOAP calls?
The JAXB plugins/bundles are available on Eclipse Orbit: the plugins/bundles starting with javax..
In the plugins/bundles where they are needed, add the dependency in the MANIFEST.MF file via Import-Package (using Require-Bundle would require that these plugins/bundles are available even when using Java 8).
See also this answer.
I am currently working on a project that uses JDK 1.4. So its just turned out to be that we have to use ESAPI 1.4.4 which is the only version compatible with JDK 1.4 . I downloaded it from the following path https://github.com/esapi/esapi-java-legacy but it doesnt seem to be a jar file . I couldnt figure out how to include this in my eclipse project or how to bring it into my classpath. Is it possible to get the JAR ??? Someone please guide me how to use it or any sample project for reference is sufficient .Thanks in advance
Ditching JDK 1.4 is my top recommendation as well. But if that is not an option for some reason, then I would try pulling down the ESAPI code base from GitHub (https://github.com/ESAPI/esapi-java-legacy), changing the tag under the maven-compiler-plugin plugin from 1.7 to 1.4 and see if it compiles. Much of it probably will be fine, but you likely will have some huge 3rd party FOSS dependency issues so you will have to adjust those. So, before you go down that route, figure out what exactly it is that you need. If you only need ESAPI's output encoding, use the OWASP Java Encoder Project instead. Various other substitutes are described here: https://www.owasp.org/index.php/Category:OWASP_Enterprise_Security_API#tab=Should_I_use_ESAPI_3F
Good luck.
-kevin
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
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?
What is the best way to convert existing jar (without source) written in java 1.5 into java 1.4.x?
Take a look at Retroweaver. It will convert the classes or jar so that it can be run using a 1.4 JRE. Depending on the 1.5 features used, you won't need any additional retroweaver run-time.
Retroweaver uses byte code enhancement. It sounds mysterious but it works.
retrotranslator is another option similar to retroweaver
You could decompile it, then recompile. You'll probably have to fix incompatibilities by hand. Here's a thread on java decompilers.
My gut instinct would be to decompile the jar, then recompile as 1.4.
If there are no 1.5 specific API calls in the decompiled code, that should work fine.
If there are, you will need to re-engineer those sections to work in the earlier java version.
As well as decompiling, you'll likely have to refactor a few things in the source code - enums, generics (I don't think the generics will be in the decompiled code but that probably means you'll be missing some casts), boxing/unboxing, etc. etc.
as Rodeoclown said,
1) unzip the JAR
2) use a decompiler like jad(http://www.kpdus.com/jad.html) using options like these
jad -d src -f -ff -s .java -space -t4 ***.class
3) and from the generated source files, compile them using JDK 1.4's javac.
4) if the 1.4 compiler works OK, rebundle into new jar
5) if 1.4 compiler has issues, you need to use retroweaver(http://retroweaver.sourceforge.net/index.html). That might work in some cases BUT if the class expects changes in JVM, then you're in a tough spot. If the classes uses new threading facility, you can use the JDK 1.4 version of util.concurrent from http://g.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html.
Good Luck!