title: Deployment of simple Spring web application on OSGI with Karaf
body: <p>I'm trying to run a simple Spring Web application on OSGI - Karaf 3.0.1 with no results.</p>
  
  <p>On my fresh Karaf instance I've installed following features:</p>
  
  <ul>
  <li>spring 4.0.2.RELEASE_1</li>
  <li>spring-web 4.0.2.RELEASE_1</li>
  <li>pax-http 3.0.1</li>
  <li>pax-war 3.0.1</li>
  <li>war 3.0.1</li>
  <li>pax-jetty 8.1.14.v20131031</li>
  </ul>
  
  <p>Here is my <strong><a href="http://pastebin.com/75fDSDZ9" rel="nofollow">pom.xml</a></strong>:</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;groupId&gt;co.chudy.kairos&lt;/groupId&gt;
  &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;spring-web Maven Webapp&lt;/name&gt;
  
  &lt;properties&gt;
      &lt;spring.version&gt;4.0.2.RELEASE&lt;/spring.version&gt;
      &lt;jdk.version&gt;1.7&lt;/jdk.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;junit&lt;/groupId&gt;
          &lt;artifactId&gt;junit&lt;/artifactId&gt;
          &lt;version&gt;3.8.1&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
          &lt;artifactId&gt;servlet-api&lt;/artifactId&gt;
          &lt;version&gt;2.5&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax.servlet.jsp&lt;/groupId&gt;
          &lt;artifactId&gt;jsp-api&lt;/artifactId&gt;
          &lt;version&gt;2.1&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.osgi&lt;/groupId&gt;
          &lt;artifactId&gt;spring-osgi-web&lt;/artifactId&gt;
          &lt;version&gt;1.2.1&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;build&gt;
      &lt;finalName&gt;spring-web&lt;/finalName&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;source&gt;${jdk.version}&lt;/source&gt;
                  &lt;target&gt;${jdk.version}&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.felix&lt;/groupId&gt;
              &lt;artifactId&gt;maven-bundle-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.5.0&lt;/version&gt;
              &lt;extensions&gt;true&lt;/extensions&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;bundle-manifest&lt;/id&gt;
                      &lt;phase&gt;process-classes&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;manifest&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;configuration&gt;
                  &lt;supportedProjectTypes&gt;
                      &lt;supportedProjectType&gt;war&lt;/supportedProjectType&gt;
                      &lt;supportedProjectType&gt;bundle&lt;/supportedProjectType&gt;
                      &lt;supportedProjectType&gt;jar&lt;/supportedProjectType&gt;
                  &lt;/supportedProjectTypes&gt;
                  &lt;instructions&gt;
                      &lt;Bundle-SymbolicName&gt;${project.artifactId}&lt;/Bundle-SymbolicName&gt;
                      &lt;Bundle-Name&gt;${project.name}&lt;/Bundle-Name&gt;
                      &lt;Bundle-Vendor&gt;Michal Chudy&lt;/Bundle-Vendor&gt;
                      &lt;Export-Package&gt;co.chudy.kairos.spring&lt;/Export-Package&gt;
                      &lt;Web-ContextPath&gt;kairos&lt;/Web-ContextPath&gt;
                      &lt;Bundle-ClassPath&gt;.,WEB-INF/classes,{maven-dependencies}&lt;/Bundle-ClassPath&gt;
                      &lt;Embed-Dependency&gt;*;scope=compile|runtime&lt;/Embed-Dependency&gt;
                  &lt;/instructions&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
              &lt;configuration&gt;
                  &lt;archive&gt;
                      &lt;manifestFile&gt;${project.build.outputDirectory}/META-INF/MANIFEST.MF&lt;/manifestFile&gt;
                  &lt;/archive&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
       id="WebApp_ID" version="3.0"&gt;
  &lt;display-name&gt;HelloWorldSpring&lt;/display-name&gt;
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;mvc-dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>mvc-dispatcher-servlet.xml</strong></p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
     xmlns:context="http://www.springframework.org/schema/context"
     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"&gt;
  
  &lt;bean name="/helloWorld.do" class="co.chudy.kairos.spring.Home"/&gt;
  
  &lt;bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property name="viewClass" value="org.springframework.web.servlet.view.JstlView" /&gt;
      &lt;property name="prefix" value="WEB-INF/views/" /&gt;
      &lt;property name="suffix" value=".jsp" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>
  
  <p>And I've tried lots of things and searched a lot and still I'm getting stacktraces about missing context classes. I've tried different web.xml and servlet configurations and each time it was the same error - missing class. I also tried different versions of spring features. </p>
  
  <p>Here is the stacktrace: (<a href="http://pastebin.com/5W1CAhD1" rel="nofollow">full karaf log</a>)</p>
  
  <pre><code>    2014-07-26 15:49:28,119 | INFO  | raf-3.0.1/deploy | fileinstall                      | 11 - org.apache.felix.fileinstall - 3.2.8 | Updated D:\apache-karaf-3.0.1\deploy\spring-web.war
  2014-07-26 15:49:28,439 | INFO  | raf-3.0.1/deploy | HttpServiceFactoryImpl           | 93 - org.ops4j.pax.web.pax-web-runtime - 3.1.0 | Binding bundle: [spring-web [210]] to http service
  2014-07-26 15:49:28,445 | INFO  | raf-3.0.1/deploy | fileinstall                      | 11 - org.apache.felix.fileinstall - 3.2.8 | Started bundle: file:/D:/apache-karaf-3.0.1/deploy/spring-web.war
  2014-07-26 15:49:28,502 | INFO  | pool-13-thread-1 | AppHttpContext{spring-web - 210} | 84 - org.eclipse.jetty.aggregate.jetty-all-server - 8.1.14.v20131031 | Initializing Spring FrameworkServlet 'mvc-dispatcher'
  2014-07-26 15:49:28,502 | INFO  | pool-13-thread-1 | DispatcherServlet                | 212 - org.apache.servicemix.bundles.spring-webmvc - 4.0.2.RELEASE_1 | FrameworkServlet 'mvc-dispatcher': initialization started
  2014-07-26 15:49:28,503 | INFO  | pool-13-thread-1 | XmlWebApplicationContext         | 207 - org.apache.servicemix.bundles.spring-context - 4.0.2.RELEASE_1 | Refreshing WebApplicationContext for namespace 'mvc-dispatcher-servlet': startup date [Sat Jul 26 15:49:28 CEST 2014]; root of context hierarchy
  2014-07-26 15:49:28,504 | INFO  | pool-13-thread-1 | XmlBeanDefinitionReader          | 205 - org.apache.servicemix.bundles.spring-beans - 4.0.2.RELEASE_1 | Loading XML bean definitions from ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]
  2014-07-26 15:49:28,526 | ERROR | pool-13-thread-1 | DispatcherServlet                | 212 - org.apache.servicemix.bundles.spring-webmvc - 4.0.2.RELEASE_1 | Context initialization failed
  org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.web.servlet.view.InternalResourceViewResolver] for bean with name 'viewResolver' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.web.servlet.view.InternalResourceViewResolver not found by org.ops4j.pax.web.pax-web-jetty [94]
      at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1327)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:594)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1396)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:959)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:680)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)[207:org.apache.servicemix.bundles.spring-context:4.0.2.RELEASE_1]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)[207:org.apache.servicemix.bundles.spring-context:4.0.2.RELEASE_1]
      at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)[212:org.apache.servicemix.bundles.spring-webmvc:4.0.2.RELEASE_1]
      at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)[212:org.apache.servicemix.bundles.spring-webmvc:4.0.2.RELEASE_1]
      at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)[212:org.apache.servicemix.bundles.spring-webmvc:4.0.2.RELEASE_1]
      at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)[212:org.apache.servicemix.bundles.spring-webmvc:4.0.2.RELEASE_1]
      at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)[212:org.apache.servicemix.bundles.spring-webmvc:4.0.2.RELEASE_1]
      at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)[212:org.apache.servicemix.bundles.spring-webmvc:4.0.2.RELEASE_1]
      at javax.servlet.GenericServlet.init(GenericServlet.java:161)[79:org.apache.geronimo.specs.geronimo-servlet_3.0_spec:1.0]
      at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:532)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:344)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:791)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doStart(HttpServiceContext.java:222)[94:org.ops4j.pax.web.pax-web-jetty:3.1.0]
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.ops4j.pax.web.service.jetty.internal.JettyServerImpl$1.start(JettyServerImpl.java:197)[94:org.ops4j.pax.web.pax-web-jetty:3.1.0]
      at org.ops4j.pax.web.service.internal.HttpServiceStarted.end(HttpServiceStarted.java:1032)[93:org.ops4j.pax.web.pax-web-runtime:3.1.0]
      at org.ops4j.pax.web.service.internal.HttpServiceProxy.end(HttpServiceProxy.java:422)[93:org.ops4j.pax.web.pax-web-runtime:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.RegisterWebAppVisitorWC.end(RegisterWebAppVisitorWC.java:341)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.model.WebApp.accept(WebApp.java:678)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.register(WebAppPublisher.java:237)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:182)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:135)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932)[karaf-org.osgi.core.jar:]
      at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:864)[karaf-org.osgi.core.jar:]
      at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[karaf-org.osgi.core.jar:]
      at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)[karaf-org.osgi.core.jar:]
      at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:317)[karaf-org.osgi.core.jar:]
      at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261)[karaf-org.osgi.core.jar:]
      at org.ops4j.pax.web.extender.war.internal.WebAppPublisher.publish(WebAppPublisher.java:101)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.WebObserver.deploy(WebObserver.java:213)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.WebObserver$1.doStart(WebObserver.java:175)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.extender.SimpleExtension.start(SimpleExtension.java:58)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.extender.AbstractExtender$1.run(AbstractExtender.java:266)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_55]
      at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_55]
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_55]
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_55]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_55]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_55]
      at java.lang.Thread.run(Thread.java:745)[:1.7.0_55]
  Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.view.InternalResourceViewResolver not found by org.ops4j.pax.web.pax-web-jetty [94]
      at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)[org.apache.felix.framework-4.2.1.jar:]
      at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)[org.apache.felix.framework-4.2.1.jar:]
      at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)[org.apache.felix.framework-4.2.1.jar:]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_55]
      at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1844)[org.apache.felix.framework-4.2.1.jar:]
      at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:937)[org.apache.felix.framework-4.2.1.jar:]
      at org.ops4j.pax.swissbox.core.BundleClassLoader.findClass(BundleClassLoader.java:176)[85:org.ops4j.pax.swissbox.core:1.6.0]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:425)[:1.7.0_55]
      at org.ops4j.pax.swissbox.core.BundleClassLoader.loadClass(BundleClassLoader.java:192)[85:org.ops4j.pax.swissbox.core:1.6.0]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_55]
      at org.springframework.util.ClassUtils.forName(ClassUtils.java:236)[203:org.apache.servicemix.bundles.spring-core:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:392)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1348)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1319)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      ... 47 more
  2014-07-26 15:49:28,528 | WARN  | pool-13-thread-1 | AppHttpContext{spring-web - 210} | 84 - org.eclipse.jetty.aggregate.jetty-all-server - 8.1.14.v20131031 | unavailable
  org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.web.servlet.view.InternalResourceViewResolver] for bean with name 'viewResolver' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.web.servlet.view.InternalResourceViewResolver not found by org.ops4j.pax.web.pax-web-jetty [94]
      at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1327)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:594)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1396)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:959)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:680)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)[207:org.apache.servicemix.bundles.spring-context:4.0.2.RELEASE_1]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)[207:org.apache.servicemix.bundles.spring-context:4.0.2.RELEASE_1]
      at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658)[212:org.apache.servicemix.bundles.spring-webmvc:4.0.2.RELEASE_1]
      at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624)[212:org.apache.servicemix.bundles.spring-webmvc:4.0.2.RELEASE_1]
      at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672)[212:org.apache.servicemix.bundles.spring-webmvc:4.0.2.RELEASE_1]
      at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543)[212:org.apache.servicemix.bundles.spring-webmvc:4.0.2.RELEASE_1]
      at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484)[212:org.apache.servicemix.bundles.spring-webmvc:4.0.2.RELEASE_1]
      at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)[212:org.apache.servicemix.bundles.spring-webmvc:4.0.2.RELEASE_1]
      at javax.servlet.GenericServlet.init(GenericServlet.java:161)[79:org.apache.geronimo.specs.geronimo-servlet_3.0_spec:1.0]
      at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:532)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.servlet.ServletHolder.doStart(ServletHolder.java:344)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:791)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.ops4j.pax.web.service.jetty.internal.HttpServiceContext.doStart(HttpServiceContext.java:222)[94:org.ops4j.pax.web.pax-web-jetty:3.1.0]
      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)[84:org.eclipse.jetty.aggregate.jetty-all-server:8.1.14.v20131031]
      at org.ops4j.pax.web.service.jetty.internal.JettyServerImpl$1.start(JettyServerImpl.java:197)[94:org.ops4j.pax.web.pax-web-jetty:3.1.0]
      at org.ops4j.pax.web.service.internal.HttpServiceStarted.end(HttpServiceStarted.java:1032)[93:org.ops4j.pax.web.pax-web-runtime:3.1.0]
      at org.ops4j.pax.web.service.internal.HttpServiceProxy.end(HttpServiceProxy.java:422)[93:org.ops4j.pax.web.pax-web-runtime:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.RegisterWebAppVisitorWC.end(RegisterWebAppVisitorWC.java:341)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.model.WebApp.accept(WebApp.java:678)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.register(WebAppPublisher.java:237)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:182)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.WebAppPublisher$WebAppDependencyListener.addingService(WebAppPublisher.java:135)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:932)[karaf-org.osgi.core.jar:]
      at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:864)[karaf-org.osgi.core.jar:]
      at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)[karaf-org.osgi.core.jar:]
      at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)[karaf-org.osgi.core.jar:]
      at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:317)[karaf-org.osgi.core.jar:]
      at org.osgi.util.tracker.ServiceTracker.open(ServiceTracker.java:261)[karaf-org.osgi.core.jar:]
      at org.ops4j.pax.web.extender.war.internal.WebAppPublisher.publish(WebAppPublisher.java:101)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.WebObserver.deploy(WebObserver.java:213)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.WebObserver$1.doStart(WebObserver.java:175)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.extender.SimpleExtension.start(SimpleExtension.java:58)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at org.ops4j.pax.web.extender.war.internal.extender.AbstractExtender$1.run(AbstractExtender.java:266)[136:org.ops4j.pax.web.pax-web-extender-war:3.1.0]
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)[:1.7.0_55]
      at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_55]
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)[:1.7.0_55]
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)[:1.7.0_55]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_55]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_55]
      at java.lang.Thread.run(Thread.java:745)[:1.7.0_55]
  Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.view.InternalResourceViewResolver not found by org.ops4j.pax.web.pax-web-jetty [94]
      at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)[org.apache.felix.framework-4.2.1.jar:]
      at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)[org.apache.felix.framework-4.2.1.jar:]
      at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)[org.apache.felix.framework-4.2.1.jar:]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_55]
      at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1844)[org.apache.felix.framework-4.2.1.jar:]
      at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:937)[org.apache.felix.framework-4.2.1.jar:]
      at org.ops4j.pax.swissbox.core.BundleClassLoader.findClass(BundleClassLoader.java:176)[85:org.ops4j.pax.swissbox.core:1.6.0]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:425)[:1.7.0_55]
      at org.ops4j.pax.swissbox.core.BundleClassLoader.loadClass(BundleClassLoader.java:192)[85:org.ops4j.pax.swissbox.core:1.6.0]
      at java.lang.ClassLoader.loadClass(ClassLoader.java:358)[:1.7.0_55]
      at org.springframework.util.ClassUtils.forName(ClassUtils.java:236)[203:org.apache.servicemix.bundles.spring-core:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:392)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1348)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1319)[205:org.apache.servicemix.bundles.spring-beans:4.0.2.RELEASE_1]
      ... 47 more
  </code></pre>
  
  <p>But sometime the missing class was <strong>OsgiBundleXmlWebApplicationContext</strong> or <strong>ContextNamespaceHandler</strong>.</p>
  
  <p>Any ideas what am I doing wrong?</p>