Issue Details (XML | Word | Printable)

Key: OSGI-478
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Costin Leau
Reporter: Yan Pujante
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Spring OSGi

Extender pattern in ...osgi.extender and ...osgi.web.extender conflict with each other

Created: 07/May/08 09:19 AM   Updated: 26/Jun/08 05:40 AM
Component/s: EXTENDER
Affects Version/s: 1.1 M2
Fix Version/s: 1.1 RC1

Time Tracking:
Not Specified

Issue Links:
Related
 


 Description  « Hide
Here is the scenario:

* deploy the bundle for org.springframework.bundle.osgi.extender which now 'listens' to spring powered bundles (META-INF/spring/*.xml) (ConfigUtils.isSpringOsgiPoweredBundle)

* deploy the bundle for org.springframework.bundle.osgi.web.extender

* configure the 2nd bundle using a fragment (for example to provide a new war deployer). Note that the code in org.springframework.osgi.web.extender.internal.activator.WarListenerConfiguration lines 79:
Enumeration enm = bundle.findEntries("META-INF/spring", "*.xml", false);

is looking for the same pattern.

The extender pattern of the first bundle matches => process all META-INF/spring/*.xml files
The extender configuration of the second bundle matches => process all META-INF/spring/*.xml files

=> as a result the beans are processed and created twice.

 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Costin Leau added a comment - 12/May/08 04:40 AM
The same pattern is on purpose. Both extenders exist by themselves and process only the fragments that are attached to them.
Since a fragment can be attached to only one host, it means that the files are picked only by the extender to which they are attached.
Moreover, the osgi extender looks for this pattern only on bundles that are started. Fragments cannot be started only resolved.

This being said, I'd be interested in any tests or examples that you have that expose the problem you described.

Yan Pujante added a comment - 12/May/08 09:23 AM
Here is my scenario (100% reproducible):

I have the following bundles:
36 ACTIVE org.springframework.bundle.osgi.extender_1.1.0.m2
40 ACTIVE org.springframework.bundle.osgi.web.extender_1.1.0.m2

I then install a fragment bundle which needs to be attached to 40:
install file:/Users/ypujante/.m2/repository/com/linkedin/kernel-core/lispring-osgi-web/1.0.0-SNAPSHOT/lispring-osgi-web-1.0.0-SNAPSHOT.jar
Bundle id is 61

I then do a
refresh 40
so that the fragment gets attached to 40
40 ACTIVE org.springframework.bundle.osgi.web.extender_1.1.0.m2
                    Fragments=61

I see the following on the console:
com.linkedin.lispring.osgi.web.OsgiJettyComponentWarDeployer@871d3e
com.linkedin.lispring.osgi.web.OsgiJettyComponentWarDeployer@b9b888

(the constructor for my war deployer implementation simply does a system.out.println(this)

As you can see the object is being created twice.

And it makes sense. I agree with you that a fragment cannot be started, but as soon as you do 'refresh 40' 2 things happen:

1) bundle 40 extender pattern detects the META-INF/spring/*.xml and correctly loads the beans in them to discover the war depoyer
2) but bundle 36 now sees a new bundle: bundle 40 + fragment 61... for bundle 36 it does not know that the META-INF/spring/*.xml are coming from a bundle... that is the beauty of osgi... it is transparent: bundle 40 + fragment 61 is a new whole bundle... the extender pattersn (for 36) kicks in because ConfigUtils.isSpringOsgiPoweredBundle(40) now returns true... as a result the same beans get instantiated a second time as demonstrated by the output. In other words 36 is not acting on 61 but on 40 which is a valid, started bundle...

The spring file in bundle 61 is simply doing:
  <bean id="warDeployer" class="com.linkedin.lispring.osgi.web.OsgiJettyComponentWarDeployer"/>



Costin Leau added a comment - 05/Jun/08 02:44 AM
Yan, I've modified the extender configuration locations to META-INF/spring/extender/*.xml. This should avoid confusion with both users and other extenders.
The change is available in the latest nightly build.
It would be swell if you could give the TRUNK a try and report back.
Thanks,

Yan Pujante added a comment - 05/Jun/08 10:15 AM
Costin, that should definitely fix the problem. I am not sure how to get a trunk build. I was able to checkout the source code from the trunk but not compile it... is there a nightly build somewhere ?

Getting this error at build time (mvn install):
Missing:
----------
1) net.java.dev.jets3t:jets3t:jar:0.5.1-20080115

I am definitely not a pro of maven... so if there is a premade nightly build I will be more than happy to try it out.

Costin Leau added a comment - 05/Jun/08 10:29 AM
Hmm - haven't seen that before. However, see the home page for repositories: http://www.springframework.org/osgi#repos

Yan Pujante added a comment - 05/Jun/08 05:48 PM
Hmmm. My company policy does not allow me to get snapshots :( from maven... as soon as it is available as a milestone I will test it out.

Costin Leau added a comment - 06/Jun/08 04:36 AM
Okay - the code is going into freezing state and it will be come out as an RC. You can download the code yourself if you want to try it out - you can build locally for example.
Cheers,