marshalling d'un objet String avec JAXB
Bonjour ,
mon problème c'est que j'ai un String (commentaire) que je veu mettre dans un fichier XML
je fais la même opération avec un autre objet dans mon cas c'est (BusinnessIndex) est ça marche très bien avec JAXB
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
try {
m_jaxbcontext = JAXBContext.newInstance(BusinessIndex.class);
m_marshaller = m_jaxbcontext.createMarshaller();
m_marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m_marshaller.marshal(businessIndex, new FileOutputStream("getBusinessIndex.xml"));
} catch (FileNotFoundException e) {
LOGGER.error("ModificationDocumentServicesImpl.modifierAttributs(), "
+ e.getMessage());
throw new GedTechnicalException(VIRTUO_XML_TEMP_NOT_FOUND);
} catch (JAXBException e) {
LOGGER.error("ModificationDocumentServicesImpl.modifierAttributs(), "
+ e.getMessage());
throw new GedTechnicalException(VIRTUO_MARSHALING_ERROR);
} |
mais quand j'essaie avec un String sa ne veut pas marché
je fais le même code je change juste le type d'objet mais il me génère un exception
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
String commentaire = m_newAttributsxmlBean.getCommentaire();
try {
m_jaxbcontext = JAXBContext.newInstance(String.class);
m_marshaller = m_jaxbcontext.createMarshaller();
m_marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m_marshaller.marshal(commentaire, new FileOutputStream("commentaire.xml"));
} catch (FileNotFoundException e) {
LOGGER.error("ModificationDocumentServicesImpl.modifierAttributs(), "
+ e.getMessage());
throw new GedTechnicalException(VIRTUO_XML_TEMP_NOT_FOUND);
} catch (JAXBException e) {
LOGGER.error("ModificationDocumentServicesImpl.modifierAttributs(), "
+ e.getMessage());
throw new GedTechnicalException(VIRTUO_MARSHALING_ERROR);
} |