Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Any examples of OSGi-fied Spring MVC app
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Dmitriy Kopylenko  
View profile  
 More options Feb 15 2008, 8:13 am
From: "Dmitriy Kopylenko" <dima...@gmail.com>
Date: Fri, 15 Feb 2008 08:13:25 -0500
Local: Fri, Feb 15 2008 8:13 am
Subject: Any examples of OSGi-fied Spring MVC app

Hello gang.

I'm just wondering, are there any publicly available examples of OSGi-fied
Spring MVC web app., and especially with detailed instructions on how to
integrate and deploy OSGi runtime to Tomcat?

Is it even possible today to have typical Spring MVC apps (with
DispatcherServlet and all that) to be deployed in Tomcat and have shared
OSGi services running and shared amongst them, without any trickery like
Equinox HttpServletBridge, etc.

I'm new to OSGi, so please don't judge my question too much :-)

Regards,
Dmitriy.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gerd Wütherich  
View profile  
 More options Feb 15 2008, 8:45 am
From: "Gerd Wütherich" <g...@gerd-wuetherich.de>
Date: Fri, 15 Feb 2008 14:45:35 +0100
Local: Fri, Feb 15 2008 8:45 am
Subject: Re: Any examples of OSGi-fied Spring MVC app

Hey Dmitriy,

Bernd Kolb has ported Jürgen Höllers jPetStore to SpringDM:

http://thegoodthebadtheugly.wordpress.com/2007/05/20/springosgi/

Regards,
Gerd

2008/2/15, Dmitriy Kopylenko <dima...@gmail.com>:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Lippert  
View profile  
 More options Feb 15 2008, 9:43 am
From: Martin Lippert <lipp...@acm.org>
Date: Fri, 15 Feb 2008 15:43:44 +0100
Local: Fri, Feb 15 2008 9:43 am
Subject: Re: Any examples of OSGi-fied Spring MVC app
Hi Dmitriy,

if you don't what to use the servlet bridge you should think about
running your container inside OSGi instead of the standard tomcat. Then
you use the OSGi runtime as underlying technology and deploy your
servlet container (for example) as OSGi bundle, as well as your apps and
services. In this setting you can easily share services and bundles
across different web apps.

As far as I know you can use Jetty as OSGi bundle right out of the box.
Letting tomcat run within an OSGi bundle might be more complicated but
it possible as well, I think.

HTH,
Martin


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dmitriy Kopylenko  
View profile  
 More options Feb 15 2008, 10:05 am
From: "Dmitriy Kopylenko" <dima...@gmail.com>
Date: Fri, 15 Feb 2008 10:05:29 -0500
Local: Fri, Feb 15 2008 10:05 am
Subject: Re: Any examples of OSGi-fied Spring MVC app

Martin,

thanks for the clarification.

Dmitriy.

2008/2/15, Martin Lippert <lipp...@acm.org>:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dmitriy Kopylenko  
View profile  
 More options Feb 15 2008, 10:06 am
From: "Dmitriy Kopylenko" <dima...@gmail.com>
Date: Fri, 15 Feb 2008 10:06:02 -0500
Local: Fri, Feb 15 2008 10:06 am
Subject: Re: Any examples of OSGi-fied Spring MVC app

Gerd,

thanks for the pointer. I'll take a look.

Dmitriy.

2008/2/15, Gerd Wütherich <g...@gerd-wuetherich.de>:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ulrik Sandberg  
View profile  
 More options Mar 7 2008, 2:00 pm
From: Ulrik Sandberg <ulrik.sandb...@gmail.com>
Date: Fri, 7 Mar 2008 11:00:15 -0800 (PST)
Local: Fri, Mar 7 2008 2:00 pm
Subject: Re: Any examples of OSGi-fied Spring MVC app
Is there any hope of getting Bernd Kolb's utilities to run on Spring
DM 1.0.1? The reason I ask is that I have already tried and get into
problems with a null bundle in OsgiBundleResource.<init>. I had to
comment out a call to LocalBundleContext.setContext in his
BundleContextLoader, since that method is no longer accessible in more
recent versions of Spring DM. It might very well be caused by that,
but I can't say for sure.

Would it be better to try out the upcoming web support in Spring DM?
It seems to be in SVN, but I don't know if it's usable at this stage.

--
Ulrik

Here is the stack trace:

java.lang.IllegalArgumentException: Bundle must not be null
        at org.springframework.util.Assert.notNull(Assert.java:112)
        at
