【问题标题】:Issue in deploying spring mvc project on Jboss Fuse在 Jboss Fuse 上部署 spring mvc 项目的问题
【发布时间】:2016-05-21 14:46:17
【问题描述】:

我使用 Maven 创建了一个示例 Web 应用程序 (Spring MVC) 项目。我正在尝试将它部署在 Jboss fuse 容器上,但遇到一个错误或其他错误。

我已经使用 spring mvc 来创建 webapp。 web.xml、dispatcher servlet、控制器代码和 pom.xml 已附在下面: 我创建了一个新的 jboss fuse 实例并安装了以下捆绑包以支持 spring mvc 功能

install -s mvn:org.aopalliance/com.springsource.org.aopalliance/1.0.0
features:install spring-dm

要部署战争文件,我使用以下命令:

install war:mvn:com.proj.myproj.dsp/HelloWeb/0.0.1-SNAPSHOT/war?Web-ContextPath=HelloWeb

但该捆绑包仍处于已安装状态。当我尝试强制重启时,出现此错误

org.eclipse.jetty.aggregate.jetty-all-server - 8.1.14.v20131031 | FAILED HelloWeb: java.lang.NoSuchMethodError: org.springframework.core.GenericTypeResolver.resolveTypeArguments(Ljava/lang/Class;Ljava/lang/Class;)[Ljava/lang/Class;
java.lang.NoSuchMethodError: org.springframework.core.GenericTypeResolver.resolveTypeArguments(Ljava/lang/Class;Ljava/lang/Class;)[Ljava/lang/Class;
    at org.springframework.core.convert.support.GenericConversionService.getRequiredTypeInfo(GenericConversionService.java:260)

请指出我在这里犯了什么错误。本项目代码如下:

Pom.xml(快照)

<groupId>com.proj.myproj</groupId>
  <artifactId>HelloWeb</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>HelloWeb Maven Webapp</name>
  <url>http://maven.apache.org</url>

  <packaging>war</packaging>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Import-Package>
              *
            </Import-Package>
          </instructions>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.2.8.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.2.8.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.2.8.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.osgi</groupId>
        <artifactId>spring-osgi-web</artifactId>
        <version>1.2.1</version>
    </dependency>

  </dependencies>

Web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4"
   xmlns="http://java.sun.com/xml/ns/j2ee" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

   <display-name>Spring MVC Application</display-name>

   <servlet>
      <servlet-name>HelloWeb</servlet-name>
      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      <init-param>
            <param-name>contextClass</param-name>
            <param-value>org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext</param-value>
      </init-param>
      <load-on-startup>1</load-on-startup>
   </servlet>

   <servlet-mapping>
      <servlet-name>HelloWeb</servlet-name>
      <url-pattern>/</url-pattern>
   </servlet-mapping>

</web-app>

调度程序小服务程序

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
   http://www.springframework.org/schema/beans     
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/context 
   http://www.springframework.org/schema/context/spring-context-3.0.xsd">

   <context:component-scan base-package="com.tutorialspoint" />

   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/WEB-INF/jsp/" />
      <property na***strong text***me="suffix" value=".jsp" />
   </bean>

</beans>

控制器

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.ui.ModelMap;

@Controller
@RequestMapping("/hello")
public class HelloController{

   @RequestMapping(method = RequestMethod.GET)
   public String printHello(ModelMap model) {
      System.out.println("Request comes to controller");
      model.addAttribute("message", "Hello Spring MVC Framework!");

      return "hello";
   }

}

如果您需要任何其他详细信息,请告诉我。

【问题讨论】:

    标签: spring-mvc osgi jbossfuse


    【解决方案1】:

    NoSuchMethodError 的原因几乎是由于库版本冲突。在这种情况下,我猜测有多个版本的 spring 库。使用osgi:list 列出已安装的捆绑包。

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2019-03-10
      • 1970-01-01
      • 2011-08-27
      • 2013-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-19
      相关资源
      最近更新 更多