I would like to marshall Java objects into XML and vice-versa from within an Unsigned Applet and I can\'t change any of the security permission/policy files, or sign the applica
This may solve your problem. I know it solved mine :)
public void actionPerformed(ActionEvent e) {
try {
JAXBContext jc = AccessController.doPrivileged(new PrivilegedExceptionAction() {
public JAXBContext run() throws JAXBException {
// needs to run here otherwise throws AccessControlException
return JAXBContext.newInstance(SimpleObject.class);
}
});
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
SimpleObject object = new SimpleObject();
object.setSampleText("Hello");
marshaller.marshal(object, System.out);
}
catch (JAXBException e1) {
throw new RuntimeException(e1);
}
} catch (PrivilegedActionException e2) {
throw new RuntimeException(e2);
}
}
Hope it helps