org.springframework.osgi.io.OsgiBundleResource.<init>(OsgiBundleResource.ja va:
118)
        at
org.springframework.osgi.io.OsgiBundleResourcePatternResolver.getResources( OsgiBundleResourcePatternResolver.java:
102)
        at
org.springframework.context.support.AbstractApplicationContext.getResources (AbstractApplicationContext.java:
1019)
        at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.load BeanDefinitions(AbstractBeanDefinitionReader.java:
177)
        at
org.springframework.beans.factory.support.AbstractBeanDefinitionReader.load BeanDefinitions(AbstractBeanDefinitionReader.java:
149)
        at
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDe finitions(XmlWebApplicationContext.java:
124)
        at
org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDe finitions(XmlWebApplicationContext.java:
92)
        at
org.springframework.context.support.AbstractRefreshableApplicationContext.r efreshBeanFactory(AbstractRefreshableApplicationContext.java:
123)
        at
org.springframework.context.support.AbstractApplicationContext.obtainFreshB eanFactory(AbstractApplicationContext.java:
423)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(Abst ractApplicationContext.java:
353)
        at
org.example.util.spring.osgi.context.OSGiDispatcherServlet.createWebApplica tionContext(OSGiDispatcherServlet.java:
65)
        at
org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext( FrameworkServlet.java:
292)
        at
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkS ervlet.java:
262)
        at
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:
126)
        at javax.servlet.GenericServlet.init(GenericServlet.java:241)
        at
org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:
433)
        ... 35 more

Here is the commented line:

...
import
org.springframework.osgi.service.importer.support.LocalBundleContext;
...
/**
 * A {@link ContextLoader} which creates a {@link
OSGiGenericApplicationContext} for
 * the given {@link BundleContext}
 *
 * @author Bernd Kolb
 *
 */
