Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Can Spring be used in host and in snaps?
Can Spring be used in host and in snaps? [message #997561] Tue, 08 January 2013 10:17 Go to next message
Bojan Kraut is currently offline Bojan KrautFriend
Messages: 22
Registered: July 2009
Location: Maribor
Junior Member

I'm trying to make a working example using Spring in host and snaps. I'd like to define spring just in host and use that in snaps. Is this possible?

No matter what I do I constantly get this error:

java.lang.NullPointerException
	org.eclipse.virgo.snaps.core.internal.webapp.SnapServletContext.getResource(SnapServletContext.java:198)
	org.eclipse.virgo.snaps.core.internal.webapp.StaticResourceServlet.doGet(StaticResourceServlet.java:58)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:735)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
	org.eclipse.virgo.snaps.core.internal.webapp.container.ImmutableFilterChain.doFilter(ImmutableFilterChain.java:47)
	org.eclipse.virgo.snaps.core.internal.webapp.container.StandardVirtualContainerRequestDispatcher$1.doWithClassLoader(StandardVirtualContainerRequestDispatcher.java:104)
	org.eclipse.virgo.snaps.core.internal.webapp.container.StandardVirtualContainerRequestDispatcher$1.doWithClassLoader(StandardVirtualContainerRequestDispatcher.java:1)
	org.eclipse.virgo.snaps.core.internal.webapp.container.StandardVirtualContainerRequestDispatcher.doWithThreadContextClassLoader(StandardVirtualContainerRequestDispatcher.java:121)
	org.eclipse.virgo.snaps.core.internal.webapp.container.StandardVirtualContainerRequestDispatcher.service(StandardVirtualContainerRequestDispatcher.java:101)
	org.eclipse.virgo.snaps.core.internal.webapp.WebAppSnap.handleRequest(WebAppSnap.java:152)
	org.eclipse.virgo.snaps.core.RequestRouter.service(RequestRouter.java:51)
	org.eclipse.virgo.snaps.core.SnapHostFilter.doFilter(SnapHostFilter.java:62)


As docs are really poor I have no idea, how to proceed.

