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!!
">