PDA

View Full Version : How can i integrate Spring MV in Spring DM?


amich
May 14th, 2008, 12:29 AM
Spring DM's reference , version 1.1.0 M2 says that i write into a file:

<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.osgi.web.context.support.OsgiB undleXmlWebApplicationContext</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListe ner</listener-class>
</listener>

<servlet>
<servlet-name>petclinic</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>2</load-on-startup>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.osgi.web.context.support.OsgiB undleXmlWebApplicationContext</param-value>
</init-param>
</servlet>

My question is: Where do i write this code , into file with xml extension or into manifest.mf file?

Thanks..

Costin Leau
May 14th, 2008, 02:00 AM
All the parameters above are part of the Servlet web.xml file. It cannot be the manifest.mf since that is, as the name implies, a MANIFEST not an XML file. Additionally, it cannot be just any xml file but rather WEB-INF/web.xml - you can try one of Sun's Servlet tutorials for more info: http://java.sun.com/products/servlet/docs.html

amich
May 15th, 2008, 12:03 AM
Thanks Costin Leau, but i have a doubt.
I have to create a normal "web dynamic project " or create a bundle project and create it the web.xml , WEB-INF , and all web project´s estrcuture ?

oleg.zhurakousky
May 15th, 2008, 12:38 AM
It should be a regular Web Project (e.g., Dynamic Web Project from WTP) with META-INF directory at the root of the source path containing MANIFEST.MF file.
Once you build it into a WAR you can deploy it by dropping it into directory with the rest of the bundles or executing install command via Equinox console.

Here are the sample contents of MANIFEST.MF file

Bundle-ManifestVersion: 2
Bundle-Name: The Name of Your WAR
Bundle-SymbolicName: Symbolic Name of Your WAR
Bundle-Classpath: WEB-INF/classes
Import-Package: javax.servlet,javax.servlet.http,javax.servlet.res ources

amich
May 24th, 2008, 12:14 AM
All rigth, Costin Leau.
Now , I made one simple example, so i didn`t problem, but when i wanted run with spring MVC everything was bad. The misktake said that

"HTTP Status 404 - /springmvcosgi1/
type: Status report
message: /springmvcosgi1/
description: The requested resource (/springmvcosgi1/) is not available."

Could you help me , what´s the matter?

Thanks...

Costin Leau
May 24th, 2008, 06:09 AM
There could be several things going bad in there - it depends on what's your WAR structure.
Turn on logging to TRACE level and see what you get in the console under org.springframework.osgi category. This is in general useful since it indicates what goes wrong and also under what name your war is installed.