# Error serializing script library

**URL:** <https://forum.inductiveautomation.com/t/error-serializing-script-library/3547>\
**Category:** Ignition\
**Created:** [November 3, 2011, 2:10pm UTC](https://forum.inductiveautomation.com/t/error-serializing-script-library/3547 "2011-11-03T14:10:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg.Buehler](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Greg.Buehler](https://forum.inductiveautomation.com/u/Greg.Buehler)\
**Post date:** [November 3, 2011, 2:10pm UTC](https://forum.inductiveautomation.com/t/error-serializing-script-library/3547/1 "2011-11-03T14:10:04Z")

</div>

I don’t think I have that many scripts in my project, but I’m getting a message saying the encoded string is too long.

[code]com.inductiveautomation.ignition.common.xmlserialization.SerializationException: IOException during serialization.  
at com.inductiveautomation.ignition.common.xmlserialization.serialization.XMLSerializer.serialize(XMLSerializer.java:430)  
at com.inductiveautomation.ignition.common.xmlserialization.serialization.XMLSerializer.serializeBinary(XMLSerializer.java:406)  
at com.inductiveautomation.ignition.common.xmlserialization.serialization.XMLSerializer.serializeBinary(XMLSerializer.java:399)  
at com.inductiveautomation.ignition.designer.scripteditor.ModuleEditor.serialize(ModuleEditor.java:415)  
at com.inductiveautomation.ignition.designer.scripteditor.ModuleEditor.doApply(ModuleEditor.java:394)  
at com.inductiveautomation.ignition.designer.scripteditor.ModuleEditor$3.actionPerformed(ModuleEditor.java:453)  
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)  
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)  
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)  
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)  
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)  
at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)  
at java.awt.Component.processMouseEvent(Unknown Source)  
at javax.swing.JComponent.processMouseEvent(Unknown Source)  
at java.awt.Component.processEvent(Unknown Source)  
at java.awt.Container.processEvent(Unknown Source)  
at java.awt.Component.dispatchEventImpl(Unknown Source)  
at java.awt.Container.dispatchEventImpl(Unknown Source)  
at java.awt.Component.dispatchEvent(Unknown Source)  
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)  
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)  
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)  
at java.awt.Container.dispatchEventImpl(Unknown Source)  
at java.awt.Window.dispatchEventImpl(Unknown Source)  
at java.awt.Component.dispatchEvent(Unknown Source)  
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)  
at java.awt.EventQueue.access$000(Unknown Source)  
at java.awt.EventQueue$1.run(Unknown Source)  
at java.awt.EventQueue$1.run(Unknown Source)  
at java.security.AccessController.doPrivileged(Native Method)  
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)  
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)  
at java.awt.EventQueue$2.run(Unknown Source)  
at java.awt.EventQueue$2.run(Unknown Source)  
at java.security.AccessController.doPrivileged(Native Method)  
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)  
at java.awt.EventQueue.dispatchEvent(Unknown Source)  
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)  
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)  
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)  
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)  
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)  
at java.awt.EventDispatchThread.run(Unknown Source)  
Caused by: java.io.UTFDataFormatException: encoded string too long: 70506 bytes  
at java.io.DataOutputStream.writeUTF(Unknown Source)  
at java.io.DataOutputStream.writeUTF(Unknown Source)  
at com.inductiveautomation.ignition.common.xmlserialization.serialization.BinaryWriter.writeStringTable(BinaryWriter.java:87)  
at com.inductiveautomation.ignition.common.xmlserialization.serialization.BinaryWriter.writeElement(BinaryWriter.java:63)  
at com.inductiveautomation.ignition.common.xmlserialization.serialization.XMLSerializer.serialize(XMLSerializer.java:428)  
… 42 more

Ignition v7.3.1 (b496)  
Java: Sun Microsystems Inc. 1.6.0\_26  
[/code]

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 3, 2011, 3:22pm UTC](https://forum.inductiveautomation.com/t/error-serializing-script-library/3547/2 "2011-11-03T15:22:11Z")

</div>

The jokester at Sun who originally wrote DataOutputStream thought this was a good idea:

`	if (utflen > 65535)
	    throw new UTFDataFormatException(
                "encoded string too long: " + utflen + " bytes");`

We’ve recently become aware of this issue and are working on a fix for it. In the mean-time, you either have too many scripts or one script in particular is too long. I’ll ask another developer when he gets here and let you know if there’s any work around right now…

---

<div class="post-metadata">

**Author:** ![Greg.Buehler](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Greg.Buehler](https://forum.inductiveautomation.com/u/Greg.Buehler)\
**Post date:** [November 3, 2011, 3:57pm UTC](https://forum.inductiveautomation.com/t/error-serializing-script-library/3547/3 "2011-11-03T15:57:43Z")

</div>

I looked at the code, and while it is technically correct this could have been completely avoided with a 4 byte header instead of a 2 byte header. Could you just wrap the call to DataOutputStream or is it called from within your xml serializer itself?

```auto
s = "some string that i want to run through DataOutputStream, and might be bigger than 65535 bytes"

DataOutputStream outputStream = new DataOutputStream(baStream)
if (s == null) {
	outputStream.writeByte(0)
}
else if (s.length() >= 65535) {
	byte[] b = s.getBytes("utf-8");
	outputStream.writeInt(b.length);
	outputStream.write(b);
}
else {
	outputStream.writeUTF(s);
} 

byte[] result = baStream.toByteArray() // can do whatever with this now.
```

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [November 3, 2011, 4:19pm UTC](https://forum.inductiveautomation.com/t/error-serializing-script-library/3547/4 "2011-11-03T16:19:16Z")

</div>

This has already been fixed. It’ll be in the 7.3.2 release. If you’d like, you can get it early by downloading the [7.3.2 beta](http://www.inductiveautomation.com/downloads/ignition/development).

---

<div class="post-metadata">

**Author:** ![Greg.Buehler](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@Greg.Buehler](https://forum.inductiveautomation.com/u/Greg.Buehler)\
**Post date:** [November 3, 2011, 4:25pm UTC](https://forum.inductiveautomation.com/t/error-serializing-script-library/3547/5 "2011-11-03T16:25:54Z")

</div>

Thanks Carl. I’ve whittled down the scripting so it works on some legacy installs, but I guess I’ll be able to put all the comments back in now. ![:mrgreen:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/d23659b203d2d24d394be983a52adb2fa6fe23d4.gif "Mr. Green")
