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:org.opencds.service.evaluate.UnmarshalVMRSchemaPayload2VMR.java

@Override
public synchronized JAXBElement<org.opencds.vmr.v1_0.schema.CDSInput> mappingInbound(String payloadString,
        Date evalTime, TimingData timingData) throws InvalidDriDataFormatExceptionFault,
        UnrecognizedLanguageExceptionFault, RequiredDataNotProvidedExceptionFault,
        UnsupportedLanguageExceptionFault, UnrecognizedScopedEntityExceptionFault, EvaluationExceptionFault,
        InvalidTimeZoneOffsetExceptionFault, DSSRuntimeExceptionFault {

    // this begins the guts for building fact lists for input data based on one particular fact model (opencds-vmr-1_0)         
    log.debug("starting UnmarshalVMRSchemaPayload2VMR");
    JAXBElement<org.opencds.vmr.v1_0.schema.CDSInput> cdsInput = null;
    StreamSource payloadStream = new StreamSource(fileU.getInputStreamFromString(payloadString));

    try {//from w  w w  .  ja v  a 2 s  . c om
        Unmarshaller unmarshaller = SimpleKnowledgeRepository
                .getRequiredUnmarshallerInstanceForUnmarshallerClassCache("org.opencds.vmr^VMR^1.0");
        cdsInput = unmarshaller.unmarshal(payloadStream, org.opencds.vmr.v1_0.schema.CDSInput.class);

    } catch (JAXBException e) {
        String jaxBError = e.getLinkedException().fillInStackTrace().getMessage();
        e.printStackTrace();
        throw new InvalidDriDataFormatExceptionFault(jaxBError
                + ", therefore unable to unmarshal input Semantic Payload xml string: " + payloadString);
    }

    log.debug("finished UnmarshalVMRSchemaPayload2VMR");

    return cdsInput;
}

From source file:org.openhab.binding.smarthomatic.internal.SmarthomaticBinding.java

/**
 * activate binding//from  w  w  w  .  j  a  v  a 2s.com
 *
 */
@Override
public void activate() {
    // log activate of binding
    if (baseStation != null) {
        logger.info("Smarthomatic Binding activated. BaseStation= {}", baseStation.toString());
    }

    Bundle bundle = SmarthomaticActivator.getContext().getBundle();
    URL fileURL = bundle.getEntry("packet_layout.xml");
    Packet packet = null;
    try {
        InputStream inputStream = fileURL.openConnection().getInputStream();
        JAXBContext jaxbContext = JAXBContext.newInstance(Packet.class);

        Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
        packet = (Packet) jaxbUnmarshaller.unmarshal(inputStream);
    } catch (IOException e1) {
        e1.printStackTrace();
    } catch (JAXBException e) {
        e.printStackTrace();
    }
    this.packet = packet;
}

From source file:org.opf_labs.fmts.fidget.SigGenCommand.java

/**
 * @param args//ww  w .j a va2 s . co  m
 * @throws MimeTypeException
 * @throws IOException
 */
