You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mailet-api@james.apache.org by Thilo Müller <th...@web.de> on 2009/10/19 12:21:11 UTC

Serialising Mail Objects

Dear User-Group,

I would like to use JAMES to store incoming emails in text files and need some guidance here.

Is the way to go using java.io.Serializable ?


I saw that org.apache.mailet.Mail implements java.io.Serializable.

I have managed to serialisable it to file and read it back while running JAMES.

But strangely, if I make a testclass which runs from the copied BLOB

objIn = new ObjectInputStream(new BufferedInputStream(new FileInputStream("data/spool/MAILOBJECT.BIN")));
			org.apache.mailet.Mail mail = (org.apache.mailet.Mail) objIn.readObject( );

it comes to

java.io.StreamCorruptedException: unexpected end of block data
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1296)
	at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
	at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
	at eon.SendEmailFromBlob.start(SendEmailFromBlob.java:19)
	at eon.Spool2Mail.main(Spool2Mail.java:11)

I have copied the .jar from the running james installation to the testclass to make sure that the same Mail object is used.


Any other ideas how to store mails including their headers with mailets ? 


Thank you ,

Thilo Müller
______________________________________________________
GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://movieflat.web.de


Re: Serialising Mail Objects

Posted by Norman Maurer <no...@apache.org>.
Hi Thilo,

Why you not just use the FileStore to store messages in the inbox in
the filesystem ? Do you need to implement your own store ?

Bye,
Norman


2009/10/19 Thilo Müller <th...@web.de>:
> Dear User-Group,
>
> I would like to use JAMES to store incoming emails in text files and need some guidance here.
>
> Is the way to go using java.io.Serializable ?
>
>
> I saw that org.apache.mailet.Mail implements java.io.Serializable.
>
> I have managed to serialisable it to file and read it back while running JAMES.
>
> But strangely, if I make a testclass which runs from the copied BLOB
>
> objIn = new ObjectInputStream(new BufferedInputStream(new FileInputStream("data/spool/MAILOBJECT.BIN")));
>                        org.apache.mailet.Mail mail = (org.apache.mailet.Mail) objIn.readObject( );
>
> it comes to
>
> java.io.StreamCorruptedException: unexpected end of block data
>        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1296)
>        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
>        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
>        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
>        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
>        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
>        at eon.SendEmailFromBlob.start(SendEmailFromBlob.java:19)
>        at eon.Spool2Mail.main(Spool2Mail.java:11)
>
> I have copied the .jar from the running james installation to the testclass to make sure that the same Mail object is used.
>
>
> Any other ideas how to store mails including their headers with mailets ?
>
>
> Thank you ,
>
> Thilo Müller
> ______________________________________________________
> GRATIS für alle WEB.DE-Nutzer: Die maxdome Movie-FLAT!
> Jetzt freischalten unter http://movieflat.web.de
>
>