I am trying to remove and add tags from an xml file using XmlParser . Following is my code block which runs fine when executed inside my grails application deployed with "grails run-app" command :

```
def parser = new XmlParser()
def xmlTemplate = parser.parse(file1)
def origFile  = parser.parse(file2)

for (def n : origFile.cars)
{
    origFile.remove(n)
}

def children = origFile.children()
int i = 0 ; 
for (def n : xmlTemplate.cars)
{
  children.add(i,n)
   i++
}

new File(finalFileName).write( XmlUtil.serialize(origFile) )

```

However when I deploy this code on JBOSS server as a war it throws the following error when called :

```
13:50:36,312 INFO  [stdout] (http-/10.64.96.82:8080-28) org.apache.xml.serializer.utils.WrappedRuntimeException: org.apache.xml.serializer.ToXMLSAXHandler cannot be cast to org.apache.xml.serializer.SerializationHandler
13:50:36,312 INFO  [stdout] (http-/10.64.96.82:8080-28)     at org.apache.xml.serializer.SerializerFactory.getSerializer(SerializerFactory.java:179)
13:50:36,312 INFO  [stdout] (http-/10.64.96.82:8080-28)     at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(TransformerIdentityImpl.java:260)
13:50:36,312 INFO  [stdout] (http-/10.64.96.82:8080-28)     at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:330)
13:50:36,312 INFO  [stdout] (http-/10.64.96.82:8080-28)     at groovy.xml.XmlUtil.serialize(XmlUtil.java:448)
13:50:36,312 INFO  [stdout] (http-/10.64.96.82:8080-28)     at groovy.xml.XmlUtil.serialize(XmlUtil.java:437)
13:50:36,312 INFO  [stdout] (http-/10.64.96.82:8080-28)     at groovy.xml.XmlUtil.serialize(XmlUtil.java:179)
13:50:36,312 INFO  [stdout] (http-/10.64.96.82:8080-28)     at groovy.xml.XmlUtil.serialize(XmlUtil.java:88)
13:50:36,312 INFO  [stdout] (http-/10.64.96.82:8080-28)     at groovy.xml.XmlUtil$serialize.call(Unknown Source)
13:50:36,312 INFO  [stdout] (http-/10.64.96.82:8080-28)     at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
13:50:36,312 INFO  [stdout] (http-/10.64.96.82:8080-28)     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
13:50:36,312 INFO  [stdout] (http-/10.64.96.82:8080-28)     at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)

```

I found a similar issue on <https://issues.jboss.org/browse/JBEAP-19> which suggested to remove xalan serializer-2.7.1.jar from the package and it indeed works fine after removing this jar from the application war. 
The jar serializer-2.7.1.jar was part of my war file as I created the war using "grails war" command and I am not sure where it was being used.My app is running fine after the removal of jar so it seems the grails framework is also not using this jar internally anywhere.

Can anyone explain what can be the root cause of this issue and also what is the use of serializer-2.7.1.jar in grails app ?