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:eu.impress.repository.service.BedAvailabilityServiceImpl.java

@Override
public String getBedTypeAvailablityHAVE(String hospitalname) {
    String hospitalstatushave;// w  w w.j  av a  2 s .c  om
    List<eu.impress.repository.model.BedStats> bedStatsList = bedService
            .getHospitalAvailableBedTypes(hospitalname);
    HospitalStatus hospitalStatus = beansTransformation.BedTypesStatstoHAVE(bedStatsList);

    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(HospitalStatus.class);
        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();

        jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
        StringWriter sw = new StringWriter();
        jaxbMarshaller.marshal(hospitalStatus, sw);
        hospitalstatushave = sw.toString();

    } catch (JAXBException e) {
        e.printStackTrace();
        return "Error Marshalling XML Object";
    }

    return hospitalstatushave;

}

From source file:eu.impress.repository.service.BedAvailabilityServiceImpl.java

@Override
public String getBedAvailablityHAVE(String hospitalname) {

    String hospitalstatushave;//from  w w w. ja v  a  2s  . c  o m
    BedStats bedStats = bedService.getHospitalAvailableBeds(hospitalname);
    HospitalStatus hospitalStatus = beansTransformation.BedStatstoHAVE(bedStats);

    try {
        JAXBContext jaxbContext = JAXBContext.newInstance(HospitalStatus.class);
        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();

        //jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
        StringWriter sw = new StringWriter();
        //marshal the envelope 
        jaxbMarshaller.marshal(hospitalStatus, sw);
        hospitalstatushave = sw.toString();

    } catch (JAXBException e) {
        e.printStackTrace();
        return "Error Marshalling XML Object";
    }

    return hospitalstatushave;

}

From source file:com.photon.phresco.framework.actions.FrameworkBaseAction.java

