Spring module in JBoss 7
Asked Answered
W

2

8

I'm trying to set up Spring 3.0.6 libraries as a module in JBoss 7.

I have all of the jars in modules/org/springframework/main along with the following module.xml

<module xmlns:"urn:jboss:module:1.0" name="org.springframework">
    <resources>
          <resource-root path="org.springframework.beans-3.0.6.RELEASE.jar"/>
          ...
    </resources>

    <dependencies>
       <module name="javax.api"/>
       <module name="javax.servlet.api"/>
       <module name="org.apache.commons.logging"/>
    </dependencies>
</module>

I added org.springframework to the Dependencies line in my MANIFEST.MF

When I deploy the app the following exception is thrown while parsing my spring-servlet.xml file (sorry, this is from a system that is not networked)

SAXParseException: ... Cannot find the declaration of element 'beans'

My first thought was that the module is not being used but if I remove org.springframework from my Dependencies line it fails to find org.springframework.web.context.ContextLoaderListener

Everything works fine if I put the jars in WEB-INF/lib instead of using the module.

spring-servlet.xml contains the following schema reference

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

so I put spring-beans-3.0.xsd in the same directory as spring-servlet.xml and modified the xml to

http://www.springframework.org/schema/beans spring-beans-3.0.xsd

but still no luck.

Anybody have an idea of why the class files are found but the xsd files are not?

Wirework answered 11/11, 2011 at 19:4 Comment(5)
are your JARs named like this: org.springframework.beans-3.0.6.RELEASE.jar or just beans-3.0.6.RELEASE.jar ?Saddlebow
this jar is named org.springframework.beans-3.0.6.RELEASE.jar, the others are named similarly just as they came from the spring distribution.The jars seem to be recognized when scanning the module because there is a .index file for each of the jars in the module.Wirework
Incidentally I am attempting this on JBoss 7.0.2.Wirework
Take a look at the thread community.jboss.org/thread/173133?tstart=0. It may give a hint.Spence
Vadzim, that link brought me to a solution; I knew about using jboss-deployment-structure.xml but hadn't gone to using the imports element as suggested. After adding a few additional modules in the springframework module.xml I'm up and running.Wirework
W
5

Just in case the link that was given in the comments goes away, the problem is that

Problem:

The namespace configuration files are in META-INF, but that directory is not visible (nor is it configurable via jboss-deployment-structure.xml)

Solution:

   <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
        <deployment>
            <dependencies>
                <module name="org.apache.commons.logging"/>
                <module name="org.springframework" >
                    <imports>
                        <include path="META-INF**"/>
                        <include path="org**"/>
                    </imports>
                </module>
            </dependencies>
    </jboss-deployment-structure>
Wirework answered 11/5, 2012 at 13:48 Comment(1)
Just to clarify: the comment "nor is it configurable via jboss-deployment-structure.xml" is old information from a previous version. Now it is configurable, like the example in this answer shows.Debra
M
0

Was facing the exact same issue. Had set up a spring module on JBoss 7 and then when deploying my application, was facing the below warning:

Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-3.2.xsd'

I understood the spring context file was unable to access the schema definitions from the spring jars, after reading the link in the comments above. And hence, the application was not getting deployed. But the solution given there did not work for me. But the below code in the jboss-deployment-structure.xml resolved the issue.

Solution

<module name="org.springframework.spring"   meta-inf="export"   export="true" />

Added meta-inf="export" attribute.

Mcilwain answered 2/12, 2015 at 6:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.