Skip to main content



      Home
Home » Eclipse Projects » Virgo » Deploy Spring MVC application on Virgo Web Server?
Deploy Spring MVC application on Virgo Web Server? [message #632449] Tue, 12 October 2010 21:40 Go to next message
Eclipse UserFriend
Dear All:

I am in the process of researching for this OpenMRS ticket:
http://tickets.openmrs.org/browse/TRUNK-1596

and have found a relatively simple guide for converting Spring MVC applications (which we have) that seems like a relatively straightforward way to convert a Spring MVC application gradually to an OSGi bundle.
http://static.springsource.org/osgi/docs/1atest/reference/ht ml/web.html#web:spring-mvc

I have found a simple application that seems like it has followed this guide, albeit a bit dated (2008):
http://raibledesigns.com/rd/entry/running_spring_mvc_web_app lications
http://static.raibledesigns.com/downloads/myapp-noosgi.zip
http://tinyurl.com/3ylrbhp

I am trying to deploy this file in Virgo Web Server.
Specifically, I have installed successfully:
http://carroll.aset.psu.edu/pub/eclipse/virgo/milestone/VWS/ 2.1.0.M06-incubation/virgo-web-server-2.1.0.M06-incubation.z ip

I enable the Equinox telnet console by uncommenting the following line:
misha@misha-d630:~/opt/virgo-web-server-2.1.0.M06-incubation$ cat config/org.eclipse.virgo.kernel.userregion.properties | grep console
# osgi console support
osgi.console=2401


then drop the following bundle into pickup:
http://www.springsource.com/repository/app/bundle/version/do wnload?name=org.springframework.osgi.web&version=1.2.1&a mp;a mp;type=binary

I go to the console, install bundle, it is active:
telnet localhost 2401
Trying ::1...
Connected to localhost.
Escape character is '^]'.

osgi> install file:///tmp/myapp.war
Bundle id is 64

osgi> start myapp

osgi> ss myapp

Framework is launched.

id	State       Bundle
64	ACTIVE      myapp_0.0.0


Yet get a 404 from the suggested URL:

curl http://localhost:8080/myapp/
<html><head><title>Apache Tomcat/6.0.29 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - /myapp/</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/myapp/</u></p><p><b>description</b> <u>The requested resource (/myapp/) is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.29</h3></body></html>


Any ideas? Thank you.

Misha

[Updated on: Tue, 12 October 2010 21:41] by Moderator

Re: Deploy Spring MVC application on Virgo Web Server? [message #632452 is a reply to message #632449] Tue, 12 October 2010 22:42 Go to previous messageGo to next message
Eclipse UserFriend
My apologies. I have tracked down the error to the reference
"<osgi:reference id="jobsBPS" interface="com.linkedin.jobs.bps.api.JobsBPS"
timeout="10000" cardinality="0..1"/>"

in ./src/main/webapp/WEB-INF/applicationContext.xml

if I fix this reference and deploy _through_ the web interface it works!

If I deploy through equinox however, it starts successfully but is not deployed to the web interface.

Is there a simple command I am missing?

Thank you
Misha
Re: Deploy Spring MVC application on Virgo Web Server? [message #632487 is a reply to message #632452] Wed, 13 October 2010 03:20 Go to previous messageGo to next message
Eclipse UserFriend
Hi Misha

The Spring DM web support is not intended to work inside Virgo. Virgo has its own web container based on Tomcat and no work has been done in Spring DM or Virgo to get the Spring DM web support to run in Virgo.

You need to deploy using the Virgo deployment mechanisms -- admin console, copy file to pickup directory, JMX, or Deployer interface -- to ensure proper processing of a web application through the Virgo deployment pipeline (which drives Gemini Web's transformations on the web app).

Hope that helps.

Regards,
Glyn
Re: Deploy Spring MVC application on Virgo Web Server? [message #632704 is a reply to message #632487] Wed, 13 October 2010 20:30 Go to previous messageGo to next message
Eclipse UserFriend
Hi Glyn,

Thank you so much for the helpful comments.

I am, however, slightly confused by this statement:
> The Spring DM web support is not intended to work inside Virgo. Virgo has its own web container based on Tomcat and no work has been done in Spring DM or Virgo to get the Spring DM web support to run in Virgo.

As I was directed to Virgo Web Server from:
http://www.springsource.com/products/dmserver

I imagined it would be the easiest way to transition an existing Spring MVC application to use OSGi...

Is the desired functionality (of Spring DM web support) present still in the old Spring DM Server and not just migrated to Virgo Web Server quite yet, or am I missing something larger?

Thank you very much

Yours
Misha
Re: Deploy Spring MVC application on Virgo Web Server? [message #632769 is a reply to message #632704] Thu, 14 October 2010 04:48 Go to previous messageGo to next message
Eclipse UserFriend
Virgo supersedes, and renders obsolete, the web support in Spring DM. Spring DM web support was never part of dm Server or Virgo.

Users should be able to migrate their web applications, including those built using Spring MVC, to Virgo without any reference to the Spring DM web support.

I hope that's clearer. Sorry for any confusion.
Re: Deploy Spring MVC application on Virgo Web Server? [message #632904 is a reply to message #632769] Thu, 14 October 2010 11:49 Go to previous messageGo to next message
Eclipse UserFriend
Hi Glyn:

Thank you so much for your thoughtful explanation.

Perhaps I will get to my main question then, as I am not 100% clear on this:
* if I have an existing Spring MVC web app, is there a good (straightforward) way to get access to the BundleContext from this WAR with the _fewest_ amount of changes in Virgo Web Server? Specifically, I'd like to avoid going through the proprietary PAR format if possible (is such a format still present in Virgo Web Server?)

---

I understand "Users should be able to migrate their web applications, including those built using Spring MVC, to Virgo without any reference to the Spring DM web support." to mean that Virgo is meant to deploy WARs without modification in an OSGi environment? Perhaps I am misunderstanding?

Thank you

Yours
Misha
Re: Deploy Spring MVC application on Virgo Web Server? [message #632913 is a reply to message #632904] Thu, 14 October 2010 12:01 Go to previous messageGo to next message
Eclipse UserFriend
Many WAR files can be deployed successfully to Virgo without any changes at all. Of course if they are using some Java EE features like JNDI, they may need changing (unless you install a JNDI provider such as Gemini Naming), and so on.

As the OSGi Enterprise spec says, a Servlet can obtain a Bundle Context as follows:

BundleContext ctxt = (BundleContext) servletContext.getAttribute("osgi-bundlecontext");

Hope that helps.
Re: Deploy Spring MVC application on Virgo Web Server? [message #632938 is a reply to message #632913] Thu, 14 October 2010 13:36 Go to previous message
Eclipse UserFriend
You can also register a bean that implements

org.springframework.osgi.context.BundleContextAware


but that will cause a change to the ApplicationContext class that you use in web.xml

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


If you do switch your context class you can even Autowire/Inject with xml
<property name="bundleContext" ref="bundleContext"/>

Previous Topic:Error on startup for Virgo M6
Next Topic:Virgo Tools for Eclipse exists?
Goto Forum:
  


Current Time: Wed Jul 02 19:41:30 EDT 2025

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

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

Back to the top