シリアル化されている次のクラスがあります
org.springframework.integration.core.Message
次のようにファイルに:
Sample.java
public static void receive(Message<?> message) throws IOException, MessagingException
{
XStream xStream = new XStream();
File file = new File("c:/temp/temp.xml");
FileOutputStream fileOutputStream = new FileOutputStream(file);
xStream.toXML(message,fileOutputStream);
}
UnMarshall.java
public static void main(String[] args) throws IOException, MessagingException, ClassNotFoundException
{
XStream xStream = new XStream();
File file = new File("c:/temp/temp.xml");
FileInputStream fileOutputStream = new FileInputStream(file);
Message message = (Message) xStream.fromXML(fileOutputStream);
}
UnMarshall.javaを実行すると、次の例外が発生します。
質問
- XStreamを使用してMessageオブジェクトをシリアル化/逆シリアル化することは可能ですか?
そうでない場合、私には他にどのようなオプションがありますか?
スレッド"main"の例外com.thoughtworks.xstream.converters.ConversionException:クラスjava.lang.Classを構築できません----デバッグ情報----メッセージ:クラスjava.lang.Classを構築できません原因-例外:java。 lang.InstantiationException原因メッセージ:javax.activation.ActivationDataFlavorクラス:org.springframework.integration.message.GenericMessage必須-タイプ:javax.activation.ActivationDataFlavorパス:/org.springframework.integration.message.GenericMessage/payload/dh/dataContentHandler / dch / myDF行番号:14-------------------------------com.thoughtworks.xstream.converters.reflectionにあります。 com.thoughtworks.xstream.coreのExternalizableConverter.unmarshal(ExternalizableConverter.java:110)。TreeUnmarshaller.convert(TreeUnmarshaller.java:56)at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)at com .thoughtworks.xstream.annotations.AnnotationReflectionConverter.unmarshallField(AnnotationReflectionConverter.java:66)at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:188)at com.thoughtworks.xstream .unmarshal(AbstractReflectionConverter.java:125)at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)atcom.thoughtworks.xstream.core.AbstractReferenceUnmarshaller。convert(AbstractReferenceUnmarshaller.java:45)at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.unmarshallField(AnnotationReflectionConverter.java:66)at com .xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:188)at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:125)at com.thoughtworks.xstream.core.Tree (TreeUnmarshaller.java:56)at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:188)のcom.thoughtworks.xstream.annotations.AnnotationReflectionConverter.unmarshallField(AnnotationReflectionConverter.java:66)のcom.thoughtworks .reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:125)at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshall )com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)at com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.unmarshallField(AnnotationReflectionConverter.java:66)com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:125)at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:188)at com.thoughtworks .core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46 )com.thoughtworks.xstream.annotations.AnnotationReflectionConverter.unmarshallField(AnnotationReflectionConverter.java:66)at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.doUnmarshal(AbstractReflectionConverter.java:188)com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter.unmarshal(AbstractReflectionConverter.java:125)at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:56)at com.thoughtworks.xstream.core .AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45)at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46)at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:117)at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:846)at com.thoughtworks.xstream.XStream.unmarshal(XStream.java: 833)com.thoughtworks.xstream.XStreamで。fromXML(XStream.java:789)at org.springframework.integration.samples.mail.imapidle.DefaultEmailReceiverUtilService.main(DefaultEmailReceiverUtilService.java:103)原因:java.lang.InstantiationException:javax.activity.ActivationDataFlavoratjava.lang。 Class.newInstance0(Class.java:340)at java.lang.Class.newInstance(Class.java:308)at com.thoughtworks.xstream.converters.reflection.ExternalizableConverter.unmarshal(ExternalizableConverter.java:80)... 39もっとnewInstance(Class.java:308)at com.thoughtworks.xstream.converters.reflection.ExternalizableConverter.unmarshal(ExternalizableConverter.java:80)... 39 morenewInstance(Class.java:308)at com.thoughtworks.xstream.converters.reflection.ExternalizableConverter.unmarshal(ExternalizableConverter.java:80)... 39 more