Ear plugin inserts unneeded ejb modules in the application.xml ear descriptor

Hi,

Ear plugin generates application.xml with an erroneous ejb module entry containing spring’s beanRefContext.xml file.

My ear project directory listing is:

src
└── main
    └── application
        ├── beanRefContext.xml
        └── META-INF
            └── jboss-app.xml

my build.gradle is

apply plugin: 'java'
apply plugin: 'ear'
  dependencies {
   deploy project( path: ':nmcommonDaoClient')
  deploy project( path: ':nmcommonDao')
  deploy project( path: ':auditEventDaoClient')
  deploy project( path: ':auditEventDao')
  deploy project( ':auditablerest')
  deploy project( ':nmcommonrest')
  earlib project( path: ':auditEventDao', configuration: 'unprovided')
  earlib project( path: ':nmcommonDao', configuration: 'unprovided')
}
  processResources {
  expand(project.properties)
}
  jar.onlyIf { false }
  ear {
  deploymentDescriptor {
    displayName = project.name
    initializeInOrder = true
    module("nmcommonDaoClient-${project.version}.jar", 'ejb')
    module("nmcommonDao-${project.version}.jar",'ejb')
    module("auditEventDaoClient-${project.version}.jar", 'ejb')
    module("auditEventDao-${project.version}.jar",'ejb')
    webModule("nmcommonrest-${project.version}.war",'/nmcommon.rest')
    webModule("auditablerest-${project.version}.war",'/auditable.rest')
    withXml { xml ->
      xml.asNode().module.removeAll { it.ejb.text().startsWith('beanRef') }
    }
  }
}

And this is the ear’s application.xml that gradle produces,

<?xml version="1.0"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
  <display-name>auditable</display-name>
  <module>
    <ejb>nmcommonDaoClient-1.0.0.jar</ejb>
  </module>
  <module>
    <ejb>nmcommonDao-1.0.0.jar</ejb>
  </module>
  <module>
    <ejb>auditEventDaoClient-1.0.0.jar</ejb>
  </module>
  <module>
    <ejb>auditEventDao-1.0.0.jar</ejb>
  </module>
  <module>
    <web>
      <web-uri>auditablerest-1.0.0.war</web-uri>
      <context-root>auditablerest-1.0.0</context-root>
    </web>
  </module>
  <module>
    <web>
      <web-uri>nmcommonrest-1.0.0.war</web-uri>
      <context-root>nmcommonrest-1.0.0</context-root>
    </web>
  </module>
  <module>
    <ejb>beanRefContext.xml</ejb>
  </module>
  <library-directory>lib</library-directory>
</application>

What is ‘beanRefContext.xml’? Where is it coming from?

Hi Luke,

In my ear project I use spring’s @Interceptors(SpringBeanAutowiringInterceptor.class) as described in http://goo.gl/XLCSS . The file is placed at the same level of the ejb, and war modules as it needs to be visible to all ejb that use the interceptor (and thus have the ability to share one application context, instead of one per module)

Ciao Stefano

Hi Luke,

if you meant where it is physically coming from, then please refer to the directory listing at the beginning of this forum post.

Ciao Stefano

I’ve looked through the code. I can’t see a way to get the EAR plugin to leave this file alone. Your best bet will be to post process the file and remove the line.

You have a withXml block there that looks like it’s trying to do this. That should work I think.

I have exactly the same problem but with a logback.xml that sits in the src/main/resources folder of the ear project. Must it be in a subfolder like config?

1 Like