Ear tasks overrides default application.xml


(awouda) #1

Hi,

I’m working on converting a maven build into a Gradle one. Now my ear is generated and I want to test it; however during startup of Jboss, which is the target appserver as this is a seam project, fails. I narrowed it down to the generated attributes in the application element.

Now I decided to handcraft the application.xml, as the documentation states :“The existing file contents will be used and the explicit configuration in the ear.deploymentDescriptor will be ignored.” But my original application.xml (copied from a working ear file) looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE application PUBLIC
 "-//Sun Microsystems, Inc.//DTD J2EE Application 1.3//EN"
 "http://java.sun.com/dtd/application_1_3.dtd">
<application>

While after executing the ear taks this looks like:

<?xml version="1.0"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="null">

Jboss chokes on this

Caused by: org.jboss.xb.binding.JBossXBRuntimeException: Element {http://java.sun.com/xml/ns/javaee}application is not bound as a global element.

Now I know Jboss might have its quirks, but how can I force Gradle to keep my application.xml untouched?

tia

Alex


(awouda) #2

I’ve sorted it out. Jboss 5.1.GA needs the old 1.3 DTD spec, so with version I can set this. Apart from that one should not add a description in the ear closure, this is hardcoded to be a Node before display-name, and this is not expected by the application_1_3.dtd specification.

Also I needed to tweak to generated application.xml with the following, otherwise the application.xml is still rejected.

/**
 We need to adjust the generated XML somewhat, in order to be compatible with DTD version 1.3 of the application.xml spec.
 */
          withXml { application ->
   // fetch the whole xml
            def applicationXML =
application.asNode()
  // find the library-directory node, not used by spec 1.3
            def libraryDirectory = applicationXML.find { it.name() == 'library-directory' }
   //remove this library-directory folder
            applicationXML.remove(libraryDirectory)
  // also remove the version attribute in the application node
            applicationXML.attributes().remove('version')
                  }

If you need 1.3 spec, this might help you.