how to integrate springMVC with karaf

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

how to integrate springMVC with karaf

stream
This post was updated on .
Hi.
As subject, i've tried a long time for this integration.
but, always get various error,
for instance..

Problem accessing /springmvc/start.test. Reason:

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personDAO': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Class[]' for property 'interfaces'; nested exception is java.lang.IllegalArgumentException: Cannot find class [net.iocanel.database.dao.PersonDAO]
Caused by:

javax.servlet.UnavailableException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personDAO': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Class[]' for property 'interfaces'; nested exception is java.lang.IllegalArgumentException: Cannot find class [net.iocanel.database.dao.PersonDAO]
       
personDAO is the service from other bundle

<osgi:reference id="personDAO" interface="net.iocanel.database.dao.PersonDAO"/>

it could run other framework, for instance wicket, not in springmvc

and there is anther error!~~

HTTP ERROR 503

Problem accessing /springmvc/start.test. Reason:

    org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] for bean with name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0' defined in URL [bundle://158.0:0/WEB-INF/test-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.web.servlet.handler.SimpleUrlHandlerMapping not found from bundle [springmvc]
Caused by:

javax.servlet.UnavailableException: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] for bean with name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0' defined in URL [bundle://158.0:0/WEB-INF/test-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.web.servlet.handler.SimpleUrlHandlerMapping not found from bundle [springmvc]
       
i've put the org.springframework.web.servlet into the folder of deploy....


the web.xml

<?xml version="1.0" encoding="UTF-8"?>
<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_2_5.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        id="WebApp_ID" version="2.5">


        <servlet>
                <servlet-name>test</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>2</load-on-startup>
        </servlet>

        <servlet-mapping>
                <servlet-name>test</servlet-name>
                <url-pattern>*.test</url-pattern>
        </servlet-mapping>

        <context-param>
                <param-name>contextClass</param-name>
                <param-value>org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext</param-value>
        </context-param>

        <listener>
                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>

        <welcome-file-list>
                <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
</web-app>


and test-servlet.xml

        <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
                <property name="mappings">
                        <props>
                                <prop key="start.test">startContrller</prop>
                        </props>
                </property>
        </bean>
       
        <bean id="startContrller" class="cn.shopex.springmvc.StartController"></bean>
       
        <bean class="org.springframework.web.servlet.view.UrlBasedViewResolver">
                <property name="ViewClass" value="org.springframework.web.servlet.view.JstlView"></property>
                <property name="prefix" value="/WEB-INF/jsp/"></property>
                <property name="suffix" value=".jsp"></property>
        </bean>



someone could help me
thinks
Reply | Threaded
Open this post in threaded view
|

Re: how to integrate springMVC with karaf

jbonofre
Hi,

which kind of errors did you get ?

Regards
JB

On 03/31/2011 04:22 AM, stream wrote:
> Hi.
> As subject, i've tried a long time for this integration.
> but, always get various error, someone could give me guideline or a example
> thinks
Reply | Threaded
Open this post in threaded view
|

Re: how to integrate springMVC with karaf

Łukasz Dywicki
Hello,
First of all you need to change your context class to OsgiWebAppContext instead standard class. After that most of the errors dissapear.
I did some small test about 3 months before and it is pretty standard setup - Spring 3 + Spring WebMVC.

If you have some additional errors please share it. We may include Spring WebMVC demo in futher Karaf releases.

Best regards,
Lukasz

> Hi,
>
> which kind of errors did you get ?
>
> Regards
> JB
>
> On 03/31/2011 04:22 AM, stream wrote:
>> Hi.
>> As subject, i've tried a long time for this integration.
>> but, always get various error, someone could give me guideline or a example
>> thinks

Reply | Threaded
Open this post in threaded view
|

Re: how to integrate springMVC with karaf

Achim Nierbeck
Hi Lukasz,

that would be great :)

regards, Achim

2011/3/31 Łukasz Dywicki <[hidden email]>:

