You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Norbert Somlai <ns...@gmail.com> on 2010/04/16 12:53:49 UTC

Fragment bundle does not get attached

Hello,

We have a fragment bundle that loads without warnings and gets into Resolved
state. However, it does not get attached to any host and the bundle using it
gets resolved and started but fails with a ClassNotFoundException. Could you
tell us what could be wrong?

-> ps
...
[   2] [Resolved   ] [    1] Messages fragment (1.0.0.messages)
[   3] [Resolved   ] [    1] SampleClient (1.0.0)

-> inspect fragment capability 2
com.expedia.platform.messages.fragment [2] is attached to:
----------------------------------------------------------
Nothing

MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Messages fragment
Bundle-SymbolicName: com.acme.platform.messages.fragment
Bundle-Version: 1.0.0.messages
Bundle-Vendor: EPAM
Fragment-Host: system.bundle;extension:=framework
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: fragment/com.acme.e3.platform.samples.messaging.s
 ampleservice.messages.v1-1.1.0.jar
Export-Package: com.acme.e3.platform.samples.messaging.sampleservic
 e.messages.v1

Error:
-> start 3
Exception: java.lang.NoClassDefFoundError:
com/expedia/e3/platform/samples/messaging/sampleservice/messages/v1/ConcatenateStringsRequestType

Thanks, Norbert
-- 
View this message in context: http://old.nabble.com/Fragment-bundle-does-not-get-attached-tp28265468p28265468.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Fragment bundle does not get attached

Posted by Christopher Brind <ch...@googlemail.com>.
Norbert,

Have a look at aQute's bnd tool to help speed up the process of wrapping the
JARs in a bundle:
www.aqute.biz/Code/Bnd

<http://www.aqute.biz/Code/Bnd>If the JARs in question are reasonably common
and been around for a while they may already be available on a repository,
for instance SpringSource's repository:
www.springsource.com/repository/app/

Hope that helps.

Cheers,
Chris



On 16 April 2010 19:51, Richard S. Hall <he...@ungoverned.org> wrote:

> On 4/16/10 14:07, Norbert Somlai wrote:
>
>> Richard, Guo,
>>
>> Thanks for the reply. The Felix version is 2.0.4.
>>
>> I'm not perfectly familiar with fragments yet so it may be a design
>> mistake
>> anyway. This fragment bundle contains some common JAR libraries we plan to
>> import into multiple bundles so we don't have to add them to each of our
>> bundles.
>>
>> So we created a fragment bundle, added the JARs to the bundle classpath
>> and
>> exported them as you can see in the manifest. Is this the right way to do
>> this? What should be the host bundle in this case?
>>
>>
>
> In theory, you can use system bundle framework extensions this way, but I'd
> say it wasn't the primary purpose. If you are going to use this approach,
> then you still need to import these packages in the bundles that are going
> to use them, since a system bundle extension attaches to the system bundle,
> not to the clients.
>
> However, it seems this entire approach is incorrect. The primary purpose of
> bundles is to share common JAR libraries, so why don't you just package them
> as a normal bundle and import them in the client bundles?
>
> -> richard
>
>
>
>> Richard S. Hall wrote:
>>
>>
>>> The above is a system bundle framework extension, which automatically
>>> gets attached to the system bundle when it is installed; this is why you
>>> see if get resolved immediately. However, the fact that it is attached
>>> to nothing is sort of a missed special case since system bundle
>>> extensions are handled differently than normal fragments. This message
>>> should be improved in the framework.
>>>
>>> If you are trying to create a fragment for SampleClient, you should have
>>> something like this in the fragment metadata:
>>>
>>>      Fragment-Host:<symbolic-name-of-sample-client>
>>>
>>> This will cause the fragment to get attached to SampleClient, rather
>>> than the system bundle.
>>>
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Fragment bundle does not get attached

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 4/19/10 10:50, Norbert Somlai wrote:
> Thanks for the tip, but I couldn't make it work, it throws a
> ClassNotFoundException for org.apache.felix.main.Main. Not to mention the
> fact I have no idea what this does. :-)
>    