protected List<String> getProjectModules(String projectCode) {
    try {/* w  ww .ja v a  2  s.com*/
        StringBuilder builder = getProjectHome(projectCode);
        builder.append(File.separatorChar);
        builder.append(POM_XML);
        File pomPath = new File(builder.toString());
        PomProcessor processor = new PomProcessor(pomPath);
        Modules pomModule = processor.getPomModule();
        if (pomModule != null) {
            return pomModule.getModule();
        }
    } catch (JAXBException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (PhrescoPomException e) {
        e.printStackTrace();
    }
    return null;
}

From source file:eu.impress.repository.service.BedAvailabilityServiceImpl.java

@Override
public String createBedAvailabilityDE() throws DatatypeConfigurationException {

    String DEmessageenvelope = "";
    String DEmessage = "";

    EDXLDistribution ed = EDXLlib.createEDXLEnvelope();

    try {/*from   w w  w.j a v  a  2 s  .c o  m*/
        JAXBContext jaxbContext = JAXBContext.newInstance(EDXLDistribution.class);
        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();

        //jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
        StringWriter sw = new StringWriter();
        //marshal the envelope 
        jaxbMarshaller.marshal(ed, sw);
        DEmessageenvelope = sw.toString();

        //could not unescape characters no matter what!
        //encapsulate the edxl have message into DE by avoiding jaxb 
        //DEmessage = EDXLlib.DEEncapsulation(DEmessageenvelope, edxlhave);
        DEmessage = DEmessageenvelope;

    } catch (JAXBException e) {
        e.printStackTrace();
        return "Error Marshalling XML Object";
    }

    return DEmessage;

}

From source file:eu.learnpad.cw.rest.internal.DefaultXWikiPackage.java

private void importPage(File pageFolder, String spaceName) throws XWikiRestException {
    String pageName = pageFolder.getName();
    if (!pageFolder.isDirectory()) {
        throw new XWikiRestException();
    }//  ww  w  . j a  v  a  2  s.c  o m
    try {
        File indexFile = new File(pageFolder.getPath() + "/index.xml");
        if (indexFile.isFile()) {
            putPage(indexFile, spaceName, pageName);
        }
        File objectsFolder = new File(pageFolder.getPath() + "/objects");
        if (objectsFolder.isDirectory()) {
            importObjects(objectsFolder, spaceName, pageName);
        }
    } catch (JAXBException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.photon.phresco.service.dependency.impl.AndroidDependencyProcessor.java

@Override
public void process(ProjectInfo info, File path) throws PhrescoException {
    if (isDebugEnabled) {
        S_LOGGER.debug("Entering Method AndroidDependencyProcessor.process(ProjectInfo info, File path)");
        S_LOGGER.debug("process() ProjectCode=" + info.getCode());
        S_LOGGER.debug("process() Path=" + path.getPath());
    }/*from w  w w  .  j  a  v a  2s.c  om*/
    Technology technology = info.getTechnology();
    // copy pilot projects
    if (StringUtils.isNotBlank(info.getPilotProjectName())) {
        List<ProjectInfo> pilotProjects = getRepositoryManager().getPilotProjects(technology.getId());
        if (CollectionUtils.isEmpty(pilotProjects)) {
            return;
        }
        for (ProjectInfo projectInfo : pilotProjects) {
            String urls[] = projectInfo.getPilotProjectUrls();
            if (urls != null) {
                for (String url : urls) {
                    DependencyUtils.extractFiles(url, path);
                }
            }
        }
    }
    updateAndroidVersion(path, info);
    try {
        List<ModuleGroup> modules = technology.getModules();
        if ((CollectionUtils.isNotEmpty(modules)) && modules != null) {
            updatePOMModules(path, modules);
        }
    } catch (JAXBException e) {
        e.printStackTrace();
    } catch (PhrescoPomException e) {
        e.printStackTrace();
    }
    AndroidTestPOMUpdater.updatePOM(path);
    if (technology.getId().equals(TechnologyTypes.ANDROID_HYBRID)) {
        extractJsLibraries(path, info.getTechnology().getJsLibraries());
    }
}

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

public void testJaxbFromContext() {
    System.out.println("start of test:testJaxbFromContext()");
    try {//  ww  w. j av a  2s  . c o m
        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());

        // see http://stackoverflow.com/questions/1043109/why-cant-jaxb-find-my-jaxb-index-when-running-inside-apache-felix
        // need to provide bundles class loader
        ClassLoader cl = org.opennms.features.vaadin.pmatrix.model.DataPointDefinition.class.getClassLoader();
        JAXBContext jaxbContext = JAXBContext.newInstance("org.opennms.features.vaadin.pmatrix.model", cl);

        //JAXBContext jaxbContext = JAXBContext.newInstance("org.opennms.features.vaadin.pmatrix.model");

        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");

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

        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_context, 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:testAppContext()");
}

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

public void testMarshalData() {
    System.out.println("start of test:testMarshalData()");

    // check slf4j settings
    LOG.debug("debug message");
    LOG.warn("warn message");
    LOG.info("info message");

    try {/*from w  w  w  .j a v a2  s  .  co m*/
        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.calculator");

        // *****************
        // create calculator
        // *****************
        PmatrixDpdCalculatorSimpleMovingAvgImpl simpleMovingAvgCalc = new PmatrixDpdCalculatorSimpleMovingAvgImpl();

        simpleMovingAvgCalc.setLatestDataValue(1010d);
        simpleMovingAvgCalc.setLatestTimestamp(new Date().getTime());
        simpleMovingAvgCalc.setPrevDataValue(3040d);
        simpleMovingAvgCalc.setPreviousTimestamp(new Date().getTime());

        NameValuePair property = new NameValuePair(
                PmatrixDpdCalculatorSimpleMovingAvgImpl.MAX_SAMPLE_NO_PROPERTY_NAME, "10");
        simpleMovingAvgCalc.getConfiguration().add(property);

        for (int i = 1; i < 15; i++) {
            Double latestDataValue = Double.valueOf(i);
            Long latestTimestamp = new Date().getTime() + i; // adding to show small increment in time
            simpleMovingAvgCalc.updateCalculation(latestDataValue, latestTimestamp);
        }

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

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

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

        jaxbMarshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION,
                "http://xmlns.opennms.org/xsd/config/pmatrix pmatrixConfig.xsd");

        jaxbMarshaller.marshal(simpleMovingAvgCalc, 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 PmatrixDpdCalculatorSimpleMovingAvgImpl) {
            System.out.println("unmarshalled list:");
            System.out.println((PmatrixDpdCalculatorSimpleMovingAvgImpl) o);
        } else
            System.out.println("cant unmarshal object:");

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

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

}

From source file:com.spend.spendService.SearchText.java

private SearchEngines getSearchEnginesFromXml() {
    try {//  w w  w.  j av  a 2 s . c  o  m
        File file = new File("SearchEngines.xml");
        JAXBContext jaxbContext = JAXBContext.newInstance(SearchEngines.class);
        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
        SearchEngines searchEngineList = (SearchEngines) jaxbUnmarshaller.unmarshal(file);
        return searchEngineList;
    } catch (JAXBException ex) {
        System.out.println("SearchText.java getSearchEnginesFromXml function ERROR " + ex.getMessage());
        ex.printStackTrace();
    }
    return null;
}

From source file:edu.harvard.i2b2.PdoEGtoFhirBundle.java

@Test
public void TestPatient() throws XQueryUtilException {

    String patientBundle = getPatients();
    logger.trace("getPatients:" + patientBundle);
    try {//  w  ww.j  av a2s  .c  om
        Bundle b = JAXBUtil.fromXml(patientBundle, Bundle.class);
        logger.trace(JAXBUtil.toXml(b.getEntry().get(0).getResource().getPatient()));
    } catch (JAXBException e) {
        e.printStackTrace();
    }

}