Imagine a web application that provides you with a special feature called "Upload plugin". You would be able to write a plugin in eclipse, using APIs from that application delivered to you through other plugins. Then you could upload your new plugin and would immediately notice the extensions to the web application.
More important than the hot deployment is the standardized modularization API available. A plugin marketplace could evolve (yes, remember Eclipse plugins!) from which you could add functionality to your application even without coding! Now imagine this environment deployed into a cloud infrastructure: The ideal PaaS for java web development!
Installation and Test
- Download Virgo Web Server.
- Unzip it somewhere.
- Start bin/startup.sh.
- Goto http://localhost:8080.
- Play around with the admin console.
- Checkout git://git.eclipse.org/gitroot/virgo/org.eclipse.virgo.snaps.git
- Import all projects therein into Eclipse (use a fresh workspace).
- in snaps, say git submodule update --init (this creates content in ./virgo-build)
- Stop the virgo server (or tests will fail in the next step)
- in ./build-snaps, say ant clean clean-integration test package
- say cp target/package-expanded/snaps-1.0.0.BUILD-20101206191709/repository/usr/* somewhere/virgo-web-server-2.1.0.RELEASE/repository/usr/
- Start the server again, you should not notice big differences
- Now cd to ./org.eclipse.virgo.snaps.test/src/test/resources
- cp simple-host.war somewhere/virgo-web-server-2.1.0.RELEASE/pickup/
- Look into the server console and observe how the bundle is deployed
- Goto http://localhost:8080/simple-host only to get a "index" answer.
- Goto http://localhost:8080/simple-host/simple/index.jsp only to get a 404.
- cp simple-snap.jar somewhere/virgo-web-server-2.1.0.RELEASE/pickup/
- Goto http://localhost:8080/simple-host/simple/index.jsp and get an "OK" answer.
- You may now start and stop the simple-snap bundle in the admin console and watch the web resource appearing and disappearing.
What happened?
Let's first examing simple-host, the host webapp of our test. It is a pretty normal WAR file. Since OSGi R4 specifies a way to deploy WARs as bundles, Virgo is able to do that. Moreover, in the web.xml, you can find a filter called "host-filter" of class org.eclipse.virgo.snaps.core.SnapHostFilter.
The is the core component of snaps, re-routing requests for different contexts to different OSGi-bundles, called snaps.
simple-snap is an example of such a snap. Its web.xml could very well be empty (but isn't here - it contains several test resources). Its MANIFEST.MF, besides usual entries, contains the following:
Snap-Host: simple.host;version="[1.0, 2.0)"
Snap-ContextPath: /simple
This way, a snap is tied to a specific host and has to declare under which (sub-) context it is serving resources.
In Part 2, I want to develop my first own snaps from scratch. Read on!
In Part 2, I want to develop my first own snaps from scratch. Read on!
thanks your share,
however, i can't build it when step #10, the error is caused by "copy" from the dist folder.
D:\springbox\org.eclipse.virgo.snaps\virgo-build\common\package.xml:49: Warning: Could not find file D:\springbox\org.eclipse.virgo.snaps\org.eclipse.
virgo.snaps.api\target\artifacts\org.eclipse.virgo.snaps.api.jar to copy.
how could i build org.eclipse.virgo.snaps.api.jar firstly ?
Hi garylee,
this api.jar should have been build automatically before. I assume some compile failure happened. Could you please attach full build logs?
I chekced the exception, classnotfound: org.springframework.aws.ivy.S3Resolver,
http://blog.springsource.com/2009/03/03/building-spring-3/
After removing the ivy-2.2.0.jar in %ANT_HOME%\lib , it works !
Finally, i got "BUILD SUCCESSFUL", there is still a small trouble when it runs "test" with not enough heapsize. ( because my notebook only 2MB RAM ). So that i decrease the build.properties test.vm.args with -Xmx512m to replace 1024m.
Ah - I see - so I assume its working now? - Thanks for sharing!
Hi,
thanks for this post, it is very helpful.
However, with the recent version of Eclipse Virgo, I had the following error while deploying snaps-host:
Error creating bean with name 'snapFactoryMonitor' defined in URL [bundleentry://53.fwk9223249/META-INF/spring/module-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.eclipse.virgo.snaps.core.internal.SnapFactoryMonitor]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.osgi.util.tracker.ServiceTracker.(Lorg/osgi/framework/BundleContext;Ljava/lang/Class;Lorg/osgi/util/tracker/ServiceTrackerCustomizer;)
After a couple of hours investigating, I found that it is enough to replace file: your_virgo_install_dir\lib\org.eclipse.osgi-3.6.1.R36x_v20100806.jar
by
org.eclipse.osgi-3.7.0.v20101022.jar
which can be found in ivy-cache\repository which is created during build process.
This may help someone,
cheers,
Andrzej
Great write-up. I'm having just a little bit of trouble though. When I copy simple-host.war into the pickup dir, I see the following in the server's logs:
[2011-02-22 21:15:48.751] fs-watcher Installation of bundle 'simple.host' version '1.0.0.BUILD-20100626235759' failed. org.eclipse.virgo.kernel.osgi.framework.UnableToSatisfyBundleDependenciesException: Unable to satisfy dependencies of bundle 'simple.host' at version '1.0.0.BUILD-20100626235759': Cannot resolve: simple.host
Resolver report:
An Import-Package could not be resolved. Caused by missing constraint in bundle
constraint:
An Import-Package could not be resolved. Caused by missing constraint in bundle
constraint:
at org.eclipse.virgo.kernel.install.pipeline.stage.resolve.internal.QuasiResolveStage.process(QuasiResolveStage.java:45)
at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessTree(StandardPipeline.java:62)
at org.eclipse.virgo.kernel.install.pipeline.internal.CompensatingPipeline.doProcessTree(CompensatingPipeline.java:72)
at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
at org.eclipse.virgo.kernel.install.pipeline.internal.StandardPipeline.doProcessTree(StandardPipeline.java:62)
at org.eclipse.virgo.kernel.install.pipeline.stage.AbstractPipelineStage.process(AbstractPipelineStage.java:41)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.driveInstallPipeline(PipelinedApplicationDeployer.java:271)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.doInstall(PipelinedApplicationDeployer.java:151)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.install(PipelinedApplicationDeployer.java:123)
at org.eclipse.virgo.kernel.deployer.core.internal.PipelinedApplicationDeployer.deploy(PipelinedApplicationDeployer.java:190)
at org.eclipse.virgo.kernel.deployer.hot.HotDeploymentFileSystemListener.deploy(HotDeploymentFileSystemListener.java:174)
at org.eclipse.virgo.kernel.deployer.hot.HotDeploymentFileSystemListener.deployIfNotDeployed(HotDeploymentFileSystemListener.java:186)
at org.eclipse.virgo.kernel.deployer.hot.HotDeploymentFileSystemListener.onChange(HotDeploymentFileSystemListener.java:87)
at org.eclipse.virgo.util.io.FileSystemChecker.notifyListeners(FileSystemChecker.java:245)
at org.eclipse.virgo.util.io.FileSystemChecker.check(FileSystemChecker.java:166)
at org.eclipse.virgo.kernel.deployer.hot.WatchTask.run(WatchTask.java:58)
at java.lang.Thread.run(Thread.java:680)
Upon further inspection (via the admin console), I see no evidence that Snaps is installed, however, Snaps did successfully build and I added to the following three items to the server's repository/usr dir as instructed:
* org.eclipse.virgo.snaps.api-1.0.0.BUILD-20110223003922.jar
* org.eclipse.virgo.snaps.plan
* org.eclipse.virgo.snaps.core-1.0.0.BUILD-20110223003922.jar
Any thoughts?
To me, it really looks like the issue is that Snaps is not installed properly.
Any help is greatly appreciated!!
Hi,
Thanks so much for this wonderfull startup guide to snaps.. I am having problem :(, starting the server with snaps built as per mentioned.
Error:
An Import-Package could not be resolved. Caused by missing constraint in bundle
constraint:
I got the build sucessfull as per instructed and copied the plan into pickup folder and the 2 repositories into respository/usr folder