class XmlMarshaller {

    public static String marshal(Object object) throws MarshallerException {

        StringWriter stringWriter = new StringWriter();
        try {
            JAXBContext jaxbContext = JAXBContext.newInstance(object.getClass());
            Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
            jaxbMarshaller.marshal(object, stringWriter);
        } catch (JAXBException e) {
            logger.error(LoggingAnchor.THREE, MessageEnum.GENERAL_EXCEPTION.toString(),
                    ErrorCode.SchemaError.getValue(), e.getMessage(), e);
            throw new MarshallerException(e.getMessage(), ErrorCode.SchemaError.getValue(), e);
        }

        return stringWriter.toString();
    }

}