You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Andrew Fawcett <An...@coda.com> on 2000/07/18 16:37:01 UTC

NotSerializableException thrown when Serializing StylesheetRoot o bject?

Hi,

I am presently attempting to serialize a compiled Stylesheet using the
following Java code. I was wondering if anyone else has had any experience
with this. Any comments or advise would be much appreciated. ;-)

import java.io.*;
import java.util.Date;
import org.apache.xalan.xslt.*;

public class XSL
{
	public static void main(String[] args)
		throws Throwable
	{
		XSLTProcessor processor =
XSLTProcessorFactory.getProcessor();
		StylesheetRoot stylesheet =
processor.processStylesheet("file:///c:/test.xsl");
		ObjectOutputStream ostream = new
ObjectOutputStream(System.out);
		ostream.writeObject(stylesheet);
	}
}

This is the style sheet.

<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
	<xsl:template match="*">
		<xsl:copy>
			<xsl:apply-templates/>
		</xsl:copy>
	</xsl:template>
	<xsl:template match="text()">
		<xsl:value-of
select="translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz')"/>
	</xsl:template>
</xsl:stylesheet>

The writeObject method eventually throws the following exception. I am using
version 1.1.D01 of Xalan.

java.io.NotSerializableException:
org.apache.xalan.xpath.xml.StringToStringTable
        at
java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:845)
        at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:342)
        at
java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1567)
        at
java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:453)
        at
org.apache.xalan.xslt.ElemTemplateElement.writeObject(ElemTemplateElement.ja
va:252)
        at java.lang.reflect.Method.invoke(Native Method)
        at
java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java:1585)
        at
java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:907)
        at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:342)
        at
java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1567)
        at
java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:453)
        at
java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:911)
        at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:342)
        at
java.io.ObjectOutputStream.outputClassFields(ObjectOutputStream.java:1567)
        at
java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:453)
        at org.apache.xalan.xslt.Stylesheet.writeObject(Stylesheet.java:531)
        at java.lang.reflect.Method.invoke(Native Method)
        at
java.io.ObjectOutputStream.invokeObjectWriter(ObjectOutputStream.java:1585)
        at
java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:907)
        at
java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:342)
        at XSL.main(XSL.java:17)


Re: NotSerializableException thrown when Serializing StylesheetRoot object?

Posted by "Sergei S. Ivanov" <iv...@aha.ru>.
----- Èñõîäíîå ñîîáùåíèå -----
Îò: Andrew Fawcett <An...@coda.com>
Êîìó: <xa...@xml.apache.org>
Îòïðàâëåíî: 18 èþëÿ 2000 ã. 18:37
Òåìà: NotSerializableException thrown when Serializing StylesheetRoot
object?


> I am presently attempting to serialize a compiled Stylesheet using the
> following Java code. I was wondering if anyone else has had any experience
> with this. Any comments or advise would be much appreciated. ;-)

<...>

> The writeObject method eventually throws the following exception. I am
using
> version 1.1.D01 of Xalan.
>
> java.io.NotSerializableException:
> org.apache.xalan.xpath.xml.StringToStringTable
>         at
> java.io.ObjectOutputStream.outputObject(ObjectOutputStream.java:845)
>         at

<...>

The problem is that StringToStringTable does not implement Serializable. I
have made a note on this list a week ago, but had no replies from the
developers.

But even if you change StringToStringTable to implement Serializable, the
de-serialized stylesheet will crash when top level params are used (no
problems without parameters).

Still looking forward for the developers' comments...
--
Sergei S. Ivanov  sergei_ivanov@object-tools.com
Object Tools, Moscow  http://www.object-tools.com