View Full Version : install spring-osgi-web.jar - WHERE?
Gisbert
May 2nd, 2008, 07:46 AM
The docs on http://static.springframework.org/osgi/docs/current/reference/html/web.html say:
To use Spring-DM Web, install:
* spring-osgi-web.jar - Spring-DM web support
* spring-osgi-web-extender.jar - Spring-DM web extender
bundles to detect started OSGi WAR bundles and to deploy them to one of the supported web containers.
What does that mean? WHERE do I install these jars? Into a runing OSGi environment? How does that know about my Tomcat then? These questions have been asked here before but not been answered comprehensibly (at least not for me).
Please don't tell me to first read the docs, because that's where I came from.
A step-by-step tutorial how to dive into that whole thing would be of great help.
Gisbert
May 2nd, 2008, 07:55 AM
A guess: Since the docs talk about bundles, I need to install these Jars into a running OSGi environment, right?
But I still don't understand how my Tomcat is recognized then. Needs it also to be startet as a bundle within the OSGi runtime?
bjoern.voss
May 2nd, 2008, 08:43 AM
Yes, you need a "OSGi version" of your servlet container. As I know jetty jars are out of the box OSGi capable - means it has a MANIFEST with OSGi headers.
A OSGi version of tomcat is included in the "with-dependencies" download or the great new bundle repository on http://www.springsource.com/repository/ which is described on this Google Group thread (http://groups.google.com.mt/group/spring-osgi/browse_thread/thread/5c0db7a65ab4c86d/41a466bd2518f524#41a466bd2518f524).
After you have set up the OSGi service of your servlet container you can go along with the reference docu, to configure spring-dm-web if you don't use tomcat.
I hope this helps to get started
regards
Björn
Gisbert
May 2nd, 2008, 09:19 AM
Thanks for your help. Sorry for bothering you, but what exactly do you mean by "set up the OSGi service of your servlet container"?
I've installed the Tomcat bundle into the pax-runner OSGi-environment, but when I try to start it, I get this Exception:
org.osgi.framework.BundleException: Unresolved package in bundle 21: package; (&(package=org.apache.tomcat.util.digester)(version>=6.0.16)(version<=6.0.16))
I'll have another look in the repository you named and see if I can find that digester utility. This isn't as user friendly as I would it expect to be from my experiences made with Spring so far.
Gisbert
May 2nd, 2008, 09:26 AM
I found out that I also need com.springsource.org.apache.coyote-6.0.16.jar; not onla the catalina package. But when I try to start this, I get:
org.osgi.framework.BundleException: Unresolved package in bundle 22: package; (&(package=org.apache.juli.logging)(version>=6.0.16)(version<=6.0.16))
This whole thing reminds me of early days Linux package dependency resolving by hand ...
Gisbert
May 2nd, 2008, 09:31 AM
I found out where the digester thingi lives: com.springsource.org.apache.juli.extras-6.0.16.jar
This can be started without any complains. Hurray.
Trying to start com.springsource.org.apache.coyote again, I now get
org.osgi.framework.BundleException: Unresolved package in bundle 21: package; (&(package=javax.servlet.http)(version>=2.5.0)(!(version>=3.0.0)))
I see. It needs the Servlet API aswell. I thought I had overcome these dependency hell (at least partially) by using Maven. Here it is again ...
bjoern.voss
May 2nd, 2008, 09:36 AM
I know what you mean, but that's not a spring but OSGi specific thing, I think. You have to "pay" for the strict version management in OSGi.
But I think the spring guys did - again - a great job here, because in the repo I mentioned you can look up the dependencies needed by a bundle.
For example for Tomcat (http://www.springsource.com/repository/app/bundle/version/detail?name=com.springsource.org.apache.catalina&version=6.0.16)
May be it is a good idea to provide a zip with a "ready to run" OSGi runtime for a quick start.
But I think, this could only be a quick start, because your production OSGi runtime must fit exact your needs.
Colin, what do you think about this?
Gisbert
May 2nd, 2008, 09:51 AM
Some more dependencies I needed to download and install:
com.springsource.javax.mail-1.4.0.jar
com.springsource.javax.persistence-1.0.0.jar
com.springsource.javax.xml.ws-2.1.1.jar
com.springsource.javax.xml.soap-1.3.0.jar
com.springsource.javax.activation-1.1.0.jar
com.springsource.javax.xml.bind-2.0.0.jar
com.springsource.javax.xml.stream-1.0.1.jar
com.springsource.javax.ejb-3.0.0.jar
com.springsource.javax.xml.rpc-1.1.0.jar
com.springsource.javax.annotation-1.0.0.jar
Now catalina starts. And I wonder: What to do next?
Gisbert
May 2nd, 2008, 09:53 AM
Yes the repository is really great. However, there are transitive dependencies that are not listet there :)
bjoern.voss
May 2nd, 2008, 09:59 AM
Which one?
I thought in the "Full Dependencies" list are all - also transitive - dependencies listed. :confused:
Gisbert
May 2nd, 2008, 10:14 AM
Catalina lacks the XML deps:
com.springsource.javax.xml.ws-2.1.1.jar
com.springsource.javax.xml.soap-1.3.0.jar
com.springsource.javax.xml.bind-2.0.0.jar
com.springsource.javax.xml.stream-1.0.1.jar
com.springsource.javax.xml.rpc-1.1.0.jar
However, they are listed under "imported packages" (among others). So one needs to look at all sections of the repo page. It is really great.
BTW: Catalina lists itself as required dependency :)
bjoern.voss
May 2nd, 2008, 10:57 AM
Yes, I see.
I use jetty so I didn't run into this ;)
Could you post it in the Google Group thread? I think Adrian will pick it up and at least comment on it.
Otherwise I will do.
bjoern.voss
May 2nd, 2008, 11:37 AM
I just find this
Spring Application Platform (http://www.springsource.com/web/guest/products/suite/applicationplatform) through one of my RSS-feads.
I think it's really interesting :):eek::)
Costin Leau
May 3rd, 2008, 06:06 AM
Guys, there is some misunderstanding here.
Spring-DM 1.1.0 m2 doesn't use BRITS yet since at the time of its release it wasn't available yet. The libraries used by Spring-DM are available in its own repo, as explained here:
http://static.springframework.org/osgi/docs/current/reference/html/web.html#web:osgi-artifacts
and here:
http://static.springframework.org/osgi/docs/current/reference/html/appendix-osgi-repo.html
The first link provided below also explains how to install and configure Tomcat and Jetty.
What does that mean? WHERE do I install these jars? Into a runing OSGi environment? How does that know about my Tomcat then? These questions have been asked here before but not been answered comprehensibly (at least not for me).
Gisbert (http://forum.springframework.org/member.php?u=37969), to answer your questions:
"A major feature introduced in the 1.1.0 release is support for web applications which enables easy deployment of web artifacts to OSGi."
This means that wars and the bundles are deployed into an OSGi platform.
The entire reference documentation assumes the case of a running OSGi platform to which bundles are installed. If that's not the case, then the bundles won't have to be bundles - they could just be jars.
I'll make this point more clear in the future.
As for the Tomcat install:
"Spring-DM web support expects the web containers to be installed as OSGi services. Since neither the Tomcat nor the Jetty distribution do this, Spring-DM offers two simple yet useful OSGi Activator (http://www2.osgi.org/javadoc/r4/org/osgi/framework/BundleActivator.html)s for both containers at the Spring-DM OSGi repository. Once installed, these will programmatically start the appropriate web container based on a default configuration (which can be customized and publish it as an OSGi service."
Both of these quotes are taken from the reference documentation. If they are unclear or incomplete, let me know and I will try to improve them.
Note that 1.1 is in M2 phase, it's not a final release. We plan to have a tutorial and other examples around the GA release date.
See Matt Raible's blog - it might help you out:
http://raibledesigns.com/rd/entry/running_spring_mvc_web_applications
jmcginn
May 9th, 2008, 10:40 AM
Hi Costin, I like Gisbert am trying to get a grasp of this.
My problem is that in our controlled environment I do not have control of the installed version of Tomcat so installing an OSGi bundled version of it may not be an option. Although we did just have a webinar with SpringSource yesterday where we covered the SpringSource app server so that may be a future option (is it already OSGi'ified?)
Also from this blog: http://blog.springsource.com/main/2008/04/29/web-applications-and-osgi/
I see the following line:
As a side note, when dealing with two managed environments, one is facing an interesting problem: what deployment model to use? That is which is be the bootstrapping platform and which one embedded? In our case, one can either deploy the OSGi platform as a WAR or deploy the web container (under some form of service), inside the OSGi platform. More about this though, in a future entry.
Which seems to indicate that we can do either. Have a traditional tomcat WAR bootstrap the OSGi framework (similar to how the Eclipse servlet bridge works) or have Tomcat ran as an OSGi Service. Right now in our current environment the first option would have to be pursued.
I was able to get the Eclipse servlet bridge to run, but am having issues getting Spring DM bundles to run inside this. For instance I create a HelloWorld bundle that uses Spring DM to wire up the beans but the application context fails to find the HelloWorld bean.
Here is what my HelloWorld manifest looks like:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: HelloWorld Plug-in
Bundle-SymbolicName: HelloWorld
Bundle-Version: 1.0.1
Bundle-Localization: plugin
Require-Bundle: org.springframework.bundle.osgi.extender,
org.springframework.bundle.osgi.core,
org.springframework.bundle.osgi.io,
org.springframework.bundle.spring.aop,
org.springframework.bundle.spring.beans,
org.springframework.bundle.spring.context,
org.springframework.bundle.spring.core,
org.springframework.osgi.aopalliance.osgi,
org.springframework.osgi.cglib-nodep.osgi
Spring-Context: spring-config/hello-world.xml
Export-Package: com.railinc.hello
Eclipse-RegisterBuddy: org.springframework.bundle.osgi.extender
In my hello-world.xml I have the following:
<osgi:service ref="helloWorldBean" interface="com.railinc.hello.HelloWorld"/>
<bean id="helloWorldBean" scope="bundle" class="com.railinc.hello.impl.HelloWorldImpl"/>
I then deploy the servletbridge WAR to Tomcat (5.5) and start it up and install the spring bundles and my Hello World bundle.
My bundles look like this:
id State Bundle
0 ACTIVE org.eclipse.osgi_3.3.0.200704022148
Fragments=10
1 ACTIVE org.eclipse.equinox.common_3.3.0.200704022148
2 ACTIVE org.eclipse.update.configurator_3.2.100.v20070322
3 ACTIVE org.eclipse.equinox.http.servletbridge_1.0.0.20070 4022148
4 ACTIVE org.eclipse.equinox.http.registry_1.0.0.2007040221 48
8 ACTIVE org.eclipse.equinox.http.servlet_1.0.0.20070402214 8
9 ACTIVE org.eclipse.equinox.registry_3.3.0.v20070318
10 RESOLVED org.eclipse.equinox.servletbridge.extensionbundle_ 1.0.0
Master=0
11 ACTIVE org.eclipse.osgi.services_3.1.100.200704022148
46 ACTIVE org.springframework.osgi.aopalliance.osgi_1.0.0.SN APSHOT
47 ACTIVE org.springframework.osgi.cglib-nodep.osgi_2.1.3.SNAPSHOT
48 ACTIVE org.springframework.osgi.log4j.osgi_1.2.15.SNAPSHO T
54 ACTIVE slf4j.api_1.4.3
55 ACTIVE slf4j.log4j12_1.4.3
56 ACTIVE org.springframework.bundle.spring.aop_2.5.2
57 ACTIVE org.springframework.bundle.spring.beans_2.5.2
58 ACTIVE org.springframework.bundle.spring.context_2.5.2
59 ACTIVE org.springframework.bundle.spring.core_2.5.2
60 ACTIVE org.springframework.bundle.osgi.core_1.0.2
61 ACTIVE org.springframework.bundle.osgi.extender_1.0.2
62 ACTIVE org.springframework.bundle.osgi.io_1.0.2
63 ACTIVE Apache_Commons_Logging_1.1.1
70 RESOLVED HelloWorld_1.0.1
When I try and start HelloWorld I get the following:
SEVERE: Post refresh error
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.osgi.service.exporter.support .OsgiServiceFactoryBean#0': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type [java.lang.String] to required type [java.lang.Class[]] for property 'interfaces'; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.railinc.hello.HelloWorld]. Root cause: java.lang.ClassNotFoundException: com.railinc.hello.HelloWorld
Which seems to indicate that the spring class loader doesn't know about the OSGi class loaders classes?
Do I need to use a fragment to extend the system bundle?
Thanks
John
Costin Leau
May 12th, 2008, 03:45 AM
John,
use 1.1.0 M2 not 1.0.2 since the latter has no web support. The Eclipse service bridge has not been yet tested though I don't see many problems with that approach.
On the other hand, the use of servlet bridge forces the bundles to be pre-parsed so that the dispatcher/proxy servlet is instructed to do the proper redirects (like http service) which is not the approach that Spring-DM takes.
Ideally, you should expose Tomcat as a service inside the embedded OSGi but that requires some work.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.