public class BundleContextLoader extends ContextLoader {
        ...
        protected WebApplicationContext createWebApplicationContext(
                        ServletContext servletContext, ApplicationContext parent)
                        throws BeansException {
                ClassLoader contextClassLoader = Thread.currentThread()
                                .getContextClassLoader();
                try {
                        ClassLoader cl = BundleDelegatingClassLoader
                                        .createBundleClassLoaderFor(ctx.getBundle(), getClass()
                                                        .getClassLoader());
                        Thread.currentThread().setContextClassLoader(cl);
                        //LocalBundleContext.setContext(ctx);
                        OSGiGenericApplicationContext appContext = new
OSGiGenericApplicationContext(ctx, parent, servletContext);
                        appContext.refresh();
                        return appContext;
                } finally {
                        Thread.currentThread().setContextClassLoader(contextClassLoader);
                }
        }

On 15 Feb, 14:45, "Gerd Wütherich" <g...@gerd-wuetherich.de> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alin Dreghiciu  
View profile  
 More options Mar 7 2008, 4:19 pm
From: "Alin Dreghiciu" <adreghi...@gmail.com>
Date: Sat, 8 Mar 2008 05:19:54 +0800
Local: Fri, Mar 7 2008 4:19 pm
Subject: Re: Any examples of OSGi-fied Spring MVC app
Hi Dimitriy,

To have an non OSGi Spring MVC app running in OSGi is very easy to
accomplish by using Pax Web War Extender:
http://wiki.ops4j.org/confluence/x/OQJN.
It is also an example of how easy is to do that based on Spring
Petclinic here:
http://wiki.ops4j.org/confluence/display/ops4j/Pax+Web+Extender+-+War...

As they run under osgi you can use in your war manifest all the normal
osgi headers so you can import the required packages and you then do
not need to have your classes available in WEB-INF/classes or in a jar
n WEB-INF/lib. If you need access to service registry to get services
from another bundle you just have to implement a bundle activator and
specify the activator in war manifest as for any other bundle. The
trick is how you pass the bundle context to your
servlets/filters/listeners or anything that needs it, but it shouldn't
be to hard as a simple singleton may do the trick. If you find it just
raise an issue on pax extender jira and I can publish the bundle
context as a servlet context attribute or we can do the in the spring
way by injecting into servlets/listeners/filters if they implement
something like BundleContextAware.

But I guess the nicest part would be that the actual application
context used by ServletDispatcher(FrameworkServlet) would be the
application context created by Spring DM. I didn't had a deep look
into it (nor I'm to much of an expert of Spring MVC) but It shouldn't
be to hard to obtain that as I recall that FrameworkServlet supports
some customization regarding the application context creation, so
somehow it should be possible to make it use the app context created
by spring extender.
Is not on my priorities right now, so feel free to experiment ad let
me know if you need some kind of support form pax web / pax web
extender.

Ulrik, as you are now into this why not trying this?

Alin


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Conde  
View profile  
 More options Apr 17 2008, 6:58 am
From: David Conde <i...@javadeveloper.eu>
Date: Thu, 17 Apr 2008 03:58:16 -0700 (PDT)
Local: Thurs, Apr 17 2008 6:58 am
Subject: Re: Any examples of OSGi-fied Spring MVC app
I'm currently trying to achieve the same thing here. I have pax-web
with a web application deployed and another bundle that exports an
OSGi service using Spring DM. I'm currently having trouble injecting
the service reference into a servlet filter due to the fact that I
cannot obtain a Context in the filter to perform the injection. Any
suggestions would be great.

Thanks,
Dave

On Mar 7, 10:19 pm, "Alin Dreghiciu" <adreghi...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Matt Raible  
View profile  
 More options Apr 17 2008, 11:45 am
From: "Matt Raible" <mrai...@gmail.com>
Date: Thu, 17 Apr 2008 09:45:13 -0600
Local: Thurs, Apr 17 2008 11:45 am
Subject: Re: Any examples of OSGi-fied Spring MVC app
I have Spring MVC 2.5.3 working with Spring DM 2.0 M2. From what I can
tell, Spring MVC's annotations are not supported by the Spring DM web
bundle. Moving my controllers to having bean definitions in my
*-servlet.xml solved the problem. Is this a missing feature of 2.0 M2?

On a related note, I was able to get things working with a JstlView,
but not with FreeMarker. When I tried adding FreeMarker to the mix,
the following error occurs. Note that my app works fine with "mvn jetty:run".

SEVERE: Servlet /myapp threw load() exception
java.lang.NoClassDefFoundError: org/xml/sax/helpers/DefaultHandler
       at org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer.setSer vletContext(FreeMarkerConfigurer.java:101)
       at org.springframework.web.context.support.ServletContextAwareProcessor.postPr ocessBeforeInitialization(ServletContextAwareProcessor.java:75)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactor y.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFa ctory.java:350)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactor y.initializeBean(AbstractAutowireCapableBeanFactory.java:1329)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactor y.doCreateBean(AbstractAutowireCapableBeanFactory.java:471)

I tried adding xercesImpl to my MANIFEST.MF (the version Spring uses
to build with) but it didn't seem to help.

Any advice?

Thanks,

Matt

--
http://raibledesigns.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Costin Leau  
View profile  
 More options Apr 17 2008, 11:54 am
From: Costin Leau <costin.l...@gmail.com>
Date: Thu, 17 Apr 2008 18:54:10 +0300
Local: Thurs, Apr 17 2008 11:54 am
Subject: Re: Any examples of OSGi-fied Spring MVC app
Matt Raible wrote:
> I have Spring MVC 2.5.3 working with Spring DM 2.0 M2. From what I can
> tell, Spring MVC's annotations are not supported by the Spring DM web
> bundle. Moving my controllers to having bean definitions in my
> *-servlet.xml solved the problem. Is this a missing feature of 2.0 M2?

No - component scanning (as well as classpath: and classpath*:) works
however, due to a loading problem, meta-annotations are not discovered
in an OSGI environment when using Spring 2.5.3. @Component works but
@Controller does not.
However, this is fixed in Spring HEAD (upcoming 2.5.4).

Haven't encountered this problem but you can just add an optional import
  (as Spring-DM does) and you should be set:

Import-Package: org.xml.sax;resolution:=optional,
org.xml.sax.helpers;resolution:=optional

Hope this helps,

--
Costin Leau
Senior Software Engineer
SpringSource (formerly Interface21) Limited - Spring Services from the
Source
Email: costin.l...@SpringSource.com
http://www.SpringSource.com
Registered in England and Wales: No. 5187766
Registered Office: A2 Yeoman Gate, Yeoman Way, Worthing, West Sussex,
BN13 3QZ, UK

This e-mail and any attachments transmitted with it are strictly
confidential and intended solely for the person or entity to whom they
are addressed. Unauthorised use, copying, disclosure or distribution is
prohibited. If you receive this e-mail in error please notify the sender
immediately and then delete it along with any attachments. E-mails
should be checked by the recipient to ensure that there are no viruses
and SpringSource does not accept any responsibility if this is not done.
Any views or opinions presented are solely those of the author and do
not necessarily represent those of SpringSource.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google