> Hello,
> First of all you need to change your context class to OsgiWebAppContext instead standard class. After that most of the errors dissapear.
> I did some small test about 3 months before and it is pretty standard setup - Spring 3 + Spring WebMVC.
>
> If you have some additional errors please share it. We may include Spring WebMVC demo in futher Karaf releases.
>
> Best regards,
> Lukasz
>
>> Hi,
>>
>> which kind of errors did you get ?
>>
>> Regards
>> JB
>>
>> On 03/31/2011 04:22 AM, stream wrote:
>>> Hi.
>>> As subject, i've tried a long time for this integration.
>>> but, always get various error, someone could give me guideline or a example
>>> thinks
>
>
Reply | Threaded
Open this post in threaded view
|

Re: how to integrate springMVC with karaf

Łukasz Dywicki
Hi all,
I found my old project. From details provided by steam it looks like there is no all required imports:

In my example I had following packages imported:

Core spring dependency
 org.springframework.context,
 org.springframework.context.support,

Spring DM web stuff
 org.springframework.osgi.web.context.support,

Servlet and mvc
 org.springframework.web.context,
 org.springframework.web.servlet,
 org.springframework.web.servlet.handler,
 org.springframework.web.servlet.i18n,
 org.springframework.web.servlet.view,
 org.springframework.web.servlet.view.document,
 org.springframework.web.servlet.view.json,
 org.springframework.web.servlet.view.feed,
 org.springframework.web.servlet.view.tiles2,
 org.springframework.web.servlet.theme,
 org.springframework.web.servlet.tags,
 org.springframework.web.servlet.tags.form,
 org.springframework.web.servlet.mvc,
 org.springframework.web.servlet.mvc.annotation,

If you use json features in Spring WebMVC
 org.codehaus.jackson,
 org.codehaus.jackson.map,


If you wish to use tiles
 org.apache.tiles,
 org.apache.tiles.preparer,
 org.apache.tiles.renderer.impl,
 org.apache.tiles.evaluator,
 org.apache.tiles.context,
 org.apache.tiles.renderer,
 org.apache.tiles.definition,
 org.apache.tiles.startup,
 org.apache.tiles.jsp.context,
 org.apache.tiles.jsp.taglib,
 org.apache.tiles.servlet.context,

The jstl stuff
 javax.servlet.jsp.jstl.core,
 javax.servlet.jsp.jstl.fmt,

Jstl implementation
 org.apache.taglibs.standard,
 org.apache.taglibs.standard.tlv,
 org.apache.taglibs.standard.tei,
 org.apache.taglibs.standard.tag.rt.core,
 org.apache.taglibs.standard.tag.rt.fmt,
 org.apache.taglibs.standard.tag.common.core,
 org.apache.taglibs.standard.tag.common.fmt,
 org.apache.taglibs.standard.functions,

