Example usage for javax.xml.bind JAXBException printStackTrace

List of usage examples for javax.xml.bind JAXBException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.bind JAXBException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this JAXBException and its stack trace (including the stack trace of the linkedException if it is non-null) to System.err .

Usage

From source file:fr.fastconnect.factory.tibco.bw.maven.compile.ArchiveBuilder.java

public void save(File f) {
    try {//from   w  ww  . ja va  2 s. c o m
        JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
        Marshaller m = jaxbContext.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        m.marshal(this.repository, f);
    } catch (JAXBException e) {
        e.printStackTrace();
    }
}

From source file:fr.fastconnect.factory.tibco.bw.maven.compile.ArchiveBuilder.java

private Repository load(File f) {
    try {// ww w . ja va 2  s. c  o m
        JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
        Object o = jaxbUnmarshaller.unmarshal(f);
        return (Repository) o;
    } catch (JAXBException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:it.cnr.icar.eric.client.xml.registry.DeclarativeQueryManagerImpl.java

public BulkResponse executeQuery(Query query, Map<String, String> queryParams,
        IterativeQueryParams iterativeParams) throws JAXRException {
    BulkResponse bresp = null;/*from  www  .jav a2  s.  c  o m*/

    try {
        if (query == null) {
            throw new NullPointerException("query is null");
        }

        AdhocQueryRequest ebAdhocQueryRequest = ((QueryImpl) query).toBindingObject();
        ClientRequestContext context = new ClientRequestContext(
                "it.cnr.icar.eric.client.xml.registry.DeclarativeQueryManagerImpl:executeQuery",
                ebAdhocQueryRequest);
        bresp = executeQuery(context, queryParams, iterativeParams);
    } catch (JAXBException ex) {
        ex.printStackTrace();
    }
    return bresp;
}

From source file:com.mc.printer.model.panel.task.BuildModelTask.java

@Override
public Object doBackgrounp() {
    javax.swing.JTabbedPane tabs = AutoPrinterApp.getMainView().getMainWorkPanel();
    if (tabs != null) {
        if (tabs.getSelectedIndex() >= 0) {
            Component selectedcom = tabs.getSelectedComponent();
            if (selectedcom instanceof CanvasWork) {
                CanvasWork selectPanel = (CanvasWork) selectedcom;
                FormBeans beansForm = selectPanel.getBeansForm();

                /**/
                if (beansForm.getHeightcm() == 0 || beansForm.getWidthcm() == 0) {
                    int res = BaseMessage.CONFIRM(
                            "?\r\nA4.");
                    if (res != JOptionPane.OK_OPTION) {
                        return null;
                    }// w w  w .j  a v  a  2  s  .c  om
                }

                String imagePath = beansForm.getImgpath();
                HashMap<String, ComponentBean> parameterMap = selectPanel.getSavedForms();
                if (parameterMap.size() > 0) {
                    Set set = parameterMap.keySet();
                    boolean foundKey = false;
                    //???
                    List<ComponentBean> beans = new ArrayList();
                    Iterator it = set.iterator();
                    while (it.hasNext()) {
                        ComponentBean com = parameterMap.get(it.next().toString());
                        beans.add(com);
                        if (com.isIskey()) {
                            foundKey = true;
                        }
                    }
                    beansForm.setElements(beans);
                    //
                    //                        if (!foundKey) {
                    //                            BaseMessage.ERROR("PRIMARY KEY.");
                    //                            return null;
                    //                        }

                    BaseFileChoose fileChoose = new BaseFileChoose("?",
                            new String[] { Constants.MODEL_SUFFIX }, AutoPrinterApp.getMainFrame());
                    String selectedPath = fileChoose.showSaveDialog();
                    if (!selectedPath.trim().equals("")) {

                        //get formname
                        selectedPath = selectedPath + File.separator + beansForm.getFormname();
                        //String time=DateHelper.format(new Date(), "yyyyMMddHHmmss");
                        String finalZip = selectedPath;
                        if (!selectedPath.endsWith("." + Constants.MODEL_SUFFIX)) {
                            finalZip = selectedPath + "." + Constants.MODEL_SUFFIX;
                        }

                        String tempDir = selectedPath + File.separator + Constants.MODEL_TEMP_DIR;

                        File imageFile = new File(imagePath);

                        String xmlPath = tempDir + File.separator + imageFile.getName() + ".xml";
                        XMLHelper helper = new XMLHelper(xmlPath, beansForm);
                        try {
                            helper.write();
                        } catch (JAXBException ex) {
                            ex.printStackTrace();
                            logger.error(ex.getMessage());
                            return ex;
                        }

                        File paramFile = new File(xmlPath);
                        if (paramFile.isFile() && paramFile.exists()) {
                            try {
                                FileUtils.copyFileToDirectory(imageFile, new File(tempDir));
                                ZipHelper.createZip(tempDir, finalZip);
                                return "??.\r\n" + finalZip;
                            } catch (IOException ex) {
                                ex.printStackTrace();
                                logger.error(ex.getMessage());
                                return ex;
                            } finally {
                                try {
                                    FileUtils.deleteDirectory(new File(selectedPath));
                                } catch (IOException ex) {
                                    ex.printStackTrace();
                                    logger.error(ex.getMessage());
                                    return ex;
                                }
                            }
                        }
                    }
                } else {
                    return "??.";
                }
            } else {
                return "??????.";
            }
        } else {
            return ".";
        }
    } else {
        return ".";
    }
    return null;
}

From source file:alter.vitro.vgw.service.query.wrappers.ResponseAggrMsg.java

public String toString() {
    String retStr = "";
    try {//from  w  ww  .ja v a 2 s. co m
        javax.xml.bind.JAXBContext jaxbContext = javax.xml.bind.JAXBContext
                .newInstance("alter.vitro.vgw.service.query.xmlmessages.response");
        ObjectFactory theFactory = new ObjectFactory();
        javax.xml.bind.Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        JAXBElement<QueryResponseType> myAggrResponseMsgEl = theFactory.createQueryResponse(response);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        marshaller.marshal(myAggrResponseMsgEl, baos);
        //            marshaller.marshal(myAggrResponseMsgEl, new java.io.FileOutputStream("ResponseTest.xml"));
        retStr = baos.toString(HTTP.UTF_8);

    } catch (javax.xml.bind.JAXBException je) {
        je.printStackTrace();
    } catch (UnsupportedEncodingException e2) {
        e2.printStackTrace();
    }
    return retStr;
}

From source file:org.opennms.features.vaadin.pmatrix.manual.ManualSpecificationMarshalTest.java

public void testJaxbManual() {
    System.out.println("start of test:testJaxb()");
    try {//from w  w w . jav  a  2s. c  om
        String testFileName = this.getClass().getSimpleName() + "_File.xml";
        File file = new File("target/" + testFileName);
        PrintWriter writer = new PrintWriter(file, "UTF-8");
        writer.close();
        System.out.println("file location:" + file.getAbsolutePath());

        JAXBContext jaxbContext = JAXBContext.newInstance("org.opennms.features.vaadin.pmatrix.model");
        // TODO these classes are listed in jaxb.index file
        //         JAXBContext jaxbContext = JAXBContext.newInstance(               
        //               PmatrixSpecificationImpl.class,
        //               DataPointDefinitionImpl.class,
        //               PmatrixSpecificationListImpl.class,
        //               NameValuePair.class,
        //               PmatrixDpdCalculatorConfigImpl.class);

        // **********************
        // marshal test file
        // **********************

        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
        jaxbMarshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");

        // output pretty printed
        jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

        //PmatrixSpecificationList pmatrixSpecificationList_context = (PmatrixSpecificationList) appContext.getBean("pmatrixSpecificationList");
        //PmatrixSpecification pmatrixSpec_Context = (PmatrixSpecification) appContext.getBean("pmatrixSpecification");

        // manual create process
        PmatrixSpecificationImpl newspec1 = createNewSpecification();
        newspec1.setPmatrixName("spec1");
        PmatrixSpecificationImpl newspec2 = createNewSpecification();
        newspec2.setPmatrixName("spec2");

        //create new specfication list
        PmatrixSpecificationListImpl pmatrixSpecificationList = new PmatrixSpecificationListImpl();
        pmatrixSpecificationList.setRefreshRate(1000);

        //create and add new DpdCalculator specification
        PmatrixDpdCalculatorConfig pmatrixDpdCalculatorConfig = new PmatrixDpdCalculatorConfigImpl();
        pmatrixDpdCalculatorConfig
                .setPmatrixDpdCalculatorClassName(PmatrixDpdCalculatorEmaImpl.class.getName());

        List<NameValuePair> configuration = new ArrayList<NameValuePair>();
        configuration.add(new NameValuePair("file", "fred.txt"));
        pmatrixDpdCalculatorConfig.setConfiguration(configuration);

        pmatrixSpecificationList.setPmatrixDpdCalculatorConfig(pmatrixDpdCalculatorConfig);

        //add specifications of each matrix
        List<PmatrixSpecification> pmsl = new ArrayList<PmatrixSpecification>();

        pmsl.add(newspec1);
        pmsl.add(newspec2);
        pmatrixSpecificationList.setPmatrixSpecificationList(pmsl);

        //System.out.println("list to be marshalled:");
        System.out.println(pmatrixSpecificationList);

        System.out.println("marshalled list:");
        //jaxbMarshaller.marshal(testDatalist, file);

        //jaxbMarshaller.marshal(pmatrixSpec, System.out); // works
        //jaxbMarshaller.marshal(pmatrixSpecificationList, System.out); //works

        //test of marshaling context data
        //jaxbMarshaller.marshal(pmatrixSpecificationList_context, System.out);
        jaxbMarshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
                "http://xmlns.opennms.org/xsd/config/pmatrix pmatrixConfig.xsd");

        jaxbMarshaller.marshal(pmatrixSpecificationList, file);
        //jaxbMarshaller.marshal(pmatrixSpecificationList_context, file);

        // **********************
        // unmarshal test file
        // **********************

        Unmarshaller jaxbUnMarshaller = jaxbContext.createUnmarshaller();

        //Object o = jaxbUnMarshaller.unmarshal( new StringReader( marshalledXml )  );

        Object o = jaxbUnMarshaller.unmarshal(file);

        System.out.println("o.tostring:" + o.toString());
        if (o instanceof PmatrixSpecificationList) {
            System.out.println("unmarshalled list:");
            System.out.println((PmatrixSpecificationList) o);
        } else
            System.out.println("cant unmarshal object:");

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

    System.out.println("end of test:testJaxb()");
}

From source file:demo.jaxrs.server.CustomerServiceImpl.java

public Customer getCustomer1(String id) {
    System.out.println("----invoking getCustomer, Customer id is: " + id);
    long idNumber = Long.parseLong(id);
    Customer c = customers.get(idNumber);
    Customer c1;// w  w w  .  j av  a  2s  .  com
    JAXBContext ctx;
    try {
        ctx = JAXBContext.newInstance(Customer.class);
        StringWriter writer = new StringWriter();
        ctx.createMarshaller().marshal(c, writer);
        String custString = writer.toString();
        c1 = (Customer) ctx.createUnmarshaller().unmarshal(new StringReader(custString));
    } catch (JAXBException e) {
        e.printStackTrace();
    }
    return c;
}

From source file:alter.vitro.vgw.service.query.wrappers.ResponseAggrMsg.java

/**
 * Constructor method.//  www . j a  v a 2  s .  c o  m
 * Creates a new instance of ResponseAggrMsg
 *
 * @param queryDefID      The unique ID for the query definition that this response belongs to. This is different from the queryId of the JXTA message that this
 *                        message replies to.
 * @param responderName   The Name of the peer that sends this response.
 * @param responderPeerID The jxta unique Peer ID of the peer that sends this response.
 * @param allValuesVec    A vector of ReqResultOverData objects, that contain results for a requested Function.
 * @param qCount          the query count of the JXTA message that this response replies to.
 */
public ResponseAggrMsg(String queryDefID, String responderPeerID, String responderName,
        Vector<ReqResultOverData> allValuesVec, int qCount) {
    try {
        javax.xml.bind.JAXBContext jaxbContext = javax.xml.bind.JAXBContext
                .newInstance("alter.vitro.vgw.service.query.xmlmessages.response");
        // create an object to marshal
        ObjectFactory theFactory = new ObjectFactory();
        response = theFactory.createQueryResponseType();
    } catch (javax.xml.bind.JAXBException je) {
        je.printStackTrace();
        response = new QueryResponseType();
    }
    setDeployStatus(DEPLOY_STATUS_SERVICE_UNKNOWN);

    response.setQueryDefID(queryDefID);
    response.setResponderPeerID(responderPeerID);
    response.setResponderName(responderName);
    response.setQueryCount(Integer.toString(qCount));
    response.setMessageType(ResponseAggrMsg.getThisMsgType());
    RespFunctionsListType rflType = new RespFunctionsListType();
    response.setReqFunctionsList(rflType);
    //
    //RespFunctionsListType rflType = response.getReqFunctionsList();
    List<RespFunctionType> rfList = rflType.getReqFunction();
    // For every function in the Vector create a ReqResultOverData with all data values "timed out" for the sensors defined here!
    for (int i = 0; i < allValuesVec.size(); i++) {
        rfList.add(allValuesVec.elementAt(i));
    }
    response.setReqFunctionsList(rflType);

    ServContinuationListType servContListType = new ServContinuationListType();
    response.setServContList(servContListType);
    List<ServContReplcItemType> pListOfReplcItems = servContListType.getServContReplcItem();
    // for (int i = 0; i < allReplceStructVec.size(); i++) {
    //    pListOfReplcItems.add(allReplceStructVec.elementAt(i));
    //}
}

From source file:alter.vitro.vgw.service.query.wrappers.ResponseAggrMsg.java

/**
 * Constructor method.//from w  w  w .j a va 2s. c  om
 * Creates a new instance of ResponseAggrMsg with timed-out entries for all sensors defined and all functions
 *
 * @param queryDefID                    The unique ID for the query definition that this response belongs to. This is different from the queryId of the JXTA message that this
 *                                      message replies to.
 * @param responderName                 The Name of the peer that sends this response.
 * @param responderPeerID               The jxta unique Peer ID of the peer that sends this response.
 * @param motesSensorsAndFunctionsForQueryVec The map that defines the querried sensors, indexed by the motes that have them
 * @param functionVec                   the vector of selected functions to be applied
 * @param qCount                        the query count of the JXTA message that this response replies to.
 */
public ResponseAggrMsg(String queryDefID, String responderPeerID, String responderName,
        Vector<QueriedMoteAndSensors> motesSensorsAndFunctionsForQueryVec,
        Vector<ReqFunctionOverData> functionVec, int qCount) {
    try {
        javax.xml.bind.JAXBContext jaxbContext = javax.xml.bind.JAXBContext
                .newInstance("alter.vitro.vgw.service.query.xmlmessages.response");
        // create an object to marshal
        ObjectFactory theFactory = new ObjectFactory();
        response = theFactory.createQueryResponseType();
    } catch (javax.xml.bind.JAXBException je) {
        je.printStackTrace();
        response = new QueryResponseType();
    }
    setDeployStatus(DEPLOY_STATUS_SERVICE_UNKNOWN);

    response.setQueryDefID(queryDefID);
    response.setResponderPeerID(responderPeerID);
    response.setResponderName(responderName);
    response.setQueryCount(Integer.toString(qCount));
    response.setMessageType(ResponseAggrMsg.getThisMsgType());
    RespFunctionsListType rflType = new RespFunctionsListType();
    response.setReqFunctionsList(rflType);
    //
    //RespFunctionsListType rflType = response.getReqFunctionsList();
    List<RespFunctionType> rfList = rflType.getReqFunction();
    // For every function in the Vector create a ReqResultOverData with all data values "timed out" for the sensors defined here!
    for (int i = 0; i < functionVec.size(); i++) {
        rfList.add(new ReqResultOverData(functionVec.elementAt(i).getfuncId(),
                motesSensorsAndFunctionsForQueryVec, ReqResultOverData.modeFillWithTimeouts));
    }
    response.setReqFunctionsList(rflType); // probably redundant

    ServContinuationListType servContListType = new ServContinuationListType();
    response.setServContList(servContListType);
    List<ServContReplcItemType> pListOfReplcItems = servContListType.getServContReplcItem();
    // for (int i = 0; i < allReplceStructVec.size(); i++) {
    //    pListOfReplcItems.add(allReplceStructVec.elementAt(i));
    //}

}

From source file:org.megam.deccanplato.provider.zoho.crm.handler.EventImpl.java

/**
 * this method creates an Event in zoho.com and returns that Event id.
 * and it uses the business support class Events to populate ZOHO XML input
 * This method takes input as a MAP(contains json dada) and returns a MAP.
 * @param outMap /*from   w  ww  .j ava2 s  .  c o  m*/
 */
private Map<String, String> create(Map<String, String> outMap) {

    Events events = new Events();
    events.setStart_DateTime(args.get(START_DATE_TIME));
    events.setEnd_DateTime(args.get(END_DATE_TIME));
    events.setSubject(args.get(SUBJECT));
    events.setVenue(args.get(VENUE));
    String xmlout = null;
    try {
        xmlout = events.toXMLString();
    } catch (JAXBException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    List<NameValuePair> eventAttrList = new ArrayList<NameValuePair>();
    eventAttrList.add(new BasicNameValuePair(OAUTH_TOKEN, args.get(AUTHTOKEN)));
    eventAttrList.add(new BasicNameValuePair(ZOHO_SCOPE, SCOPE));
    eventAttrList.add(new BasicNameValuePair(ZOHO_XMLDATA, xmlout));

    TransportTools tst = new TransportTools(ZOHO_CRM_EVENT_XML_URL + INSERT_RECORDS, eventAttrList);
    String responseBody = null;

    TransportResponse response = null;

    try {
        response = TransportMachinery.post(tst);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    responseBody = response.entityToString();

    outMap.put(OUTPUT, responseBody);
    return outMap;
}