EAR plugin generates wrong deployment descriptor for J2EE 1.3

I believe EAR plugin generates wrong deployment for J2EE 1.3 as it causes 3 errors on the file.

  1. It puts “version” attribute on <application element> when it should not.

This is what to be expected:


But… this is the reality:

  1. The other thing is, it create invalid element <library-directory> when it should not.

  2. It generates elements in wrong order.

It should generate:

<display-name>X-interface</display-name> <description>X Interface Desc</description>

But the reality:
<description>X Interface Desc</description> <display-name>X-interface</display-name>

Please fix this 3 errors.

Thanks. Which application container is this failing with?

As a workaround, you can tweak the generated XML:

ear {
	deploymentDescriptor {
		version = '1.3'	
		displayName = "foo"
		description = "description of foo"
		withXml { 
			def rootNode = it.asNode()

It is with Oracle WebLogic

By the way. Your workaround is still unable to solve the order problem.

It generates in the “correct” order for me and I would hope it doesn’t really matter.

You can modify the generated XML through this API: https://docs.gradle.org/current/javadoc/org/gradle/plugins/ear/descriptor/DeploymentDescriptor.html

What happens when the elements are in the other order?

Actually, the order is not correct according to the DTD.

This is my final fix:

// Work around bugs in generated application.xml file to comply with J2EE 1.3 spec
withXml {
  def appXml = it.asNode()
  // Remove invalid nodes
  // Fix wrong order
  def desc = appXml.'description'[0]
  def disp = appXml.'display-name'[0]

Anyway, thank you for your workaround :smile: