private void persist(Object o, Resource r) throws IOException { try { synchronized (xp) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); xp.save(o, bos); r.setContents(bos.toByteArray()); } LOGGER.fine("Persisted " + o.getClass().getName() + " to " + r.path()); } catch (Exception e) { // catch any exceptions and send them back as CatalogExeptions String msg = "Error persisting " + o + " to " + r.path(); throw new CatalogException(msg, e); } }