Java Code Examples for javax.xml.bind.JAXBException#getCause()
The following examples show how to use
javax.xml.bind.JAXBException#getCause() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: T2FlowReader.java From incubator-taverna-language with Apache License 2.0 | 6 votes |
@Override public WorkflowBundle readBundle(File bundleFile, String mediaType) throws ReaderException, IOException { try { WorkflowBundle bundle = getParser().parseT2Flow(bundleFile); scufl2Tools.setParents(bundle); preserveOriginal(bundle, new FileInputStream(bundleFile)); return bundle; } catch (JAXBException e) { if (e.getCause() instanceof IOException) { IOException ioException = (IOException) e.getCause(); throw ioException; } throw new ReaderException("Can't parse t2flow " + bundleFile, e); } }
Example 2
Source File: AbstractJAXBProvider.java From cxf with Apache License 2.0 | 6 votes |
protected void handleJAXBException(JAXBException e, boolean read) { StringBuilder sb = handleExceptionStart(e); Throwable linked = e.getLinkedException(); if (linked != null && linked.getMessage() != null) { Throwable cause = linked; while (read && cause != null) { if (cause instanceof XMLStreamException && cause.getMessage().startsWith("Maximum Number")) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); } if (cause instanceof DepthExceededStaxException) { throw ExceptionUtils.toWebApplicationException(null, JAXRSUtils.toResponse(413)); } cause = cause.getCause(); } String msg = linked.getMessage(); if (sb.lastIndexOf(msg) == -1) { sb.append(msg).append(". "); } } Throwable t = linked != null ? linked : e.getCause() != null ? e.getCause() : e; String message = new org.apache.cxf.common.i18n.Message("JAXB_EXCEPTION", BUNDLE, sb.toString()).toString(); handleExceptionEnd(t, message, read); }
Example 3
Source File: T2FlowReader.java From incubator-taverna-language with Apache License 2.0 | 5 votes |
@Override public WorkflowBundle readBundle(InputStream inputStream, String mediaType) throws ReaderException, IOException { DelayedCloseBufferedInputStream buffered = new DelayedCloseBufferedInputStream( inputStream, PRESERVE_ORIGINAL_MAXIMUM_BYTES); try { buffered.mark(PRESERVE_ORIGINAL_MAXIMUM_BYTES); WorkflowBundle bundle; try { bundle = getParser().parseT2Flow(buffered); scufl2Tools.setParents(bundle); } catch (JAXBException e) { if (e.getCause() instanceof IOException) { IOException ioException = (IOException) e.getCause(); throw ioException; } throw new ReaderException("Can't parse t2flow", e); } // Rewind and try to copy out the original t2flow try { buffered.reset(); } catch (IOException ex) { // Too big workflow, can't preserve it. // TODO: Store to Bundle first? // FIXME: Can we close BufferedInputStream without closing // inputStream from our parameter? return bundle; } preserveOriginal(bundle, buffered); return bundle; } finally { buffered.reallyClose(); } }
Example 4
Source File: ScuflReader.java From incubator-taverna-language with Apache License 2.0 | 5 votes |
@Override public WorkflowBundle readBundle(File bundleFile, String mediaType) throws ReaderException, IOException { try { WorkflowBundle bundle = getParser().parseScufl(bundleFile); scufl2Tools.setParents(bundle); return bundle; } catch (JAXBException e) { if (e.getCause() instanceof IOException) { IOException ioException = (IOException) e.getCause(); throw ioException; } throw new ReaderException("Can't parse SCUFL " + bundleFile, e); } }
Example 5
Source File: ScuflReader.java From incubator-taverna-language with Apache License 2.0 | 5 votes |
@Override public WorkflowBundle readBundle(InputStream inputStream, String mediaType) throws ReaderException, IOException { try { WorkflowBundle bundle = getParser().parseScufl(inputStream); scufl2Tools.setParents(bundle); return bundle; } catch (JAXBException e) { if (e.getCause() instanceof IOException) { IOException ioException = (IOException) e.getCause(); throw ioException; } throw new ReaderException("Can't parse SCUFL", e); } }
Example 6
Source File: ExporterRegistrationHandler.java From arquillian-recorder with Apache License 2.0 | 5 votes |
private JAXBContext getContext() { try { return JAXBContextFactory.initContext(Report.class); } catch (JAXBException ex) { throw new RuntimeException("Unable to initialize JAXBContext.", ex.getCause()); } }