XML : JaxbContext in loop

Well my question is about the next problem I have creating a XML file with Jaxb, well now i need to extract some information from a document and for it i have to use a For (loop), so in the next code example Im trying to applicate in my Jaxb scheme but I have the next problem:

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: at xmlcontent.Xmlcontent.main(Xmlcontent.java:184) Java Result: 1

and my code is the next:

  package xmlcontent;    import java.io.File;  import java.time.LocalDate;  import java.time.Month;  import java.util.ArrayList;  import java.util.List;    import javax.xml.bind.JAXBContext;  import javax.xml.bind.JAXBException;  import javax.xml.bind.Marshaller;  import javax.xml.bind.annotation.*;    public class Xmlcontent {                       public static void main(String[] args) throws JAXBException {        for(int s=0;s<=10;s++){                PointInfoA pointinfoa = new PointInfoA();      pointinfoa.setNename("");      pointinfoa.setObjecttype("");      pointinfoa.setPortid("");      pointinfoa.setTpid("");        TPIDa tpida = new TPIDa();      tpida.setEida("Somos el mismo EIDA");        RoutePointA routepointa = new RoutePointA();      routepointa.setBorderCrossMode("");      routepointa.setTerminationMode("");      routepointa.setResilience("");      routepointa.setIsRequiredWorker("");      routepointa.setBandwidth("");      routepointa.setTPIndexA("");      routepointa.setTPIDa(tpida);      routepointa.setPointInfoA(pointinfoa);               NonTerminatedLayers nonterminatedlayers = new NonTerminatedLayers();      nonterminatedlayers.setNonLayer("RS64"); // Puede variar con respecto a los querys                LayerSet layerset = new LayerSet();      layerset.setNonTerminatedLayers(nonterminatedlayers);                     Gui gui = new Gui();      gui.setClientcontainerid("");      gui.setClientcontainertype("");      gui.setIsreversed("");        RefObjectID refobjectid = new RefObjectID();      refobjectid.setEid("");        Item item = new Item();      item.setType("");      item.setDirection("");      item.setConnectivity("");      item.setReqCreationState("");      item.setIsWorkerEdge("");      item.setIsExpansion("");      item.setNxCount("");      item.setFragmentLayer("");      item.setRefObjectID(refobjectid);      item.setRoutePointA(routepointa);      item.setLayerSet(layerset);      item.setGui(gui);        Route route = new Route();      route.setItem(item);          //--------------- Campos de Topology ------------------------       PointInfoZ pointinfoz = new PointInfoZ();      pointinfoz.setNename("");      pointinfoz.setObjecttype("");      pointinfoz.setPortid("");      pointinfoz.setTpid("");        ParentIDZ parentidz = new ParentIDZ();      parentidz.setEidz("Somos el mismo EIDZ");        TPIDz tpidz = new TPIDz();      tpidz.setEidz("Somos el mismo EIDZ");        RoutePointZ routepointz = new RoutePointZ();      routepointz.setBorderCrossMode("");      routepointz.setTerminationMode("");      routepointz.setResilience("");      routepointz.setIsRequiredWorker("");      routepointz.setBandwidth("");      routepointz.setTPIndexZ("");      routepointz.setTPIDz(tpidz);      routepointz.setParentIDZ(parentidz);          routepointz.setPointInfoZ(pointinfoz);        ParentIDA parentida = new ParentIDA();      parentida.setEida("Somos el mismo EIDA");        routepointa.setParentIDA(parentida);        Edge edge = new Edge();      edge.setLayerSet(layerset);      edge.setDirection("");      edge.setConnectionClass("");      edge.setNxCount("");      edge.setFragmentLayer("");      edge.setRoutePointA(routepointa);      edge.setRoutePointZ(routepointz);        Edges edges = new Edges();       edges.setEdge(edge);                Topology topology = new Topology();      topology.setConnectionType("");      topology.setConnectionClass("");      topology.setDirection("");      topology.setNxCount("");      topology.setFragmentLayer("");      topology.setIsBandWidthReq("");      topology.setBandwidth("");      topology.setLayerSet(layerset);      topology.setEdges(edges);                     //--------------- Campos de Info ------------------------       Activation activation = new Activation();      activation.setIsOn("false"); //Constante      activation.setDateAndTime("Once"); //Constante                Deactivation deactivation = new Deactivation();      deactivation.setIsOn("false"); //Constante      deactivation.setDateAndTime("Once"); //Constante                Scheduling scheduling = new Scheduling();      scheduling.setIsOn("false"); //Constante      scheduling.setPeriod("Once"); //Constante      scheduling.setDeactivation(deactivation);      scheduling.setActivation(activation);                ServiceID serviceid = new ServiceID();      serviceid.setEID("Svc: subscriberprueba 232132_PAST_POPA_STM64"); //Puede variar con respecto a los querys                  Info info = new Info();          info.setName( "232132_PAST_POPA_STM64" ); //Puede variar con respecto a los querys      info.setReqCreationState( "Unknown" ); //Constante      info.setTopologyReadOnly("false"); //Constante      info.setIsWriteProtected("false");      info.setCorrelationMode("Endpoint");      info.setEventMask("EnableSecondaryAlarmsAtEndpoints");      info.setExplAdminState("Unlocked");      info.setImplAdminState("Unlocked");      info.setAllowImplicitDeletion("true");      info.setAllowImplicitUnmanage("false");      info.setGUISuppression("false");      info.setClassOfService("Default");      info.setServiceID(serviceid);      info.setScheduling(scheduling);      //----------------------------------------------------------------------------------------------------------              TPath tpath = new TPath();      tpath.setInfo(info);      tpath.setTopology(topology);      tpath.setRoute(route);                        TPaths tpaths = new TPaths();      tpaths.setTPath( tpath );                    //---------------------------------------------------------------------------------------------------------                  }            // Creo el Root del XML      TNMSData tnmsdata = new TNMSData();      tnmsdata.setXmlns("http://www.ossnms.com/tnms");      //Agrego al Root el primer child en el XML      tnmsdata.setTPaths( tpaths );                        // conseguir la instancia de JAXBContext basado en la clase root      JAXBContext context = JAXBContext.newInstance( TNMSData.class );                            // marshall hacia XML via System.out y creación XML      Marshaller marshaller = context.createMarshaller();      marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, true );      marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "http://www.ossnms.com/tnms TnmsV1.xsd");      marshaller.marshal( tnmsdata, System.out );      marshaller.marshal( tnmsdata, new File( "TNMSData.xml" ) );                        }        }  

I know my problem is with the "tpaths" object, but how I can fix the code to have the info correct.

Thanks

No comments:

Post a Comment