In my project,Iam converting object into xml.Iam using jaxb marshal method to do the conversion.
In running the program ,i got 1 counts of Illegal Annotation Exceptions.
how to solve this problem .
thanks in advance
In running the program ,i got 1 counts of Illegal Annotation Exceptions.
how to solve this problem .
thanks in advance
Code:
//Method for converting public static ReturnObject getXmlValue(HttpServletRequest httpRequest) { ReturnObject xRetObject = new ReturnObject(); xRetObject.setReturnCode("0"); xRetObject.setReturnMessage(null); xRetObject.setReturnObject(null); List<Widgets> widgetObjLists = null; Container thisContainer =new Container(); System.out.println("Inside the Utilities for getting the XmlValue >>>>>>>>>>"); try { List<Container> myContainer = (List<Container>) httpRequest.getSession().getAttribute(com.cmsapplication.utilities.StaticDefinitions.CONTAINER_OBJECT); // List l1 =new ArrayList(); // l1.add(thisContainer); Iterator itr = myContainer.iterator(); // System.out.println("List Size ::::::::::" + myContainer.size()); // ============================================================================================================= // Setup JAXB // ============================================================================================================= System.out.println("11111111111111111111111"); // Create a JAXB context passing in the class of the object we want to marshal/unmarshal final JAXBContext context = JAXBContext.newInstance(com.cmssuite.application.objects.Container.class); // final JAXBContext context = JAXBContext.newInstance(com.cmssuite.application.objects.JavaObject.class); // ============================================================================================================= // Marshalling OBJECT to XML // ============================================================================================================= // Create the marshaller, this is the nifty little thing that will actually transform the object into XML final Marshaller marshaller = context.createMarshaller(); System.out.println("222222222222222222222222"); // Create a stringWriter to hold the XML final StringWriter stringWriter = new StringWriter(); // Create the sample object we wish to transform into XML final Container javaObject = new Container(); // final JavaObject javaObject = new JavaObject(); //javaObject.setName("Shanthi"); //javaObject.setRole("CEO"); while (itr.hasNext()) { Container conObj = (Container) itr.next(); System.out.println("WIDTH LIST SIZE :::::::::" + conObj.getWidgetObjectLists().size()); System.out.println("Container Code >>>>>>>>>>>>"+conObj.getContainerCode()); System.out.println("Container Name >>>>>>>>>>>>"+conObj.getContainerName()); //widgetObjLists = conObj.getWidgetObjectLists(); javaObject.setContainerCode(conObj.getContainerCode()); javaObject.setContainerName(conObj.getContainerName()); javaObject.setTotalContainer(conObj.getTotalContainer()); //Iterator widItr = widgetObjLists.iterator(); // while (widItr.hasNext()) // { // Widgets scrollTextObj = (Widgets) widItr.next(); // System.out.println("Behaviour >>>>>>>>" + scrollTextObj.getBehaviour()); // System.out.println("Direction >>>>>>>>>>>>" + scrollTextObj.getDirection()); // System.out.println("Height >>>>>>>>>>>>>" + scrollTextObj.getHeight()); // System.out.println("Scroll Amount >>>>>>>>>>" + scrollTextObj.getScrollAmount()); // System.out.println("Scroll Delay >>>>>>>>>>>>" + scrollTextObj.getScrollDelay()); // System.out.println("Text >>>>>>>>>>" + scrollTextObj.getText()); // // // } } //Container.Class @XmlRootElement public class Container extends com.cmssuite.businesslayer.core.DataObject { /// <summary> /// Default Constructor /// </summary> public Container() { super(); System.out.println ("Inside the constructor"); // // TODO: Add constructor logic here // } private String _containerName = null; public String getContainerName() { return _containerName; } public void setContainerName(String containerName) { this._containerName = containerName; } private String _containerCode = null; public String getContainerCode() { return _containerCode; } public void setContainerCode(String containerCode) { this._containerCode = containerCode; } private Integer _totalContainer = null; public Integer getTotalContainer() { return _totalContainer; } public void setTotalContainer(Integer totalContainer) { this._totalContainer = totalContainer; } /* * Getter and Setting method for Widgets Object Instance. */ private Vector _widgetLists = null; public void setWidgetObjectLists(Vector widgetObject) { _widgetLists = widgetObject; } public Vector getWidgetObjectLists() { return _widgetLists; } public void addWidgetObject(DataObject widgetObject) { if ( (_widgetLists != null) && (_widgetLists.size() > 0) ) this._widgetLists.add(widgetObject); else { _widgetLists = new Vector(); this._widgetLists.add(widgetObject); } } /// <summary> /// Getter and Setting method for Instance Variable. /// </summary> /// <summary> /// Method for generateObjectLists: /// A Virtual method that is being implemented (overrided) by the sub class. /// This will generate all the respective object related table fields and its corresponding values. /// </summary> public void generateObjectLists() { } /// <summary> /// Method for generateUpdateObjectLists: /// A Virtual method that is being implemented (Overrided) by the sub class. /// This will generate all the respective object related table fields and its corresponding values. /// </summary> public void generateUpdateObjectLists() { } /// <summary> /// Method for validateObject: /// A Virtual method that must be implemented by the sub class. /// This will validate the respective object. /// </summary> public ReturnObject validateObject() { ReturnObject xRetObject = new ReturnObject("0", "", null); xRetObject.setReturnCode("0"); xRetObject.setReturnMessage(""); xRetObject.setReturnObject(null); return xRetObject; } /// <summary> /// Overrided Constructor /// </summary> public Container(String containerName,String containerCode,Integer totalContainer) { super(); System.out.println("4444444444444444444444"); this.setContainerName(containerName); System.out.println("555555555555555555555"); this.setContainerCode(containerCode); System.out.println("666666666666666666666"); this.setTotalContainer(totalContainer); } }
Comment