• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using JAXB APIs in jdk1.6 and jdk1.4

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am using the JAXB apis and the xjc utitlity in my project. The code I am writing should be compatible for both jdk 1.4 and jdk 1.6 versions. I tried the following -

Used xjc of jdk1.6 and generated JAVA source code for a .xsd file and compiled the JAVA source files and used these class files and able to unmarshall the xml file in jdk1.6 environment. I used the same source code of unmarshalling as shown below - in jdk1.4 environment using the same class files generated using the xjc of 1.6 version, but I am getting unsupported version error.

==============================unmarshall code==============================

try{
JAXBContext jc = JAXBContext.newInstance("com.ericsson.jaxb");
Unmarshaller unmarshaller = jc.createUnmarshaller();
Items items = (Items)unmarshaller.unmarshal(new File("Items.xml"));
List itemList = items.getItem();
for(int i=0; i<itemList.size();i++){
Item item = (Item)itemList.get(i);
System.out.println("Name = " + item.getName() +
", Price = " + item.getPrice() + ", Id = " + item.getId());

}
}
catch(Exception e)
{
e.printStackTrace();
}

=============================================================================

The error I get in jdk1.4 - javax.xml.bind.JAXBException: Provider com.sun.xml.bind.ContextFactory could not be instantiated: java.lang.UnsupportedClassVersionError: com/ericsson/jaxb/ObjectFactory (Unsupported major.minor version 50.0)

So, there is a compatibility issue between the generated source code for a .xsd file in jdk1.4 and jdk1.6 versions. Is there a solution to address this in JAXB? If not, is there any other way to create JAVA objects, given a .xsd file other than unmarshalling using JAXB?

Please clarify.

Thanks in advance!!
">
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


using the same class files generated using the xjc of 1.6 version


You'll need to compile your JAXB generated java files in 1.4 otherwise you will get this message. Of course you can't do this, since JAXB source will contain annotations, unless you use a backport (as mentioned in your other post).

Unless there is some incredibly compelling reason to try to use JDK1.4, I'd do all your JAXB work in a version that supports JAXB.
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Sorry to reopen an old thread

Hi ,

I got the same issue as i m compelled to use JDK 1.4. Where can i download JAXB (xjc compiler and jars ) compatible to JDK1.4. The current download available in SUN website is "JWSDP 2.0" which requires 1.5 minimum. Please point some links where i can download JWSDP 1.X version compatble to JDK1.4 . Thanks.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On the JAXB home page (linked above), just follow the "JAXB 1.0" link; it'll lead you to the downloads.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"

On the JAXB home page (linked above)



Is this link https://jaxb.dev.java.net/ ? Cant find 1.0 .
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Really? There's no big "JAXB 1.0" link at the left hand side?
 
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic