1

我正在开发一个基于OSGISpring MVC应用程序,我正在使用Karaf来部署捆绑包。我的 spring MVC 应用程序是一个战争文件。我将捆绑文件放在部署目录中

karaf@root()> 网络:列表

身份证 | 状态 | 网络状态 | 水平 | Web-ContextPath | 姓名

125 | 活跃 | 部署 | 80 | /样品 | Tomcat 样本 (0) 168 | 活跃 | 部署 | 80 | /spring-kalees-mvc-主机 | spring-kalees-mvc-host (0.0.1.SNAPSHOT)

我有一个servlet(要验证捆绑包),其他的是 Spring

网址:http://*a****t:8181/spring-kalees-mvc-host/hello(Servlet 映射)工作正常 但是,网址:http://*a*****t:8181/ spring-kalees-mvc-host/osgi/osgi.htm(基于 Spring 的控制器)不工作

它抛出错误,例如,

HTTP 错误 503

访问 /spring-kalees-mvc-host/osgi/saySomething 时出现问题。原因:

    org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Class' for property 'contextClass'; nested exception is java.lang.IllegalArgumentException: Cannot find class [org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext]
Caused by:

org.eclipse.jetty.servlet.ServletHolder$1: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Class' for property 'contextClass'; nested exception is java.lang.IllegalArgumentException: Cannot find class [org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext]
    at org.eclipse.jetty.servlet.ServletHolder.makeUnavailable(ServletHolder.java:483)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:537)
    at org.eclipse.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:402)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:642)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1448)
    at org.ops4j.pax.web.service.internal.WelcomeFilesFilter.doFilter(WelcomeFilesFilter.java:192)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)

In karaf log file, There was a error entry like below :

org.ops4j.pax.web.pax-web-extender-war - 3.0.0.M3 | Registration exception. Skipping.
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener not found by org.danielsoft.learn.spring-kalees-mvc-host [167]
    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)[org.apache.felix.framework-4.0.3.jar:]
    at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)[org.apache.felix.framework-4.0.3.jar:]
    at 

我指定了类路径

<classpath>WEB-INF/lib,WEB-INF/lib/org.springframework.context-3.2.2.RELEASE.jar,WEB-INF/lib/org.springframework.context.support-3.2.2.RELEASE.jar,WEB-INF/classes/,.</classpath>

并用 lib 文件打包战争文件(WEB-INF/lib)

我的捆绑信息是

在此处输入图像描述

关于这个错误的任何想法?

4

0 回答 0