Spring MVC with Karaf

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Spring MVC with Karaf

kaleeswaran14
I tried to develop the OSGI based spring mvc application. I am using karaf for deploying the bundle.

I placed the dependency jar (org.springframework.*) into the deploy folder and placed my Spring MVC war file inside the deploy folder.

I am getting the error like in UI,
=====================
HTTP ERROR 500

Problem accessing /spring-kalees-mvc-host/osgi/osgi.htm. Reason:

Failed properties: 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.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (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.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:468)

I opened the log file and I saw that ,
============================

2013-09-11 00:14:47,187 | INFO | BundleWatcher: 2 | HttpServiceFactoryImpl | 90 – org.ops4j.pax.web.pax-web-runtime – 3.0.0.M3 | Binding bundle: [org.danielsoft.learn.spring-kalees-mvc-host [142]] to http service
2013-09-11 00:14:47,218 | ERROR | BundleWatcher: 2 | RegisterWebAppVisitorWC | 103 – 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 [142]
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:]

I am using the spring 3.2.2.RELEASE.

My bundle information :
===================

Bundle Classpath WEB-INF/classes/,.
Exported Packages org.springframework.osgi.sample.web,version=0.0.1.SNAPSHOT
Imported Packages javax.servlet,version=2.6.0 from org.apache.geronimo.specs.geronimo-servlet_3.0_spec (76)
javax.servlet,version=3.0.0 from org.apache.geronimo.specs.geronimo-servlet_3.0_spec (76)
javax.servlet.http,version=2.6.0 from org.apache.geronimo.specs.geronimo-servlet_3.0_spec (76)
javax.servlet.http,version=3.0.0 from org.apache.geronimo.specs.geronimo-servlet_3.0_spec (76)
org.springframework.stereotype,version=3.2.2.RELEASE from org.springframework.context (124)
org.springframework.web.bind.annotation,version=3.2.2.RELEASE from org.springframework.web (119)
org.springframework.web.servlet,version=3.2.2.RELEASE from org.springframework.web.servlet (116)
Service ID 430 Types: javax.servlet.ServletContext
Manifest Headers Archiver-Version: Plexus Archiver
Bnd-LastModified: 1378838240046
Build-Jdk: 1.6.0_26
Built-By: rajeshkumar_ra
Bundle-Classpath: WEB-INF/classes/, .
Bundle-ManifestVersion: 2
Bundle-Name: spring-kalees-mvc-host
Bundle-SymbolicName: org.danielsoft.learn.spring-kalees-mvc-host
Bundle-Version: 0.0.1.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Export-Package: org.springframework.osgi.sample.web; uses:=”javax.servlet.http, org.springframework.stereotype, org.springframework.web.bind.annotation, org.springframework.web.servlet”; version=”0.0.1.SNAPSHOT”
Import-Package: javax.servlet, javax.servlet.http, org.springframework.stereotype; version=”[3.2, 4)”, org.springframework.web.bind.annotation; version=”[3.2, 4)”, org.springframework.web.servlet; version=”[3.2, 4)”
Manifest-Version: 1.0
Tool: Bnd-2.1.0.20130426-122213
Webapp-Context: spring-kalees-mvc-host

Any idea on this error ? Thanks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Spring MVC with Karaf

richardsenior
did you get this sorted.
I have the same issue.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Spring MVC with Karaf

richardsenior
In reply to this post by kaleeswaran14
Found the solution...
For some reason putting spring-osgi-web in your maven dependencies doesn't put it in the imports of your manifest.
You have to explicitely add it :

 <Import-Package>
                    *,
                        org.springframework.osgi.web.context.support; version="[1.2,2.0)"
</Import-Package> 
Loading...