You must have to specify the absolute path to the felix.jar file in the 
command I suggested... Felix' launcher uses the standard OSGi launching 
API, so it can launch Equinox too. You just need to put Equinox on the 
class path first.

> It seems we found the cause. For configuration admin we used
> org.eclipse.osgi.services_3.2.0.v20090520-1800.jar under Felix, thinking
> that it should be platform-independent. Replacing it with
> org.apache.felix.configadmin-1.2.4.jar seems to have solved the issue.
>    

Good. Well, Felix Config Admin should be platform independent...

-> richard

>
> Richard S. Hall wrote:
>    
>> Depends on how Equinox is configured...I am not sure if they are still
>> automatically boot delegating and to which class loader, but if so that
>> could explain why it works. If you want to investigate some more, try to
>> run your example on Equinox using the Felix launcher, that way we will
>> know everything is configured the same. For example:
>>
>>       java -cp /path/to/equinox.jar:./bin/felix.jar
>> org.apache.felix.main.Main
>>
>>      
>    

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Fragment bundle does not get attached

Posted by Norbert Somlai <ns...@gmail.com>.
Thanks for the tip, but I couldn't make it work, it throws a
ClassNotFoundException for org.apache.felix.main.Main. Not to mention the
fact I have no idea what this does. :-)

It seems we found the cause. For configuration admin we used
org.eclipse.osgi.services_3.2.0.v20090520-1800.jar under Felix, thinking
that it should be platform-independent. Replacing it with
org.apache.felix.configadmin-1.2.4.jar seems to have solved the issue.


Richard S. Hall wrote:
> 
> Depends on how Equinox is configured...I am not sure if they are still 
> automatically boot delegating and to which class loader, but if so that 
> could explain why it works. If you want to investigate some more, try to 
> run your example on Equinox using the Felix launcher, that way we will 
> know everything is configured the same. For example:
> 
>      java -cp /path/to/equinox.jar:./bin/felix.jar 
> org.apache.felix.main.Main
> 

-- 
View this message in context: http://old.nabble.com/Fragment-bundle-does-not-get-attached-tp28265468p28287690.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Fragment bundle does not get attached

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 4/17/10 2:44, Norbert Somlai wrote:
> I will need consult on this question but I think the main reason was that
> this is private legacy code of our client in many JARs and a million
> packages (@Chris: yes, we tried BND on them and it generated 200K manifest
> files on some of them), from which we use a few only but we wanted to skip
> the tedious process of mapping their dependencies. I guess the developers
> were just looking for a way so that they don't have to touch them. :-)
>    

Taking shortcuts is rarely the best way. Using a modularity layer, but 
trying to avoid the restrictions it imposes seems somewhat 
contradictory. Regarding BND, you don't have to have it export 
everything. You can specify a BND file that tells it to embed all the 
packages from the library using Private-Package, but only export a 
subset using Export-Package, both of which can use wildcards. Of course, 
you'll still need to examine the metadata to make sure you export 
everything used by the specified exported packages...not sure if BND 
will complain about this or not.

> On the question of our issue being caused by a wrong import: our setup works
> fine in Equinox. We use Pax for testing and that fails with Felix. Also set
> up a usual Felix installation to try and that refuses to work as well. I
> know Felix is somewhat more picky on the manifest format (for example,
> Equinox seems to accept extension=framework while Felix needs ':=' ), so it
> may be some typo as well. The problem is it does not complain and debug mode
> doesn't give us anything out of the ordinary either. Will keep
> investigating.
>    

Depends on how Equinox is configured...I am not sure if they are still 
automatically boot delegating and to which class loader, but if so that 
could explain why it works. If you want to investigate some more, try to 
run your example on Equinox using the Felix launcher, that way we will 
know everything is configured the same. For example:

     java -cp /path/to/equinox.jar:./bin/felix.jar 
