Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Bundle classpath resources fail to load when using ServerOsgiBundleXmlWebApplicationContext(a problem preventing deployment of spring-batch-admin-sample with ServerOsgiBundleXmlWebApplicationContext as context class)
Bundle classpath resources fail to load when using ServerOsgiBundleXmlWebApplicationContext [message #647363] Wed, 05 January 2011 19:08 Go to next message
Martin Schmied is currently offline Martin SchmiedFriend
Messages: 7
Registered: July 2009
Junior Member
Hi,

I run into this problem when trying to deploy webapp based on spring-batch-admin-sample (available from git://github.com/SpringSource/spring-batch-admin.git). I removed many dependencies from the war and added appropriate imports, but I still wanted to keep all of the spring-batch-admin* bundles inside the war (on it's private classpath). Everything went fine until I changed the webapp's ApplicationContext class to ServerOsgiBundleXmlWebApplicationContext (in order to import some OSGi services). Suddenly, the application wasn't able to load some of the spring config files.

These configuration files are located in required libraries in WEB-INF/lib (and thus on bundle's private classpath), but ServerOsgiBundleXmlWebApplicationContext fails to locate them. It happens only when the resource pattern contains "absolute" path like classpath*:/org/springframework/batch/admin/web/resources/we bapp-config.xml. Changing the resource pattern to classpath*:org/springframework... fixes the problem. Unfortunaltely there are many places in spring-batch-admin with resource paths that cannot be resolved by ServerOsgiBundleXmlWebApplicationContext.

Solution might be as simple as removing leading slash from the path at some appropriate location within Spring-DM (maybe OsgiBundleResourcePatternResolver.findBundleClassPathMatchin gPaths).

Anyway, if you have some tip for a clean simple woraround, please respond. Otherwise this post might be just a piece of advice for others playing with Virgo & spring-batch.

Regards,
Martin
Re: Bundle classpath resources fail to load when using ServerOsgiBundleXmlWebApplicationContext [message #647426 is a reply to message #647363] Thu, 06 January 2011 09:25 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
On the face of it, that looks like a bug. Please would you raise a bugzilla. If you can provide a minimal testcase to reproduce, that would be very helpful.
Re: Bundle classpath resources fail to load when using ServerOsgiBundleXmlWebApplicationContext [message #647428 is a reply to message #647363] Thu, 06 January 2011 09:47 Go to previous messageGo to next message
Martin Schmied is currently offline Martin SchmiedFriend
Messages: 7
Registered: July 2009
Junior Member
Actually I've just found out that it's already fixed in the 1.2.x branch of spring-osgi-io. I'm attaching a patch for 1.2.1 (which you can get from https://anonsvn.springframework.org/svn/spring-osgi/tags/spr ing-osgi-1.2.1/io). Hope it will help somebody else.

Regards,
Martin
Re: Bundle classpath resources fail to load when using ServerOsgiBundleXmlWebApplicationContext [message #647431 is a reply to message #647428] Thu, 06 January 2011 10:19 Go to previous messageGo to next message
Glyn Normington is currently offline Glyn NormingtonFriend
Messages: 1222
Registered: July 2009
Senior Member
Well spotted! Then hopefully the problem will be fixed when Virgo upgrades from Spring DM 1.2.1 to Gemini Blueprint, which is the latest level. See bug 317943.

[Updated on: Thu, 06 January 2011 10:20]

Report message to a moderator

Re: Bundle classpath resources fail to load when using ServerOsgiBundleXmlWebApplicationContext [message #657364 is a reply to message #647363] Wed, 02 March 2011 15:00 Go to previous messageGo to next message
Artur  is currently offline Artur Friend
Messages: 2
Registered: March 2011
Junior Member
Hello,

I have some similar problem.

There are two bundles:
izol - standard bundle
zyzol - web bundle

Using Virgo 2.1.0 with Spring 3.0.5

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

	<context-param>
		<param-name>contextClass</param-name>
		<param-value>org.eclipse.virgo.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
	</context-param>

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:WEB-INF/applicationContext.xml classpath*:WEB-INF/bundle-context.xml</param-value>
	</context-param>

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

	<!-- Servlets -->
	<servlet>
		<servlet-name>greetServlet</servlet-name>
		<servlet-class>pl.poznan.put.zyzol.server.GreetingServiceImpl</servlet-class>
	</servlet>

	<servlet-mapping>
		<servlet-name>greetServlet</servlet-name>
		<url-pattern>/Zyzol/greet</url-pattern>
	</servlet-mapping>

	<servlet>
        <servlet-name>roosample</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath*:/WEB-INF/spring/webmvc-config.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>roosample</servlet-name>
        <url-pattern>/sample</url-pattern>
    </servlet-mapping>
    
	<!-- Default page to serve -->
	<welcome-file-list>
		<welcome-file>Zyzol.html</welcome-file>
	</welcome-file-list>

</web-app>


Context for webmvc-config.xml loads from the both bundles and for bundle-context.xml only from the zyzol bundle, where the web.xml is stored.

Link to the sample project: http://bit.ly/f8vyOS

Is there any way to force beans loading from bundle-context.xml from the both bundles?

Regards,
Artur
Re: Bundle classpath resources fail to load when using ServerOsgiBundleXmlWebApplicationContext [message #657365 is a reply to message #647363] Wed, 02 March 2011 15:00 Go to previous message
Artur  is currently offline Artur Friend
Messages: 2
Registered: March 2011
Junior Member
duplicated msg, sorry

[Updated on: Wed, 02 March 2011 15:32]

Report message to a moderator

Previous Topic:Using Spring DM v2_0_0_M2 in Virgo 3.0.0M2
Next Topic:Unable to load standalone war webapp using JSF 2.0
Goto Forum:
  


Current Time: Sun Dec 08 10:19:33 GMT 2024

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

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

Back to the top