What resource should whould be returned by SnapServletContext.getResource?
Re: Can Spring be used in host and in snaps? [message #998292 is a reply to message #997561] Wed, 09 January 2013 18:36 Go to previous messageGo to next message
Chris Frost is currently offline Chris FrostFriend
Messages: 230
Registered: January 2010
Location: Southampton, England
Senior Member

Hi,

Have you tried deploying the sample application that comes with Snaps, the source code is included. Also, there is some documentation that ships with Snaps or have you found that and find it to be poor. It is fine to say so Smile

Using Spring with the host and its snaps or just one of them should work fine. The fact it's come out as a NPE in the Snaps code looks like a Bug. Can you describe your application a little more, web.xml and manifests etc... Also, have you got the Snaps sample app working?

Chris.


------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
Re: Can Spring be used in host and in snaps? [message #998296 is a reply to message #998292] Wed, 09 January 2013 18:40 Go to previous messageGo to next message
Chris Frost is currently offline Chris FrostFriend
Messages: 230
Registered: January 2010
Location: Southampton, England
Senior Member

I've just re-read your other thread, I'm sorry no one has come forward to look at this.
I will spend some time tomorrow having a look. Could you provide the sample application as a '.zip' please.

Thanks, Chris.


------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
Re: Can Spring be used in host and in snaps? [message #998572 is a reply to message #998296] Thu, 10 January 2013 09:16 Go to previous messageGo to next message
Bojan Kraut is currently offline Bojan KrautFriend
Messages: 22
Registered: July 2009
Location: Maribor
Junior Member

I created an archive directly from my STS. With snap and host project.
I hope it helps.
Re: Can Spring be used in host and in snaps? [message #998785 is a reply to message #998572] Thu, 10 January 2013 17:45 Go to previous messageGo to next message
Chris Frost is currently offline Chris FrostFriend
Messages: 230
Registered: January 2010
Location: Southampton, England
Senior Member

Hi,

Thanks for the ZIP I am having a look at it now. Are you running on Java7, there are some known issues to do with that but it should be fine, worth checking your version though. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=382710

Chris


------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
Re: Can Spring be used in host and in snaps? [message #998805 is a reply to message #998785] Thu, 10 January 2013 18:11 Go to previous messageGo to next message
Chris Frost is currently offline Chris FrostFriend
Messages: 230
Registered: January 2010
Location: Southampton, England
Senior Member

I can't build it as I'm missing the parent POM. I have spotted a few things just having a look around.

* I don't know what the 'Webapp-Context: objectverse' manifest entry is for, should be harmless though.
* The host bundle is giving the 'Bundle-Classpath' twice with different values, no way of knowing which one it will actually use.

The host looks to be well setup but the snap has nothing in the web.xml, it's all commented out. I don't know how you expect it to find any of the ***-context.xml files in the snap. I think (if my memory is working) that Blueprint won't look for Spring contexts in the WEB-INF folder and Tomcat won't look for anything as the web.xml is empty. Spring context files should go under META-INF. This may seem annoying but we have to make sure that Blueprint and the Servlet container don't try and read the same context files as you get duplicates/races etc... and it just won't work.

I've also hunted the NPE down, this is a bug on our part but it isn't clear what is causing it. I have raised a bug that you might like to follow,
https://bugs.eclipse.org/bugs/show_bug.cgi?id=397902

Sorry I haven't got a straight fix for you.

Chris.


------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.

[Updated on: Thu, 10 January 2013 18:12]

Report message to a moderator

Re: Can Spring be used in host and in snaps? [message #998816 is a reply to message #998805] Thu, 10 January 2013 18:42 Go to previous messageGo to next message
Bojan Kraut is currently offline Bojan KrautFriend
Messages: 22
Registered: July 2009
Location: Maribor
Junior Member

Hi,

I tried several configurations for host and snaps. Redundant declarations of classpath stayed there by accident. I suspected, that if I declare Spring configuration in host that it would be sufficient also for snaps.
I created host - snap without Spring successfully, but with Spring configuration it just doesn't work.
If each snap should have all the Spring declations that would be impossible to maintain as one web application can consist from several modules (can be hundreds). From my point of view, snaps should see host configuration and just extend it. From what I read the configuration is merged. In my case snap shoul use declarations from the host.
Re: Can Spring be used in host and in snaps? [message #999069 is a reply to message #998816] Fri, 11 January 2013 09:18 Go to previous messageGo to next message
Bojan Kraut is currently offline Bojan KrautFriend
Messages: 22
Registered: July 2009
Location: Maribor
Junior Member

Hi,

Thank you for all your time. I created now a test application, where both host and snaps are working in Spring.
However both also declare Spring configuration. This way Dispatcher Servlet must be defined in all the modules and also the configuration must be specified for each module separately. This is impossible when having lot of modules as I stated in my previous answer.
Is it possible to use shared configuration on modules? And that modules possibly extend the host configuration?

[Updated on: Fri, 11 January 2013 09:19]

Report message to a moderator

Re: Can Spring be used in host and in snaps? [message #999093 is a reply to message #999069] Fri, 11 January 2013 10:26 Go to previous messageGo to next message
Chris Frost is currently offline Chris FrostFriend
Messages: 230
Registered: January 2010
Location: Southampton, England
Senior Member

Hi,

I'm glad you have it working. I have looked again at the docs and Snaps code. To clarify:

The host and all its snaps require all their own setup, it is wrong to force the setup of the host on to the snaps. The servlet contexts of the host and all the snaps are merged but that is a bit of a simplification. Each snap and the host are separate stand-alone web bundles but Snaps hooks in to the servlet contexts of all the snaps to allow resource lookups to propagate up to the host and to dispatch requests against the combined application to the appropriate snap via the host filter. So a snap will 'see' all the resources in the host such as files, tlds etc... but will not inherit any configuration of the servlet context.

So it will not do exactly what you are looking sure but having discussed it I'm not sure how that would even work. I hope this clears things up, I have made a note to improve the Snaps documentation.

Chris.


------------------------------------------------
Chris Frost, Twitter @cgfrost
Springsource, a divison of VMware.
Re: Can Spring be used in host and in snaps? [message #1303586 is a reply to message #997561] Sat, 19 April 2014 10:35 Go to previous message
Rajiv Croos is currently offline Rajiv CroosFriend
Messages: 2
Registered: April 2014
Junior Member
Hi guys,

Could you please excuse me and say from where i can find the com.objectverse.osgi.parent project.

Thanks a lot.
Previous Topic:[resolved] CXF failed to publish endpoints in Eclipse 4.2.2 OSGi, Jetty 8.1.14 and Spring 3.0.7 env
Next Topic:Moving from 3.5.0 to 3.6.2.RELEASE results in "not visible from classloader"
Goto Forum:
  


Current Time: Fri Apr 19 14:18:38 GMT 2024

Powered by FUDForum. Page generated in 0.03107 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top