org.apache.felix.main.Main

If you perform this command in the Felix install directory, it will 
launch Equinox using the Felix launcher and configuration file (assuming 
you are using a recent version of Equinox).

See if it still works, if so, then see if you can tell me how to 
recreate the scenario or send me privately your bundles to debug it.

-> richard

>
> Richard S. Hall wrote:
>    
>>
>> However, it seems this entire approach is incorrect. The primary purpose
>> of bundles is to share common JAR libraries, so why don't you just
>> package them as a normal bundle and import them in the client bundles?
>>
>>
>>      

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Fragment bundle does not get attached

Posted by Norbert Somlai <ns...@gmail.com>.
I will need consult on this question but I think the main reason was that
this is private legacy code of our client in many JARs and a million
packages (@Chris: yes, we tried BND on them and it generated 200K manifest
files on some of them), from which we use a few only but we wanted to skip
the tedious process of mapping their dependencies. I guess the developers
were just looking for a way so that they don't have to touch them. :-)

On the question of our issue being caused by a wrong import: our setup works
fine in Equinox. We use Pax for testing and that fails with Felix. Also set
up a usual Felix installation to try and that refuses to work as well. I
know Felix is somewhat more picky on the manifest format (for example,
Equinox seems to accept extension=framework while Felix needs ':=' ), so it
may be some typo as well. The problem is it does not complain and debug mode
doesn't give us anything out of the ordinary either. Will keep
investigating.


Richard S. Hall wrote:
> 
> 
> However, it seems this entire approach is incorrect. The primary purpose 
> of bundles is to share common JAR libraries, so why don't you just 
> package them as a normal bundle and import them in the client bundles?
> 
> 
-- 
View this message in context: http://old.nabble.com/Fragment-bundle-does-not-get-attached-tp28265468p28274419.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Fragment bundle does not get attached

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 4/16/10 14:07, Norbert Somlai wrote:
> Richard, Guo,
>
> Thanks for the reply. The Felix version is 2.0.4.
>
> I'm not perfectly familiar with fragments yet so it may be a design mistake
> anyway. This fragment bundle contains some common JAR libraries we plan to
> import into multiple bundles so we don't have to add them to each of our
> bundles.
>
> So we created a fragment bundle, added the JARs to the bundle classpath and
> exported them as you can see in the manifest. Is this the right way to do
> this? What should be the host bundle in this case?
>    

In theory, you can use system bundle framework extensions this way, but 
I'd say it wasn't the primary purpose. If you are going to use this 
approach, then you still need to import these packages in the bundles 
that are going to use them, since a system bundle extension attaches to 
the system bundle, not to the clients.

However, it seems this entire approach is incorrect. The primary purpose 
of bundles is to share common JAR libraries, so why don't you just 
package them as a normal bundle and import them in the client bundles?

-> richard

>
> Richard S. Hall wrote:
>    
>> The above is a system bundle framework extension, which automatically
>> gets attached to the system bundle when it is installed; this is why you
>> see if get resolved immediately. However, the fact that it is attached
>> to nothing is sort of a missed special case since system bundle
>> extensions are handled differently than normal fragments. This message
>> should be improved in the framework.
>>
>> If you are trying to create a fragment for SampleClient, you should have
>> something like this in the fragment metadata:
>>
>>       Fragment-Host:<symbolic-name-of-sample-client>
>>
>> This will cause the fragment to get attached to SampleClient, rather
>> than the system bundle.
>>
>>      
>    

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Fragment bundle does not get attached

Posted by Norbert Somlai <ns...@gmail.com>.
Richard, Guo,

Thanks for the reply. The Felix version is 2.0.4.

I'm not perfectly familiar with fragments yet so it may be a design mistake
anyway. This fragment bundle contains some common JAR libraries we plan to
import into multiple bundles so we don't have to add them to each of our
bundles.