In past version of pax-web I needed to embed taglibs and put them to web.xml. Maybe it is not required now:
<Embed-Dependency>*;scope=runtime|provided;inline=META-INF/*.tld|META-INF/tld/*

Some of these imports are not necessary, but you have them by default in spring bundles so it will work anyway.

Best regards,
Lukasz

> Hi Lukasz,
>
> that would be great :)
>
> regards, Achim
>
> 2011/3/31 Łukasz Dywicki <[hidden email]>:
>> Hello,
>> First of all you need to change your context class to OsgiWebAppContext instead standard class. After that most of the errors dissapear.
>> I did some small test about 3 months before and it is pretty standard setup - Spring 3 + Spring WebMVC.
>>
>> If you have some additional errors please share it. We may include Spring WebMVC demo in futher Karaf releases.
>>
>> Best regards,
>> Lukasz
>>
>>> Hi,
>>>
>>> which kind of errors did you get ?
>>>
>>> Regards
>>> JB
>>>
>>> On 03/31/2011 04:22 AM, stream wrote:
>>>> Hi.
>>>> As subject, i've tried a long time for this integration.
>>>> but, always get various error, someone could give me guideline or a example
>>>> thinks
>>
>>

Reply | Threaded
Open this post in threaded view
|

Re: how to integrate springMVC with karaf

Achim Nierbeck
With the latest version of Pax Web you might not need to embed the
taglibs anymore since I added the bundles which are imported to the
jasper classloader. This way it should be possible to get a hold on
those extra taglibs, unless the bundles which do contain those aren't
imported :)

regards, Achim

P.S. Lukasz we should put this somewhere in the karaf manual / howto
for a broader audience.

2011/3/31 Łukasz Dywicki <[hidden email]>:

> Hi all,
> I found my old project. From details provided by steam it looks like there is no all required imports:
>
> In my example I had following packages imported:
>
> Core spring dependency
>  org.springframework.context,
>  org.springframework.context.support,
>
> Spring DM web stuff
>  org.springframework.osgi.web.context.support,
>
> Servlet and mvc
>  org.springframework.web.context,
>  org.springframework.web.servlet,
>  org.springframework.web.servlet.handler,
>  org.springframework.web.servlet.i18n,
>  org.springframework.web.servlet.view,
>  org.springframework.web.servlet.view.document,
>  org.springframework.web.servlet.view.json,
>  org.springframework.web.servlet.view.feed,
>  org.springframework.web.servlet.view.tiles2,
>  org.springframework.web.servlet.theme,
>  org.springframework.web.servlet.tags,
>  org.springframework.web.servlet.tags.form,
>  org.springframework.web.servlet.mvc,
>  org.springframework.web.servlet.mvc.annotation,
>
> If you use json features in Spring WebMVC
>  org.codehaus.jackson,
>  org.codehaus.jackson.map,
>
>
> If you wish to use tiles
>  org.apache.tiles,
>  org.apache.tiles.preparer,
>  org.apache.tiles.renderer.impl,
>  org.apache.tiles.evaluator,
>  org.apache.tiles.context,
>  org.apache.tiles.renderer,
>  org.apache.tiles.definition,
>  org.apache.tiles.startup,
>  org.apache.tiles.jsp.context,
>  org.apache.tiles.jsp.taglib,
>  org.apache.tiles.servlet.context,
>
> The jstl stuff
>  javax.servlet.jsp.jstl.core,
>  javax.servlet.jsp.jstl.fmt,
>
> Jstl implementation
>  org.apache.taglibs.standard,
>  org.apache.taglibs.standard.tlv,
>  org.apache.taglibs.standard.tei,
>  org.apache.taglibs.standard.tag.rt.core,
>  org.apache.taglibs.standard.tag.rt.fmt,
>  org.apache.taglibs.standard.tag.common.core,
>  org.apache.taglibs.standard.tag.common.fmt,
>  org.apache.taglibs.standard.functions,
>
> In past version of pax-web I needed to embed taglibs and put them to web.xml. Maybe it is not required now:
> <Embed-Dependency>*;scope=runtime|provided;inline=META-INF/*.tld|META-INF/tld/*
>
> Some of these imports are not necessary, but you have them by default in spring bundles so it will work anyway.
>
> Best regards,
> Lukasz
>
>> Hi Lukasz,
>>
>> that would be great :)
>>
>> regards, Achim
>>
>> 2011/3/31 Łukasz Dywicki <[hidden email]>:
>>> Hello,
>>> First of all you need to change your context class to OsgiWebAppContext instead standard class. After that most of the errors dissapear.
>>> I did some small test about 3 months before and it is pretty standard setup - Spring 3 + Spring WebMVC.
>>>
>>> If you have some additional errors please share it. We may include Spring WebMVC demo in futher Karaf releases.
>>>
>>> Best regards,
>>> Lukasz
>>>
>>>> Hi,
>>>>
>>>> which kind of errors did you get ?
>>>>
>>>> Regards
>>>> JB
>>>>
>>>> On 03/31/2011 04:22 AM, stream wrote:
>>>>> Hi.
>>>>> As subject, i've tried a long time for this integration.
>>>>> but, always get various error, someone could give me guideline or a example
>>>>> thinks
>>>
>>>
>
>