PDA

View Full Version : Spring DM Web


jmcginn
May 27th, 2008, 02:46 PM
I have found the solution to this first post, the war file name is the default context name used I still have not found out why my context path strategy in the 2nd post does not work.

Thanks,

John

I am trying to create my first WAR bundle using Spring DM's web extender.

I have the spring osgi web and web extender bundles installed and started (1.1.0.m2).

I am a little confused on the structure of the WAR and how to install it.

I created a WAR file that looks like this:
/WEB-INF/classes - My compiled classes
/WEB-INF/web.xml
/META-INF/manifest.mf

My manifest looks like this:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MyTest Plug-in
Bundle-SymbolicName: MyTest
Bundle-Version: 1.0.0
Bundle-Localization: plugin
Import-Package: javax.servlet;version="2.5.0",
javax.servlet.http;version="2.5.0",
javax.servlet.resources;version="2.5.0"
Spring-Context: springConfig/testConfig.xml
Bundle-ClassPath: WEB-INF/classes/,
.


My web.xml looks like this:

<web-app id="MyTestApp">

<servlet>
<servlet-name>Test</servlet-name>
<servlet-class>com.railinc.test.MyTestServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>Test</servlet-name>
<url-pattern>/test</url-pattern>
</servlet-mapping>
</web-app>


I was able to install and start the WAR bundle, but I cannot seem to actually hit my servlet.

I tried /MyTest/test but got no results :(.

Am I packaging my WAR incorrectly?
Am I installing it incorrectly? Should it be a fragment attached to the web.extender?
Do I need to register any spring services?
What is the context root for this web app? The default context handler seems to indicate bundle-location is the default, but what does this mean?

Thanks

John

jmcginn
May 27th, 2008, 03:24 PM
More attempts with no results :(

Ok to make things simple I tried to implement my own ContextPathStrategy that would use hte bundle-name.

I created a new project and created a class that implemented ContextPathStrategy.

My manifest for this jar looks like this:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: ContextPathProvider Plug-in
Bundle-SymbolicName: ContextPathProvider
Bundle-Version: 1.0.0
Bundle-Localization: plugin
Fragment-Host: org.springframework.bundle.osgi.web.extender
Spring-Context: springConfig/contextProviderConfig.xml


My spring config file looks like this:

<bean id="contextPathStrategy" class="com.railinc.util.RailincContextPathProvider"/>



I can see that the fragment is attached to the web.extender, but no matter what I do I cannot get my context provider to fire off (I have a break point set and a System.out)

What am I doing wrong?

Thanks,

John

Costin Leau
May 28th, 2008, 04:04 AM
John, the default strategy in m2, uses the bundle location followed (if it's missing) by its name and then by its symbolic name.
Turn on logging and see under what path your application is running.
As for the fragments, Spring-Context: header is not supported. Make sure your configuration is under META-INF/spring - otherwise it is not being picked up.

sammaish
Jul 1st, 2008, 09:53 PM
Am new to OSGi/Spring DM. Could you please point me to an example on how I can deploy my first WAR. I am using Spring DM 1.1.0 rc1.

Thanks.

Costin Leau
Jul 2nd, 2008, 01:15 AM
Sammaish, the distribution contains both docs and samples that address this matter. Additionally, the upcoming 1.1 final will improve the existing samples.

P.S. In the future, please start your own separate thread...