use of javax.xml.bind.MarshalException in project tomee by apache.
the class JaxbOpenejb method writeConfig.
public static void writeConfig(final String configFile, final Openejb openejb) throws OpenEJBException {
OutputStream out = null;
try {
final File file = new File(configFile);
out = IO.write(file);
marshal(Openejb.class, openejb, out);
} catch (final IOException e) {
throw new OpenEJBException(messages().format("conf.1040", configFile, e.getLocalizedMessage()), e);
} catch (final MarshalException e) {
if (e.getCause() instanceof IOException) {
throw new OpenEJBException(messages().format("conf.1040", configFile, e.getLocalizedMessage()), e);
} else {
throw new OpenEJBException(messages().format("conf.1050", configFile, e.getLocalizedMessage()), e);
}
} catch (final ValidationException e) {
/* NOTE: This doesn't seem to ever happen. When the object graph
* is invalid, the MarshalException is thrown, not this one as you
* would think.
*/
throw new OpenEJBException(messages().format("conf.1060", configFile, e.getLocalizedMessage()), e);
} catch (final JAXBException e) {
throw new OpenEJBException(e);
} finally {
if (out != null) {
try {
out.close();
} catch (final Exception e) {
// no-op
}
}
}
}
Aggregations