So we created a fragment bundle, added the JARs to the bundle classpath and
exported them as you can see in the manifest. Is this the right way to do
this? What should be the host bundle in this case?


Richard S. Hall wrote:
> 
> The above is a system bundle framework extension, which automatically 
> gets attached to the system bundle when it is installed; this is why you 
> see if get resolved immediately. However, the fact that it is attached 
> to nothing is sort of a missed special case since system bundle 
> extensions are handled differently than normal fragments. This message 
> should be improved in the framework.
> 
> If you are trying to create a fragment for SampleClient, you should have 
> something like this in the fragment metadata:
> 
>      Fragment-Host: <symbolic-name-of-sample-client>
> 
> This will cause the fragment to get attached to SampleClient, rather 
> than the system bundle.
> 

-- 
View this message in context: http://old.nabble.com/Fragment-bundle-does-not-get-attached-tp28265468p28270107.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Fragment bundle does not get attached

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 4/16/10 6:54, Norbert Somlai wrote:
> Hello,
>
> We have a fragment bundle that loads without warnings and gets into Resolved
> state. However, it does not get attached to any host and the bundle using it
> gets resolved and started but fails with a ClassNotFoundException. Could you
> tell us what could be wrong?
>
> ->  ps
> ...
> [   2] [Resolved   ] [    1] Messages fragment (1.0.0.messages)
> [   3] [Resolved   ] [    1] SampleClient (1.0.0)
>
> ->  inspect fragment capability 2
> com.acme.platform.messages.fragment [2] is attached to:
> ----------------------------------------------------------
> Nothing
>
> MANIFEST.MF:
> Manifest-Version: 1.0
> Bundle-ManifestVersion: 2
> Bundle-Name: Messages fragment
> Bundle-SymbolicName: com.acme.platform.messages.fragment
> Bundle-Version: 1.0.0.messages
> Bundle-Vendor: EPAM
> Fragment-Host: system.bundle;extension:=framework
>    

The above is a system bundle framework extension, which automatically 
gets attached to the system bundle when it is installed; this is why you 
see if get resolved immediately. However, the fact that it is attached 
to nothing is sort of a missed special case since system bundle 
extensions are handled differently than normal fragments. This message 
should be improved in the framework.

If you are trying to create a fragment for SampleClient, you should have 
something like this in the fragment metadata:

     Fragment-Host: <symbolic-name-of-sample-client>

This will cause the fragment to get attached to SampleClient, rather 
than the system bundle.

On the other hand, if you really want this to be exported from the 
system bundle (which is the purpose of system bundle framework 
extensions), then it appears as if your SampleClient bundle is not 
properly importing the package.

-> richard

> Bundle-RequiredExecutionEnvironment: J2SE-1.5
> Bundle-ClassPath: fragment/com.acme.e3.platform.samples.messaging.s
>   ampleservice.messages.v1-1.1.0.jar
> Export-Package: com.acme.e3.platform.samples.messaging.sampleservic
>   e.messages.v1
>
> Error:
> ->  start 3
> Exception: java.lang.NoClassDefFoundError:
> com/expedia/e3/platform/samples/messaging/sampleservice/messages/v1/ConcatenateStringsRequestType
>
> Thanks, Norbert
>    

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Fragment bundle does not get attached

Posted by Guo Du <mr...@gmail.com>.
On Fri, Apr 16, 2010 at 11:54 AM, Norbert Somlai <ns...@gmail.com> wrote:
> We have a fragment bundle that loads without warnings and gets into Resolved
> state. However, it does not get attached to any host and the bundle using it
> gets resolved and started but fails with a ClassNotFoundException. Could you
> tell us what could be wrong?
Early version of felix (e.g. 2.0.0) has problems with fragment.

What's your version? You may turn on the debug flag for felix to see
more details.

-Guo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org