My sub deployment application cannot load Spring META-INF/** when Spring module dependency is exported from the ear in JBoss EAP 6

Solution Verified - Updated -

Issue

  • We have installed Spring as a JBoss module, and add a dependency to it via jboss-deployment-structure.xml. I have an WAR inside and EAR which has to access the Spring JAR's. This configuration does not work.
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
     <deployment>
        <dependencies>
           <module name="org.springframework.spring" slot="main" export="true">
              <imports>
               <include path="META-INF**"/>
               <include path="org**"/>
              </imports>
           </module>
        </dependencies>
     </deployment>
</jboss-deployment-structure>

But in that case all files that are in META-INF that are required for spring to work (spring.handlers, spring.schemas, spring.tooling) are not available and so, the schemas file cannot be found and application fails to start with such message

Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 20 in XML document from file [\JBOSS_HOME\server\jboss-eap-6.0\standalone\configuration\support\application\spring\my-spring-config.xml]
 is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 20; columnNumber: 73; cvc-elt.1: Cannot find
 the declaration of element 'beans'.
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.j
ava:396)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.jav
a:334)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.jav
a:302)
...
Caused by: org.xml.sax.SAXParseException; lineNumber: 20; columnNumber: 73; cvc-elt.1: Cannot find the declaration of el
ement 'beans'.
        at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
        at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
        at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
...
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
        at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.j
ava:388)
        ... 50 more

We have tried to add the "import" statement in the jboss-deployment-structure.xml like here https://community.jboss.org/thread/173133?tstart=0 but it does not work.

Our machine does not a valid internet connection but if I include the Spring libs in the EAR then this issue doesn't appear. This proves that the Spring JAR's are not being picked up properly when installed as a module regardless of the internet connection to fetch the schema's.

  • There appears to be an issue with how the META-INF/** import is exposed to sub-deployments. We have an EAR which contains only a single sub-deployment, and a Spring application context is loaded from the sub-deployment. The jboss-deployment-structure.xml is defined at and it declares a dependency on the Spring module (including an export=”true” attribute to expose it to the sub-deployment) and includes an element for importing the META-INF/** packages, but does not contain any elements. The loading of the Spring context is failing as the Spring classes used in the EJB would not have visibility to the META-INF/** of the Spring jars in the Spring module. So it appears there is a bug where the defined on a module at the root deployment level is not effectively exposed to sub-deployments, unless there is something we are missing.

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 6.1.x
    • 6.0.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content