1 Reply Latest reply on Jun 29, 2014 10:57 PM by Raphael Rodrigues da Costa

    Spring MVC OSGI bundle

    Zd Y Newbie

      I try to deploy a spring mvc osgi bundle:

      When the program goes to dispatcher.xml:    

      This two lines cause issue.

      <mvc:annotation-driven/>   

      <mvc:view-controller path="/" view-name="index"/> 

       

      Issue: org.springframework.beans.factory.parsing.BeanDefinitionParsingException:

      Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/mvc] Offending resource: ServletContext resource [/WEB-INF/dispatcher-servlet.xml] Caused by: org.eclipse.jetty.servlet.ServletHolder$1: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/mvc] Offending resource: ServletContext resource [/WEB-INF/dispatcher-servlet.xml]

       

      I may miss spring-mvc packages in import package. However, I didn't find out which one I miss.

       

      Anyone made spring mvc osgi before? Could you please give me some hints or share me an example. (Actually I refered to many cases in google, I couldn't solve it though)

       

      main part of pom.xml:

       

      <dependencies>
          <!-- Spring core & mvc -->
        <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
        <scope>provided</scope>
        </dependency>
        <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
        <scope>provided</scope>
        </dependency>
        <dependency>
           <groupId>org.springframework</groupId>
           <artifactId>spring-webmvc</artifactId>
           <version>${spring.version}</version>
           <scope>provided</scope>
        </dependency>
        <dependency>
           <groupId>org.springframework</groupId>
           <artifactId>spring-orm</artifactId>
           <version>${spring.version}</version>
           <type>jar</type>
           <scope>provided</scope>
        </dependency>
        <dependency>
           <groupId>org.springframework</groupId>
           <artifactId>spring-test</artifactId>
           <version>${spring.version}</version>
           <type>jar</type>
           <scope>test</scope>
        </dependency>
      
            <!-- Servlet Spec -->
        <dependency>
           <groupId>javax.servlet</groupId>
           <artifactId>servlet-api</artifactId>
           <version>2.4</version>
           <scope>provided</scope>
        </dependency>
        <dependency>
           <groupId>javax.servlet.jsp</groupId>
           <artifactId>jsp-api</artifactId>
           <version>2.1</version>
           <scope>provided</scope>
        </dependency>
      
        <!-- Unit testing -->
        <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
        </dependency>
        </dependencies>
      
        <build>
        <finalName>sdnconsole</finalName>
        <plugins>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-compiler-plugin</artifactId>
                      <version>3.0</version>
                      <configuration>
        <source>1.7</source>
        <target>1.7</target>
        </configuration>
                  </plugin>
                  <plugin>
                      <groupId>org.apache.felix</groupId>
                      <artifactId>maven-bundle-plugin</artifactId>
                      <extensions>true</extensions>
                      <version>2.4.0</version>
                      <configuration>
                          <supportedProjectTypes>
                              <supportedProjectType>jar</supportedProjectType>
                              <supportedProjectType>bundle</supportedProjectType>
                              <supportedProjectType>war</supportedProjectType>
                          </supportedProjectTypes>
                          <instructions>
                              <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
                              <Bundle-Version>${project.version}</Bundle-Version>
                              <Import-Package>
                                        org.springframework.web.servlet,
                                        org.springframework.web.servlet.view,
                                        org.springframework.web.context.support,
                                        *; resolution:=optional
                              </Import-Package>
                              <Export-Package>org.test.*,!*</Export-Package>
                              <Bundle-Classpath>WEB-INF/classes</Bundle-Classpath>
                              <Web-ContextPath>war-spring</Web-ContextPath>
                              <Embed-Dependency>*; artifactId=!org.osgi.compendium; scope=compile; type=!pom; inline=true</Embed-Dependency>
                              <Embed-Transitive>true</Embed-Transitive>
                              <_removeheaders>
                                  Include-Resource,
                                  Private-Package,
                                  Embed-Dependency,
                                  Embed-Transitive,
                                  Ignore-Package
                              </_removeheaders>
                          </instructions>
                      </configuration>
                      <executions>
                          <execution>
                              <id>generate-manifest</id>
                              <phase>process-classes</phase>
                              <goals>
                                  <goal>manifest</goal>
                              </goals>
                          </execution>
                      </executions>
                  </plugin>
                  <plugin>
                      <artifactId>maven-war-plugin</artifactId>
                      <version>2.1</version>
                      <configuration>
                          <archive>
                              <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                          </archive>
                      </configuration>
                  </plugin>
              </plugins>
        </build>