6 Replies Latest reply: Mar 17, 2011 5:19 PM by Mrinal Malhotra RSS

    JBoss AS6.0.0.Final Spring MVC doesnt work

    Mrinal Malhotra Newbie

      Hi,

       

      I am trying to run a basic example of Spring MVC (https://anonsvn.jboss.org/repos/jbossas/projects/spring-int/branches/1_0/documentation/samples/web-scanning/src/) for Component scanning using JBoss AS 6.0.0.0.Final and run into this error:

       

      12:33:56,429 INFO  [xnio] XNIO Version 2.1.0.CR2

      12:33:56,445 INFO  [nio] XNIO NIO Implementation Version 2.1.0.CR2

      12:33:56,570 INFO  [remoting] JBoss Remoting version 3.1.0.Beta2

      12:33:56,648 INFO  [TomcatDeployment] deploy, ctxPath=/

      12:33:56,679 INFO  [TomcatDeployment] deploy, ctxPath=/TestMVCJBoss

      12:33:56,726 INFO  [[/TestMVCJBoss]] Initializing Spring root WebApplicationContext

      12:33:56,726 INFO  [ContextLoader] Root WebApplicationContext: initialization started

      12:33:56,742 INFO  [VFSXmlWebApplicationContext] Refreshing Root WebApplicationContext: startup date [Wed Mar 16 12:33:56 EDT 2011]; root of context hierarchy

      12:33:56,742 ERROR [ContextLoader] Context initialization failed: java.lang.NoClassDefFoundError: org/jboss/virtual/VirtualFileVisitor

          at org.jboss.spring.vfs.VFSServletContextResourcePatternResolver.findPathMatchingResources(VFSServletContextResourcePatternResolver.java:51) [:1.1.0.GA]

          at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:269) [:3.0.1.RELEASE-A]

          at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1196) [:3.0.1.RELEASE-A]

          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:177) [:3.0.1.RELEASE-A]

          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) [:3.0.1.RELEASE-A]

       

      If I put the VFS jar (jboss-vfs-2.1.2.GA.jar) in the server's classpath it starts throwing:

       

      12:53:07,855 INFO  [[/TestMVCJBoss]] Initializing Spring root WebApplicationContext

      12:53:07,855 INFO  [ContextLoader] Root WebApplicationContext: initialization started

      12:53:07,871 INFO  [VFSXmlWebApplicationContext] Refreshing Root WebApplicationContext: startup date [Wed Mar 16 12:53:07 EDT 2011]; root of context hierarchy

      12:53:07,886 INFO  [VFSCacheFactory] Using VFSCache [NoopVFSCache]

      12:53:07,902 ERROR [ContextLoader] Context initialization failed: org.springframework.beans.factory.BeanDefinitionStoreException: Could not resolve bean definition resource pattern [classpath*:spring-contexts/*.xml]; nested exception is java.io.IOException: No context factory for vfs:/C:/jboss-6.0.0.Final/server/default/deploy/TestMVCJBoss.war/WEB-INF/classes/spring-contexts/

          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:190) [:3.0.1.RELEASE-A]

          at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) [:3.0.1.RELEASE-A]

          at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) [:3.0.1.RELEASE-A]

          at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93) [:3.0.1.RELEASE-A]

          at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) [:3.0.1.RELEASE-A]

          at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465) [:3.0.1.RELEASE-A]

          at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395) [:3.0.1.RELEASE-A]

       

       

      I have the following Spring and Snowdrop Jars in the server classpath:

       

      snowdrop-vfs-1.1.0.GA.jar

      org.springframework.aop-3.0.1.RELEASE-A.jar

      org.springframework.asm-3.0.1.RELEASE-A.jar    

      org.springframework.beans-3.0.1.RELEASE-A.jar    

      org.springframework.context-3.0.1.RELEASE-A.jar

      org.springframework.context.support-3.0.1.RELEASE-A.jar

      org.springframework.core-3.0.1.RELEASE-A.jar

      org.springframework.expression-3.0.1.RELEASE-A.jar

      org.springframework.web-3.0.1.RELEASE-A.jar

      org.springframework.web.servlet-3.0.1.RELEASE-A.jar

        • 1. JBoss AS6.0.0.Final Spring MVC doesnt work
          Mrinal Malhotra Newbie

          Also as recommended in the Document "http://docs.redhat.com/docs/en-US/JBoss_Web_Framework_Kit/1.1/html/Snowdrop_1.1_User_Guide/ch01.html"

           

          I download and applied Spring 3.0.2 Release Jar files, same exceptions occur

           

          -Mrinal

          • 2. JBoss AS6.0.0.Final Spring MVC doesnt work
            jaikiran pai Master

            Moved the thread to Snowdrop froum. Someone here might be able to help.

            • 3. JBoss AS6.0.0.Final Spring MVC doesnt work
              Marius Bogoevici Expert

              Hi Mrinal,

               

              Two things to make things better (you can do either, it's not necessary to do both):

               

              1) Switch the example from Snowdrop 1.1 to 2.0.0-MP1-SP1. Only the latter works on AS6.

               

              2) You don't really need Snowdrop for VFS scanning on AS6 if you are using Spring 3.0.3 or later.

               

              Try either of them and it'll work.

               

              Marius

              • 4. JBoss AS6.0.0.Final Spring MVC doesnt work
                Mrinal Malhotra Newbie

                Hi Marius

                 

                Thanks for the information, I was able to download Spring Release 3.0.5 and the application worked, with some minor modifications:

                 

                a) Moved the spring-contexts folder into WEB-INF (As I am not using the Snowdrop JAR file, I dont think I have the "classpath*" available anymore?)

                b) I had to remove references to the contextClass in the web.xml, so the source for the web.xml  changed to (Maybe the source for the demo code should be appended for this change?) :

                 

                <web-app>

                  <display-name>Classpath Scanning Spring MVC Web Application</display-name>

                 

                  <context-param>

                    <param-name>contextConfigLocation</param-name>

                    <param-value>/WEB-INF/spring-contexts/*.xml</param-value>

                  </context-param>

                   <listener>

                   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

                  </listener>

                 

                  <servlet>

                    <servlet-name>spring-mvc-servlet</servlet-name>

                    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

                    <init-param>

                      <param-name>contextConfigLocation</param-name>

                      <param-value>/WEB-INF/mvc-config.xml</param-value>

                    </init-param>

                  </servlet>

                 

                  <servlet-mapping>

                    <servlet-name>spring-mvc-servlet</servlet-name>

                    <url-pattern>/spring/*</url-pattern>

                  </servlet-mapping>

                </web-app>

                 

                -Mrinal

                • 5. Re: JBoss AS6.0.0.Final Spring MVC doesnt work
                  Marius Bogoevici Expert

                  Hey Mrinal

                   

                  a) Not sure what the problem is in your case, but the classpath*: path should really work. It does for me - see the configuration below.

                   

                  b) This what I meant by "you don't really need Snowdrop for VFS scanning".

                   

                  !DOCTYPE web-app PUBLIC
                      "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
                      "http://java.sun.com/dtd/web-app_2_3.dtd" >
                  
                  <web-app>
                    <display-name>Classpath Scanning Spring MVC Web Application</display-name>
                  
                    <context-param>
                      <param-name>contextConfigLocation</param-name>
                      <param-value>classpath*:spring-contexts/*.xml</param-value>
                    </context-param>
                  
                    <listener>
                      <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
                    </listener>
                  
                    <servlet>
                      <servlet-name>spring-mvc-servlet</servlet-name>
                      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
                      <init-param>
                        <param-name>contextConfigLocation</param-name>
                        <param-value>/WEB-INF/mvc-config.xml</param-value>
                      </init-param>
                     </servlet>
                  
                    <servlet-mapping>
                      <servlet-name>spring-mvc-servlet</servlet-name>
                      <url-pattern>/spring/*</url-pattern>
                    </servlet-mapping>
                  </web-app>
                  

                   

                   

                  Cheers,

                  Marius

                  • 6. JBoss AS6.0.0.Final Spring MVC doesnt work
                    Mrinal Malhotra Newbie

                    Hi Marius

                     

                    Thanks for the update, I still haven't figured out what was wrong but a restart fixed everything (using the web.xml configuration above).

                     

                    -Mrinal