-
15. Re: How to make dependency on osgi bundle from war file
jrantav Nov 28, 2012 12:06 PM (in response to thomas.diesler)I tried replicating the previous test examples, with updated dependency injection and some other stuff. So I copied what I could find.
It works, and I can refer to osgi bundle from servlet, and from ejb.
The original code also had Dependencies: in the war manifest, and I've now wrapped my head around all I can to replace that with either Require-Bundle or Import-Package, but at least with AS 7.1 final, I'm unable to.
This is my code: https://github.com/eis/jboss-osgi-poc
(or pretty small part of it is mine, but...)
If this is meant to work, can you let me know what exactly I should put in the war manifest in this pom file: https://github.com/eis/jboss-osgi-poc/blob/master/noosgi-web-app/pom.xml
for this to work without Dependencies in the manifest?
-
16. Re: How to make dependency on osgi bundle from war file
thomas.diesler Nov 29, 2012 9:36 AM (in response to jrantav)Howerver, I strongly discourage an attempt to achive modularity by
I made this bold in case you missed the "discourage" part of it
-
17. Re: How to make dependency on osgi bundle from war file
jrantav Dec 3, 2012 2:44 AM (in response to thomas.diesler)Yes, and like I stated in my previous post, I'm trying to replace that with something else, but I've been unable to find a working way to do it
I've seen the Arquillian test cases, but somehow when I'm trying to translate the same to a maven bundle plugin instruction, I've been unable to get it to work. I'm working with JBoss 7.1.1.
-
18. Re: How to make dependency on osgi bundle from war file
thomas.diesler Dec 3, 2012 3:31 AM (in response to jrantav)On this forum I can support you with the latest jboss-as/master. Your maven builds could use the maven-bundle-plugin for everything that is meant to be a bundle (i.e. your osgi webapp)
-
19. Re: How to make dependency on osgi bundle from war file
jrantav Dec 3, 2012 2:38 PM (in response to thomas.diesler)Yes, it is using. This case is about war (using war-plugin) accessing osgi service (using bundle plugin).
I have tried latest jboss-as/master also, but that one seems to fail earlier on - ejb doesn't seem to find my osgi service even with Dependencies header present.
Either for both 7.1.1 and 7.2.snapshot, both Require-Bundle and Import-Package are ignored for war files, or I'm doing something wrong. I'm getting ClassNotFoundExceptions in both of them.
-
20. Re: How to make dependency on osgi bundle from war file
thomas.diesler Dec 4, 2012 4:42 AM (in response to jrantav)The war should have a valid osgi manifest - you can forget about 'Dependencies'. If you insist on using war-plugin you must prefabricate the manifest that goes into the war. Can you show us that manifest? Both, Require-Bundle and Import-Package should work.
-
21. Re: How to make dependency on osgi bundle from war file
jrantav Dec 5, 2012 9:51 AM (in response to thomas.diesler)Ok, I think this is the key thing here. You're saying that war should have a valid osgi manifest - but if it would, it will be treated as a wab and not a war, right?
I know that for a wab, referring to osgi bundles with a valid osgi manifest is perfectly possible. But is war referring to osgi bundles without "Dependencies" in the manifest not possible?
This works with 7.1, doesn't work with 7.2:
Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven Built-By: user Build-Jdk: 1.7.0_09 Dependencies: org.osgi.core,org.jboss.osgi.framework,deployment.osgi-s imple-service-api:0.0.2
I assumed that you could use Import-Package with wars, so this is what I've tried, but it doesn't seem to be working with either 7.1 or 7.2:
Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven Built-By: user Build-Jdk: 1.7.0_09 Import-Package: fi.eis.applications.jboss.poc.osgiservice.api, javax.annotation, javax.servlet;version="[2.5,2.5]", javax.servlet.http;version="[3.0,4.0]", org.osgi.util.tracker, org.osgi.service.http, org.osgi.framework;version="[1.5,2.0)", org.jboss.logging;version="[3.0,4.0)"
or this
Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven Built-By: user Build-Jdk: 1.7.0_09 Embed-Dependency: *;scope=compile|runtime Embed-Directory: WEB-INF/lib Embed-Transitive: true Import-Package: fi.eis.applications.jboss.poc.osgiservice.api, javax.annotation, javax.servlet;version="[2.5,2.5]", javax.servlet.http;version="[3.0,4.0]", org.osgi.util.tracker, org.osgi.service.http, org.osgi.framework;version="[1.5,2.0)", org.jboss.logging;version="[3.0,4.0)" Private-Package: fi.eis.applications.jboss.poc.webapp
But like you said, these are not real osgi manifests, as I don't want the war to become a wab.
-
22. Re: How to make dependency on osgi bundle from war file
ejroberts Dec 6, 2012 8:29 AM (in response to jrantav)Hi
I just resolved a war deployment issue we were having with 7.2.0.Alpha1 and a jmx war which has OSGi bundle dependencies.
The dependencies syntax has definitely changed in 7.2, but I am not sure what the official syntax to use is.
Anyway, we are able to get a working solution with wars using basic Manifest definition and JBoss Dependencies using this syntax
Dependencies: deployment.deployment-file-name[, ...]
e.g.
Dependencies: deployment.my-api-1.0.0-SNAPSHOT.jar
HTH -
23. Re: How to make dependency on osgi bundle from war file
jrantav Dec 7, 2012 2:58 AM (in response to ejroberts)Thanks for the heads up. That looks quite tight coupling to me. :/
-
24. Re: How to make dependency on osgi bundle from war file
thomas.diesler Dec 7, 2012 4:15 AM (in response to jrantav)> it will be treated as a wab and not a war, right?
In AS7.2.x the difference between WAR and WAB is how the class space is constructed. It should be transparent to your webapp that it is/becomes an osgi bundle. Take a look at WebAppTestCase
BTW, the main purpose of jbosgi is to bring modularity to nontrivial enterprise applications in AS. So if your WAR is such an application it should work as an OSGi bundle just the same. If it doesn't I'd like to know about it.
-
25. Re: How to make dependency on osgi bundle from war file
charlie7 Mar 27, 2013 2:27 PM (in response to jrantav)Hi Jarkko
Where you able to find any solution for Non-OSGI accesing OSGI. If so please do share it ,
I am stuck at the same location
-
26. Re: How to make dependency on osgi bundle from war file
jrantav Mar 27, 2013 4:48 PM (in response to charlie7)Hi,
charlie7 wrote:
Where you able to find any solution for Non-OSGI accesing OSGI. If so please do share it ,
I am stuck at the same location
like mentioned in the thread, there's two options:
- osgify the war, provide it a valid OSGi manifest and
- using regular dependencies mechanism, either through jboss-deployment-structure.xml or Dependencies header in the manifest.mf
Both of these worked for me.
-
27. Re: How to make dependency on osgi bundle from war file
djchapm Mar 28, 2013 2:12 PM (in response to thomas.diesler)There will always be some situation where a non-osgi war needs to access OSGI services. Perhaps we're bound by some third party software like Liferay which doesn't work as OSGI. So regarding the answer to this overall question - would be nice to keep focus on solutions for non-osgi war to osgi services and yet we still want to take advantage of the rest of EAP/JBoss advantages including OSGI.
At this time it seems the only solution is for a war to put in the dependencies statement in the manifest, which includes the bundle jar name and version - so very tightly coupled and unhealthy. But currently no working alternative.
My understanding was that in jboss 7.2 this would open up so that you could at least specify the bundle by name and version range instaed of deployment name and exact version. Or perhaps no need to list the dependencies in manifest at all and bundles would be treated as 'provided' resources to the web app as are other jboss modules.
Apparently this is not the case, and we'll be stuck with a tight dependency between war and OSGI.
This doesn't mean OSGI isn't still useful. If you design such that you have an API bundle exporting the interfaces, and a non-exported implementation bundle providing the implementation of said interface, then the war only needs to have the tight coupling to the API and the implementation at least could be updated at runtime giving us what we typically will want in an enterprise solution bound by non-osgi war release cycles.
Dan C.
-
28. Re: How to make dependency on osgi bundle from war file
jrantav Mar 28, 2013 3:36 PM (in response to djchapm)At this time it seems the only solution is for a war to put in the dependencies statement in the manifest, which includes the bundle jar name and version - so very tightly coupled and unhealthy. But currently no working alternative.
Could you elaborate as to how using an OSGi manifest isn't a working alternative for regular .wars? In 7.2 we got the possibility to use it in standard wars, and it seems to be working quite well, so why not use it?
-
29. Re: How to make dependency on osgi bundle from war file
joshna_r Apr 15, 2013 5:45 PM (in response to jrantav)Seems like some of you are successful in using OSGI bundles from a war . I really appreciate if you can help me get through this.
I dont want to convert my war to wab's . Correct if i am wrong , if i have to convert war to wab , i have to define names of all the jars present in WEB-INF/lib in the manifest file which can be time consuming as our wars have lot of 3rd party jars.
Following are the steps i followed , but no success yet
Added the pax -web capabilities as mentioned in jboss-osgi user guide
<capability name="org.ops4j.pax.web:pax-web-jetty-bundle:1.1.2"/>
<capability name="org.ops4j.pax.web:pax-web-jsp:1.1.2"/>
<capability name="org.ops4j.pax.web:pax-web-extender-war:1.1.2"/>
Added osgi 'Dependencies' to the Manifest file.
When i deploy the war i get following error saying Missing Dependencies and deployment is rolled back.
Missing[jboss.module.spec.service.\"deployment.org.apache.aries.samples.blueprint.helloworld.api-1.0.1-SNAPSHOT\".main]","jboss.deployment.unit.\"xxxxx.war\".POST_MODULE Missing[JBAS014861: <one or more transitive dependencie
Can anyone advice me if i am missing anything , why is jboss not able to resolve the osgi bundle dependency from a war