You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Tim Jones <ti...@mccarthy.co.nz> on 2016/09/07 22:51:03 UTC

SpringMVC V4 + Karaf

Hi,

I am looking for a solution for integrating a war based upon SpringMVC V4+
with Karaf/Jetty. Currently we have a working web app based upon
SpringMVC/Security/Mobile V3 that uses SpringDM running on Karaf 2.3.2. We
would like to continue with Spring but upgrade to version 4.

I was wondering if perhaps Achim with your pax-web experience or others had
any thoughts on the following approach. By instructing the
maven-bundle-plugin to use <Spring-Context> instead of <Bundle-Blueprint>
then the blueprint-spring-extender
(https://github.com/apache/aries/tree/trunk/blueprint/blueprint-spring-extender,
thanks Guillaume) would be used to process the Spring namespaced config file
e.g

<plugin>
   <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <configuration>
       <instructions>
          <Spring-Context>WEB-INF/track-trace-servlet.xml</Spring-Context>   

This much I have done and I can log the Spring beans in the application
context and the osgi services to the Karaf console.

However the Spring DispatcherServlet still needs to be registered and I
thought that this could perhaps be achieved by programmatically implementing
Springs WebApplicationInitializer
(http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/WebApplicationInitializer.html).
Assuming that the servlet container was able to find the class implementing
the WebApplicationInitializer would this be sufficient? If so, any pointers
on how to coax the servlet container to scan and find the customised
WebApplicationInitializer? 

Thanks,

Tim







--
View this message in context: http://karaf.922171.n3.nabble.com/SpringMVC-V4-Karaf-tp4047917.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: SpringMVC V4 + Karaf

Posted by Morgan Hautman <mo...@gmail.com>.
Hi Tim,

Did you had any success following this approach?

Regards,
Morgan

Re: SpringMVC V4 + Karaf

Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi Tim,

sounds like a good approach. The custom WebApplicationInitializer should be
instantiated by the War Extender as it's a
regular ServletContainerInitializer.
An OutOfTheBox solution for this isn't available yet, but maybe it can be
generalized and either be provided by Karaf/Aries or Pax-Web :D

regards, Achim



2016-09-08 0:51 GMT+02:00 Tim Jones <ti...@mccarthy.co.nz>:

> Hi,
>
> I am looking for a solution for integrating a war based upon SpringMVC V4+
> with Karaf/Jetty. Currently we have a working web app based upon
> SpringMVC/Security/Mobile V3 that uses SpringDM running on Karaf 2.3.2. We
> would like to continue with Spring but upgrade to version 4.
>
> I was wondering if perhaps Achim with your pax-web experience or others had
> any thoughts on the following approach. By instructing the
> maven-bundle-plugin to use <Spring-Context> instead of <Bundle-Blueprint>
> then the blueprint-spring-extender
> (https://github.com/apache/aries/tree/trunk/blueprint/
> blueprint-spring-extender,
> thanks Guillaume) would be used to process the Spring namespaced config
> file
> e.g
>
> <plugin>
>    <groupId>org.apache.felix</groupId>
>     <artifactId>maven-bundle-plugin</artifactId>
>     <configuration>
>        <instructions>
>           <Spring-Context>WEB-INF/track-trace-servlet.xml</Spring-Context>
>
> This much I have done and I can log the Spring beans in the application
> context and the osgi services to the Karaf console.
>
> However the Spring DispatcherServlet still needs to be registered and I
> thought that this could perhaps be achieved by programmatically
> implementing
> Springs WebApplicationInitializer
> (http://docs.spring.io/spring/docs/current/javadoc-api/org/
> springframework/web/WebApplicationInitializer.html).
> Assuming that the servlet container was able to find the class implementing
> the WebApplicationInitializer would this be sufficient? If so, any pointers
> on how to coax the servlet container to scan and find the customised
> WebApplicationInitializer?
>
> Thanks,
>
> Tim
>
>
>
>
>
>
>
> --
> View this message in context: http://karaf.922171.n3.nabble.
> com/SpringMVC-V4-Karaf-tp4047917.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
>



-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master