@SuppressWarnings("static-access")
public static void main(String[] args) throws MimeTypeException, IOException {
    // create the command line parser
    CommandLineParser parser = new PosixParser();

    // create the Options
    Options options = new Options();
    // Main option, setting the signature file
    options.addOption(OptionBuilder.withLongOpt("sig-file").withDescription("use this mime-info signature file")
            .hasArg().withArgName("FILE").create("s"));
    // 
    options.addOption("A", "alone", false,
            "use only the supplied signature file, do not load the embedded ones");
    options.addOption("C", "convert-to-droid", false, "convert supplied signature file into DROID form");
    options.addOption("l", "list", false, "list all known types.");
    options.addOption("?", "help", false, "print help message");

    if (args.length == 0) {
        System.err.println("No identification test file found!");
        printHelp(options);
        return;
    }

    try {
        // parse the command line arguments
        CommandLine line = parser.parse(options, args);

        // validate that sig-file has been set
        String sigfile = null;
        if (line.hasOption("sig-file")) {
            // print the value of sig-file
            sigfile = line.getOptionValue("sig-file");
        }

        // Check mode:
        if (line.hasOption("?")) {
            printHelp(options);

        } else if (line.hasOption("C")) {
            // Convert mode:
            if (sigfile == null) {
                System.err.println("No signature file argument found!");
                return;
            }
            System.out.println("Generate DROID signature...");
            MimeInfo mi = null;
            FileInputStream sigStr = new FileInputStream(sigfile);
            try {
                mi = MimeInfoUtils.parser(sigStr);
            } catch (JAXBException e) {
                e.printStackTrace();
                return;
            } finally {
                sigStr.close();
            }
            SigDefSubmission sigdef = MimeInfoUtils.toDroidSigDef(mi);
            // TODO Make is possible to print out the signature submission definition?
            // This just creates a submission template, but we could output a PRONOM record too.
            PRONOMSigGenerator.generatePRONOMSigFile(sigdef);
        } else if (line.hasOption("l")) {
            // Set up Tika:
            TikaSigTester tst = SigGenCommand.tikaStarter(sigfile, line.hasOption("A"));
            TikaSigTester.printTypes(tst);

        } else {
            // Set up Tika:
            TikaSigTester tst = SigGenCommand.tikaStarter(sigfile, line.hasOption("A"));
            // Return result:
            System.out.println("" + tst.identify(new File("" + line.getArgList().get(0))));
            return;
        }
    } catch (ParseException exp) {
        System.out.println("Unexpected exception:" + exp.getMessage() + "\n");
        printHelp(options);
    }
}

From source file:org.osate.atsv.integration.preparser.EngineConfigGenerator.java

public EngineConfigGenerator() {
    try {/*from  w ww. ja  va 2 s.c o m*/
        JAXBContext context = JAXBContext.newInstance(ExplorationEngineModel.class, InputTokenModel.class,
                VariableModel.class);
        InputTokenAdapter inputAdapter = new InputTokenAdapter();
        VariableModelAdapter variableAdapter = new VariableModelAdapter();

        marshal = context.createMarshaller();
        // ATSV actually cannot parse formatted output :(
        marshal.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
        marshal.setAdapter(inputAdapter);
        marshal.setAdapter(variableAdapter);

        eem = new ExplorationEngineModel();
        cfg = new JAXBElement<ExplorationEngineModel>(new QName("ExplorationEngineModel"),
                ExplorationEngineModel.class, eem);
    } catch (JAXBException e) {
        e.printStackTrace();
    }

}

From source file:org.osate.atsv.integration.preparser.EngineConfigGenerator.java

private void generateOutputFile() {
    try {//from   www . ja  v  a  2s.c  o  m
        getStartingOutputs().writeToFile(targetDirStr + "output.xml");
    } catch (JAXBException e) {
        e.printStackTrace();
    }
}

From source file:org.osate.atsv.integration.preparser.EngineConfigGenerator.java

private void generateInputFile() {
    try {/*  w ww .  j  av a2s .co m*/
        ATSVVarCollection inputs = getStartingInputs();
        Map<String, ATSVVar> inputVars = inputs.getVars();
        Set<String> convertedVarNames = eem.getConvertedConfiguratorNames();
        convertedVarNames.retainAll(inputVars.keySet());
        for (String varName : convertedVarNames) {
            inputs.addVar(varName, ATSVVariableType.DISCRETE_FLOAT,
                    ATSVVariableType.getDefaultFromType(ATSVVariableType.DISCRETE_FLOAT));
        }
        inputs.writeToFile(targetDirStr + "input.xml");
    } catch (JAXBException e) {
        e.printStackTrace();
    }
}

From source file:org.pentaho.di.www.MasterDetector.java

