Sahoo,
I thought about this and you are dead right.
I stopped the thrash and worked to a solution. It wasn't quite the way I
intended but I did get there. I am pretty certain that all the problems I
have encountered were of my own making and I really want to thank you,
Jerome and bhakti for your patience.
So, as payback and for the benefit of future generations here is what I did.
1. I created a maven project for an OSGi bundle which I package using the
org.apache.felix/maven-bundle-plugin.
2. I played around with the various configuration elements in this plugin
(in my pom) to import and export the various packages of my bundle and it's
dependencies.
3. I create a BundleActivator class and configured this in the bundle plugin
configuration as well.
4. I put this in the autodeploy-bundle directory of a nightly build
glassfish v3 deployment and started the server.
This all works exactly how I would expect.
5. Create a simple web application with a servlet.
6. Look up the habitat like this..
Habitat habitat = (Habitat)
getServletContext().getAttribute("org.glassfish.servlet.habitat");
7. Lookup my service like this...
MyAPI api = habitat.getByContract(MyAPI.class);
This returned a null reference, so I did this...
8. I register my service in my bundle activator's start method thus...
ctx.registerService(MyAPI.class.getName(), new MyImpl(), new
Properties());
9. Unpacked a clean glass v3 nightly, put my updated bundle in the
autodeploy-bundles directory and redeployed my web application.
Now it all works.
The @Resource injection works for the habitat, I have not tried for MyAPI
just yet. I did not pesue this course because I am still interested in using
v3 prelude and @Resource doesn't seem to work in v3 prelude (I will get to
this in a bit).
Things I am still not sure I have right...
1. The configuration for the maven-bundle-plugin. I have looked at the
generated manifest, but I cannot be sure it is exactly right. There is an
entry which looks like it should export MyAPI, but given my experimentation
I do not believe it gets exported.
2. I do not know how to deploy a new version of bundle into Glassfish. Just
dropping a new jar in the autodeploy-bundles directory? Do I need to use the
asadmin tool to undeploy/deploy? I have tried the first approach (didn't
seem to work), but not the second. I wouldn't be sure how undeploy.
3. I still cannot deploy a web service application to a nightly V3 but that
problem is for another day.
OK taking a step back, I was also interested in how I might make this work
in v3 prelude. I have a project I want to deploy soon and the v3 prelude is
the only v3 that has support available should my client need it (not decided
yet). The timescale for this deployment does not lend itself to a wait for
another supported release.
I did manage to get this working as well, only slightly differently.
1. I placed my bundle jar in the glassfish/modules directory (could be
anywhere I suppose)
2. I edited the felix/conf/config.properties file. In this file there is a
section commented with...
# Auto-start osgi-adapter module, which is our management bundle.
# Also start all its dependencies.
I added the path to my bundle to the bottom of this section. I have not yet
found another way that activates my bundle at server startup in v3 prelude.
3. Deployed both a service and servlet based web application and, using the
web context's looked up the service successfully.
OK, thats me. I hope my experience helps somebody else. If I find solutions
to the outstanding issues I will certainly document them here.
Thanks,
Paul B.
--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix-tp23634609p23656043.html
Sent from the java.net - glassfish users mailing list archive at Nabble.com.