7 Replies Latest reply on Feb 6, 2013 6:02 PM by holger.lierse

    JBoss AS 7 - trouble with Spring application deploying

    sigthor

      I try to deploy Spring application on JBoss AS 7, but it fails with such error:

       

      org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/jee]

       

      Spring configured as external dependency in MANIFEST.MF and module org.springframework has been created in module directory. spring-context.jar (with jee namespace) also deployed as a module.

       

      P.S. there are no troubles on previous versions of JBoss AS. spring jars has been placed in server/default/lib directory

        • 1. Re: JBoss AS 7 - trouble with Spring application deploying
          marius.bogoevici

          This is an issue with JBoss Modules: https://issues.jboss.org/browse/AS7-1928

           

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

          • 2. Re: JBoss AS 7 - trouble with Spring application deploying
            marius.bogoevici

            Actually, it seems like jboss-deployment-structure.xml supports this already. Therefore, instead of using MANIFEST.MF, you may add this in /WEB-INF/jboss-deployment-structure.xml (this is assuming that you have a web application - otherwise it's /META-INF/jboss-deployment-structure.xml):

             

            <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>

            • 3. Re: JBoss AS 7 - trouble with Spring application deploying
              sigthor

              Thanks!!! It really works with jboss-deployment-structure.xml, but another trouble with Spring has been surfaced:

               

              Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration

                      at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141) [org.springframework.beans-3.0.6.RELEASE.jar:]

                      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74) [org.springframework.beans-3.0.6.RELEASE.jar:]

                      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958) [org.springframework.beans-3.0.6.RELEASE.jar:]

                      ... 69 more

               

              I made the following configuration in jboss-deployment-structure.xml:

               

              <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">

                        <deployment>

                                  <dependencies>

               

               

                                            <module name="org.apache.commons.logging" />

                                            <module name="org.apache.log4j" />

                                            <module name="org.hibernate" />

                                            <module name="org.jdom" />

               

                                            <module name="org.springframework">

                                                      <imports>

                                                                <include path="META-INF**" />

                                                                <include path="org**" />

                                                      </imports>

                                            </module>

               

               

                                  </dependencies>

                        </deployment>

              </jboss-deployment-structure>

               

              It seems spring doesn't see hibernate.jar, but it is deployed as a module in jboss 7 by default(I changed default Hibernate 4 to 3.6.7)

              • 4. Re: JBoss AS 7 - trouble with Spring application deploying
                marius.bogoevici

                As this is a modified version of AS7, I can't really say what went wrong, but an alternative solution that worked better would be to package hibernate inside the application, and exclude the hibernate module (might not be necessary, if this is a native Hibernate application).

                • 5. Re: JBoss AS 7 - trouble with Spring application deploying

                  Hi,

                   

                  Did yoyu ever figure out what the problem is? Facing the same issue here...

                   

                  Thanks.

                  • 6. Re: JBoss AS 7 - trouble with Spring application deploying
                    sigthor

                    What issue? spring doesn't see hibernate? You should use the latest Spring version(with 3.2 it works well on my side) or place hibernate jars within war

                    • 7. Re: JBoss AS 7 - trouble with Spring application deploying

                      Hi Sigurd,

                       

                      We're using Spring 2.5.6.SEC03 with Snowdrop 2.0.4 and we're not defining any Hibernate dependency (i.e. Hibernate 4 would be used). It seems to be working when packaging Snowdrop and the Sping libs into the EAR  however, when trying to use the JBoss deployment descriptor and defining the modules get the error above.

                      Are you using the Snowdrop module? Do you have a dependency on the Spring module in your Snowdrop module.xml? How does your Spring module.xml look like? Is there a spring-orm dependency and a dependency on Hibernate? The issue might be that Spring 2.5.6.SEC03 can't wrap Hibernate 4, however why is it working when placing the Spring libs into the EAR?

                       

                      Thanks for your help.

                      Holger