private MasterDetector() {
    JAXBContext context = null;//  w  w w. j  a  v a  2s . co  m
    try {
        context = JAXBContext.newInstance(JaxbList.class, DatabaseConnection.class);
    } catch (JAXBException e) {
        e.printStackTrace();
    } finally {
        jaxbContext = context;
    }

    this.initialDelay = Const.toLong(EnvUtil.getSystemProperty(PROP_INITIAL_DELAY), DEFAULT_INITIAL_DELAY);
    this.refreshInterval = Const.toLong(EnvUtil.getSystemProperty(PROP_REFRESH_INTERVAL),
            DEFAULT_REFRESH_INTERVAL);
}

From source file:org.pmedv.blackboard.IOUtils.java

/**
 * Updates the {@link RecentFileList} with a new file
 * //from w w w .  j a  v a 2 s.co  m
 * @param filename the name to append to the list
 */
public static void updateRecentFiles(String filename) {
    RecentFileList fileList = null;
    try {
        String inputDir = System.getProperty("user.home") + "/." + AppContext.getName() + "/";
        String inputFileName = "recentFiles.xml";
        File inputFile = new File(inputDir + inputFileName);
        if (inputFile.exists()) {
            Unmarshaller u = JAXBContext.newInstance(RecentFileList.class).createUnmarshaller();
            fileList = (RecentFileList) u.unmarshal(inputFile);
        }
        if (fileList == null)
            fileList = new RecentFileList();
    } catch (JAXBException e) {
        e.printStackTrace();
    }
    int numRecentFiles = (Integer) Preferences.values
            .get("org.pmedv.blackboard.BoardDesignerPerspective.maxRecentFiles");
    if (fileList.getRecentFiles().size() >= numRecentFiles + 1) {
        fileList.getRecentFiles().remove(0);
    }
    if (!fileList.getRecentFiles().contains(filename))
        fileList.getRecentFiles().add(filename);
    Marshaller m;
    try {
        String outputDir = System.getProperty("user.home") + "/." + AppContext.getName() + "/";
        String outputFileName = "recentFiles.xml";
        m = JAXBContext.newInstance(RecentFileList.class).createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        File output = new File(outputDir + outputFileName);
        m.marshal(fileList, output);
    } catch (JAXBException e) {
        e.printStackTrace();
    }
}

From source file:org.pmedv.blackboard.provider.AbstractElementProvider.java

public AbstractElementProvider(Class<?> clazz, String elementsBaseDir) {

    elements = new ArrayList<T>();

    try {//  ww w  . j  ava 2  s . c  om
        marshaller = JAXBContext.newInstance(clazz).createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    } catch (JAXBException e) {
        e.printStackTrace();
        throw new RuntimeException("Unable to create marshaller for " + clazz);
    }

    try {
        unmarshaller = JAXBContext.newInstance(clazz).createUnmarshaller();
    } catch (JAXBException e) {
        throw new RuntimeException("Unable to create unmarshaller for " + clazz);
    }

    this.elementsDirName = elementsBaseDir;
    final File workDir = new File(".");
    log.info("Working directory " + workDir.getAbsolutePath());

    elementsXmlDir = new File(System.getProperty("user.home"),
            "." + AppContext.getName() + "/" + elementsDirName + "/");

    if (!elementsXmlDir.exists()) {
        throw new RuntimeException(elementsXmlDir.getAbsolutePath() + " does not exist.");
    }
}

From source file:org.pmedv.blackboard.tools.PartFactory.java

public void init() {
    try {/* w  ww .  j  a  v  a2 s . co  m*/
        partUnmarshaller = JAXBContext.newInstance(Part.class).createUnmarshaller();
    } catch (JAXBException e) {
        throw new RuntimeException("Unable to create unmarshaller for part.");
    }
    try {
        partMarshaller = JAXBContext.newInstance(Part.class).createMarshaller();
        partMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    } catch (JAXBException e1) {
        throw new RuntimeException("Unable to create marshaller for part.");
    }
    try {
        getAvailableParts();
    } catch (Exception e) {
        e.printStackTrace();
    }
}