You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Wade Girard <wa...@gmail.com> on 2013/10/25 06:15:36 UTC

Noob Help

I have been experimenting with felix and learning OSGi for the last week. I really like what it has to offer and believe that I can use it for an upcoming project that I am working on.

I have been using maven to build bundles, and creating small test bundles, that has been going well. I have run into a snag though while trying to create a bundle from an existing jar file project. To figure out the dependencies that I need to include in the jar, by adding to the "Private-Package" in the pom.xml for the bundle plugin, I have been building-installing-starting, and then just adding each missing package as it's reported.

I am currently stuck on this one though

org.osgi.framework.BundleException: Unresolved constraint in bundle x.y.x [41]: Unable to resolve 41.0: missing requirement [41.0] osgi.wiring.package; (osgi.wiring.package=oracle.xml.parser)

That package is not being used in my project directly, I do use an xml reader to read rss feeds, that uses the com.sun.syndication.io.XmlReader class.

If I add "oracle.xml.*" to the list of packages, then the build gives the warning message
[WARNING] Warning building bundle x.y:z:bundle:2.0.0 : Instructions for Private-Package that are never used: oracle\.xml\..*|oracle\.xml
and when I install-start the bundle I get the same error message

Any help is appreciated

Thanks
Wade

Re: Noob Help

Posted by Wade Girard <wa...@gmail.com>.
Thank you, that would be another approach.

I finally realized what I was doing wrong. I was not using import-package or export-package as I was trying to build my first bundle. I was completely ignoring them thinking that I would be able to build my bundle as a “test” with just using the default values that the maven plugin generates.

What led me down that track was the suggestion to use “!oracle.xml”. That had no effect in the private-package.

Anyway, in my import-package I added !this.this and !that.that for the things that I specifically didn’t want to import, and I explicitly spell out the stuff that I want to import.

I also added all my internal stuff that I want to be able to use in other bundles to my export-package. (this is a core lib for my project)

Also, when I started to use these, maven would provide much better feedback on what I needed to do. 

Thanks for your help, I hope this helps someone else.

Wade

On Oct 27, 2013, at 3:59 AM, Tommy Svensson <to...@natusoft.se> wrote:

> Hello Wade,
> 
> I am assuming you are using the maven-bundle-plugin which is a wrapper around the bnd tool. This is a very good and useful tool, but sometimes it sees a bit much. It actually isn't bnd:s fault. It can't determine what is relevant and what is not. 
> 
> I had a very similar problem. Note that I didn't know about the !package to exclude so I never tried that. That sounds like it should do the trick. I any case what I did in this very specific case was to let maven-bundle-plugin generate a MANIFEST.MF for me. Then I changed my project to <packaging>jar</packaging> instead and put the MANIFEST.MF under src/main/resources/META-INF and added the following to my pom:
> 
>            <plugin>
>                <artifactId>maven-jar-plugin</artifactId>
>                <configuration>
>                    <archive>
>                        <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
>                    </archive>
>                </configuration>
>            </plugin>
> 
> After that I edited the MANIFEST.MF "Import-Package:" part removing any import I thought irrelevant. Basically I kept any package part of rt.jar (java.* javax.*, org.w3c.*), and packages imported by my code. It then worked fine. I think I removed about 70% of the generated imports so excluding them with !package would have been messy.
> 
> The problem arises when you have dependencies on "large" frameworks/libraries with many dependencies. In my case openjpa-all-2.2.0.jar pulled in tons of packages that weren't needed and weren't available runtime. 
> 
> In this case openjpa-all-2.2.0.jar did not automatically get included in the bundle so I put it and another jar I needed into src/main/resources/lib, and modified Bundle-Classpath accordingly:
> 
> Bundle-ClassPath: .,
> lib/openjpa-all-2.2.0.jar,
> lib/xob-4.0.jar
> 
> in MANIFEST.MF. 
> 
> Maven might provide a better way to bundle dependencies without maven-bundle-plugin. 
> 
> I did spend a lot of time before I gave up and took this approach. Manually managing the MAINFEST.MF file when needed is not that difficult. I do stick to using maven-bundle-plugin for most of my bundles. I use this approach only when it gives me to many imports.
> 
> /Tommy
> 
> 
> 26 okt 2013 kl. 16:19 skrev Wade Girard <wa...@gmail.com>:
> 
>> is there something that I am doing wrong???
>> 
>> I tried adding optional=true to everything, that did not resolve it, and neither did the !oracle.xml thing. So I found the oracle jdeveloper tools, downloaded them, and added the oracle.xml jars to my maven repository, and to my dependencies. Which is odd to me because I ever needed it before.
>> 
>> Since then it has just been a constant string of jars that I have had to go out and find, download, put in my repository, and add into the dependencies in my pom and the Private-Package definition.
>> 
>> It just feels wrong. The reason I say that is that before, I didn't need to include all this stuff in my project, and my jar file worked perfectly fine.
>> 
>> Am I missing something? Now it's asking for javax.resource… I'm kind of stuck on this one.
>> 
>> Plus, in order to find all of these I am having to build the jar, uninstall the previous jar from felix, install the new jar, and try and start it. I then look at the error and try to resolve it, rinse and repeat. Is that really the correct way to go about this?
>> 
>> Thanks for your help.
>> Wade
>> 
>> On Oct 25, 2013, at 7:30 AM, Snorre Lothar von Gohren Edwin <sn...@gmail.com> wrote:
>> 
>>> Or you can try to figure out which bundle depends on oracle.xml and put it
>>> with a flag optional=true.
>>> This happened when I tried to create a bundle out of the OPC-UA SDK from
>>> prosys.
>>> I had the same problem with  sun.security.x509 and sun.security.util on
>>> some packages. But these are usually integrated into the JVM.
>>> 
>>> 
>>> On Fri, Oct 25, 2013 at 2:24 PM, Richard S. Hall <he...@ungoverned.org>wrote:
>>> 
>>>> Try to exclude it in your Import-Package in your pom.xml (e.g.,
>>>> "!oracle.xml.*").
>>>> 
>>>> -> richard
>>>> 
>>>> 
>>>> On 10/25/13, 00:15 , Wade Girard wrote:
>>>> 
>>>>> I have been experimenting with felix and learning OSGi for the last week.
>>>>> I really like what it has to offer and believe that I can use it for an
>>>>> upcoming project that I am working on.
>>>>> 
>>>>> I have been using maven to build bundles, and creating small test
>>>>> bundles, that has been going well. I have run into a snag though while
>>>>> trying to create a bundle from an existing jar file project. To figure out
>>>>> the dependencies that I need to include in the jar, by adding to the
>>>>> "Private-Package" in the pom.xml for the bundle plugin, I have been
>>>>> building-installing-starting, and then just adding each missing package as
>>>>> it's reported.
>>>>> 
>>>>> I am currently stuck on this one though
>>>>> 
>>>>> org.osgi.framework.**BundleException: Unresolved constraint in bundle
>>>>> x.y.x [41]: Unable to resolve 41.0: missing requirement [41.0]
>>>>> osgi.wiring.package; (osgi.wiring.package=oracle.**xml.parser)
>>>>> 
>>>>> That package is not being used in my project directly, I do use an xml
>>>>> reader to read rss feeds, that uses the com.sun.syndication.io.**XmlReader
>>>>> class.
>>>>> 
>>>>> If I add "oracle.xml.*" to the list of packages, then the build gives the
>>>>> warning message
>>>>> [WARNING] Warning building bundle x.y:z:bundle:2.0.0 : Instructions for
>>>>> Private-Package that are never used: oracle\.xml\..*|oracle\.xml
>>>>> and when I install-start the bundle I get the same error message
>>>>> 
>>>>> Any help is appreciated
>>>>> 
>>>>> Thanks
>>>>> Wade
>>>>> 
>>>> 
>>>> 
>>>> ------------------------------**------------------------------**---------
>>>> To unsubscribe, e-mail: users-unsubscribe@felix.**apache.org<us...@felix.apache.org>
>>>> For additional commands, e-mail: users-help@felix.apache.org
>>>> 
>>>> 
>>> 
>>> 
>>> -- 
>>> Mvh
>>> Snorre Lothar von Gohren Edwin
>>> MeetMe: http://doodle.com/vonGohren
>>> +47 411 611 94
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


Re: Noob Help

Posted by Tommy Svensson <to...@natusoft.se>.
Hello Wade,

I am assuming you are using the maven-bundle-plugin which is a wrapper around the bnd tool. This is a very good and useful tool, but sometimes it sees a bit much. It actually isn't bnd:s fault. It can't determine what is relevant and what is not. 

I had a very similar problem. Note that I didn't know about the !package to exclude so I never tried that. That sounds like it should do the trick. I any case what I did in this very specific case was to let maven-bundle-plugin generate a MANIFEST.MF for me. Then I changed my project to <packaging>jar</packaging> instead and put the MANIFEST.MF under src/main/resources/META-INF and added the following to my pom:

            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>

After that I edited the MANIFEST.MF "Import-Package:" part removing any import I thought irrelevant. Basically I kept any package part of rt.jar (java.* javax.*, org.w3c.*), and packages imported by my code. It then worked fine. I think I removed about 70% of the generated imports so excluding them with !package would have been messy.

The problem arises when you have dependencies on "large" frameworks/libraries with many dependencies. In my case openjpa-all-2.2.0.jar pulled in tons of packages that weren't needed and weren't available runtime. 

In this case openjpa-all-2.2.0.jar did not automatically get included in the bundle so I put it and another jar I needed into src/main/resources/lib, and modified Bundle-Classpath accordingly:

Bundle-ClassPath: .,
 lib/openjpa-all-2.2.0.jar,
 lib/xob-4.0.jar

in MANIFEST.MF. 

Maven might provide a better way to bundle dependencies without maven-bundle-plugin. 

I did spend a lot of time before I gave up and took this approach. Manually managing the MAINFEST.MF file when needed is not that difficult. I do stick to using maven-bundle-plugin for most of my bundles. I use this approach only when it gives me to many imports.

/Tommy
 

26 okt 2013 kl. 16:19 skrev Wade Girard <wa...@gmail.com>:

> is there something that I am doing wrong???
> 
> I tried adding optional=true to everything, that did not resolve it, and neither did the !oracle.xml thing. So I found the oracle jdeveloper tools, downloaded them, and added the oracle.xml jars to my maven repository, and to my dependencies. Which is odd to me because I ever needed it before.
> 
> Since then it has just been a constant string of jars that I have had to go out and find, download, put in my repository, and add into the dependencies in my pom and the Private-Package definition.
> 
> It just feels wrong. The reason I say that is that before, I didn't need to include all this stuff in my project, and my jar file worked perfectly fine.
> 
> Am I missing something? Now it's asking for javax.resource… I'm kind of stuck on this one.
> 
> Plus, in order to find all of these I am having to build the jar, uninstall the previous jar from felix, install the new jar, and try and start it. I then look at the error and try to resolve it, rinse and repeat. Is that really the correct way to go about this?
> 
> Thanks for your help.
> Wade
> 
> On Oct 25, 2013, at 7:30 AM, Snorre Lothar von Gohren Edwin <sn...@gmail.com> wrote:
> 
>> Or you can try to figure out which bundle depends on oracle.xml and put it
>> with a flag optional=true.
>> This happened when I tried to create a bundle out of the OPC-UA SDK from
>> prosys.
>> I had the same problem with  sun.security.x509 and sun.security.util on
>> some packages. But these are usually integrated into the JVM.
>> 
>> 
>> On Fri, Oct 25, 2013 at 2:24 PM, Richard S. Hall <he...@ungoverned.org>wrote:
>> 
>>> Try to exclude it in your Import-Package in your pom.xml (e.g.,
>>> "!oracle.xml.*").
>>> 
>>> -> richard
>>> 
>>> 
>>> On 10/25/13, 00:15 , Wade Girard wrote:
>>> 
>>>> I have been experimenting with felix and learning OSGi for the last week.
>>>> I really like what it has to offer and believe that I can use it for an
>>>> upcoming project that I am working on.
>>>> 
>>>> I have been using maven to build bundles, and creating small test
>>>> bundles, that has been going well. I have run into a snag though while
>>>> trying to create a bundle from an existing jar file project. To figure out
>>>> the dependencies that I need to include in the jar, by adding to the
>>>> "Private-Package" in the pom.xml for the bundle plugin, I have been
>>>> building-installing-starting, and then just adding each missing package as
>>>> it's reported.
>>>> 
>>>> I am currently stuck on this one though
>>>> 
>>>> org.osgi.framework.**BundleException: Unresolved constraint in bundle
>>>> x.y.x [41]: Unable to resolve 41.0: missing requirement [41.0]
>>>> osgi.wiring.package; (osgi.wiring.package=oracle.**xml.parser)
>>>> 
>>>> That package is not being used in my project directly, I do use an xml
>>>> reader to read rss feeds, that uses the com.sun.syndication.io.**XmlReader
>>>> class.
>>>> 
>>>> If I add "oracle.xml.*" to the list of packages, then the build gives the
>>>> warning message
>>>> [WARNING] Warning building bundle x.y:z:bundle:2.0.0 : Instructions for
>>>> Private-Package that are never used: oracle\.xml\..*|oracle\.xml
>>>> and when I install-start the bundle I get the same error message
>>>> 
>>>> Any help is appreciated
>>>> 
>>>> Thanks
>>>> Wade
>>>> 
>>> 
>>> 
>>> ------------------------------**------------------------------**---------
>>> To unsubscribe, e-mail: users-unsubscribe@felix.**apache.org<us...@felix.apache.org>
>>> For additional commands, e-mail: users-help@felix.apache.org
>>> 
>>> 
>> 
>> 
>> -- 
>> Mvh
>> Snorre Lothar von Gohren Edwin
>> MeetMe: http://doodle.com/vonGohren
>> +47 411 611 94
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


Re: Noob Help

Posted by Wade Girard <wa...@gmail.com>.
is there something that I am doing wrong???

I tried adding optional=true to everything, that did not resolve it, and neither did the !oracle.xml thing. So I found the oracle jdeveloper tools, downloaded them, and added the oracle.xml jars to my maven repository, and to my dependencies. Which is odd to me because I ever needed it before.

Since then it has just been a constant string of jars that I have had to go out and find, download, put in my repository, and add into the dependencies in my pom and the Private-Package definition.

It just feels wrong. The reason I say that is that before, I didn't need to include all this stuff in my project, and my jar file worked perfectly fine.

Am I missing something? Now it's asking for javax.resource… I'm kind of stuck on this one.

Plus, in order to find all of these I am having to build the jar, uninstall the previous jar from felix, install the new jar, and try and start it. I then look at the error and try to resolve it, rinse and repeat. Is that really the correct way to go about this?

Thanks for your help.
Wade

On Oct 25, 2013, at 7:30 AM, Snorre Lothar von Gohren Edwin <sn...@gmail.com> wrote:

> Or you can try to figure out which bundle depends on oracle.xml and put it
> with a flag optional=true.
> This happened when I tried to create a bundle out of the OPC-UA SDK from
> prosys.
> I had the same problem with  sun.security.x509 and sun.security.util on
> some packages. But these are usually integrated into the JVM.
> 
> 
> On Fri, Oct 25, 2013 at 2:24 PM, Richard S. Hall <he...@ungoverned.org>wrote:
> 
>> Try to exclude it in your Import-Package in your pom.xml (e.g.,
>> "!oracle.xml.*").
>> 
>> -> richard
>> 
>> 
>> On 10/25/13, 00:15 , Wade Girard wrote:
>> 
>>> I have been experimenting with felix and learning OSGi for the last week.
>>> I really like what it has to offer and believe that I can use it for an
>>> upcoming project that I am working on.
>>> 
>>> I have been using maven to build bundles, and creating small test
>>> bundles, that has been going well. I have run into a snag though while
>>> trying to create a bundle from an existing jar file project. To figure out
>>> the dependencies that I need to include in the jar, by adding to the
>>> "Private-Package" in the pom.xml for the bundle plugin, I have been
>>> building-installing-starting, and then just adding each missing package as
>>> it's reported.
>>> 
>>> I am currently stuck on this one though
>>> 
>>> org.osgi.framework.**BundleException: Unresolved constraint in bundle
>>> x.y.x [41]: Unable to resolve 41.0: missing requirement [41.0]
>>> osgi.wiring.package; (osgi.wiring.package=oracle.**xml.parser)
>>> 
>>> That package is not being used in my project directly, I do use an xml
>>> reader to read rss feeds, that uses the com.sun.syndication.io.**XmlReader
>>> class.
>>> 
>>> If I add "oracle.xml.*" to the list of packages, then the build gives the
>>> warning message
>>> [WARNING] Warning building bundle x.y:z:bundle:2.0.0 : Instructions for
>>> Private-Package that are never used: oracle\.xml\..*|oracle\.xml
>>> and when I install-start the bundle I get the same error message
>>> 
>>> Any help is appreciated
>>> 
>>> Thanks
>>> Wade
>>> 
>> 
>> 
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@felix.**apache.org<us...@felix.apache.org>
>> For additional commands, e-mail: users-help@felix.apache.org
>> 
>> 
> 
> 
> -- 
> Mvh
> Snorre Lothar von Gohren Edwin
> MeetMe: http://doodle.com/vonGohren
> +47 411 611 94


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


Re: Noob Help

Posted by Snorre Lothar von Gohren Edwin <sn...@gmail.com>.
Or you can try to figure out which bundle depends on oracle.xml and put it
with a flag optional=true.
This happened when I tried to create a bundle out of the OPC-UA SDK from
prosys.
I had the same problem with  sun.security.x509 and sun.security.util on
some packages. But these are usually integrated into the JVM.


On Fri, Oct 25, 2013 at 2:24 PM, Richard S. Hall <he...@ungoverned.org>wrote:

> Try to exclude it in your Import-Package in your pom.xml (e.g.,
> "!oracle.xml.*").
>
> -> richard
>
>
> On 10/25/13, 00:15 , Wade Girard wrote:
>
>> I have been experimenting with felix and learning OSGi for the last week.
>> I really like what it has to offer and believe that I can use it for an
>> upcoming project that I am working on.
>>
>> I have been using maven to build bundles, and creating small test
>> bundles, that has been going well. I have run into a snag though while
>> trying to create a bundle from an existing jar file project. To figure out
>> the dependencies that I need to include in the jar, by adding to the
>> "Private-Package" in the pom.xml for the bundle plugin, I have been
>> building-installing-starting, and then just adding each missing package as
>> it's reported.
>>
>> I am currently stuck on this one though
>>
>> org.osgi.framework.**BundleException: Unresolved constraint in bundle
>> x.y.x [41]: Unable to resolve 41.0: missing requirement [41.0]
>> osgi.wiring.package; (osgi.wiring.package=oracle.**xml.parser)
>>
>> That package is not being used in my project directly, I do use an xml
>> reader to read rss feeds, that uses the com.sun.syndication.io.**XmlReader
>> class.
>>
>> If I add "oracle.xml.*" to the list of packages, then the build gives the
>> warning message
>> [WARNING] Warning building bundle x.y:z:bundle:2.0.0 : Instructions for
>> Private-Package that are never used: oracle\.xml\..*|oracle\.xml
>> and when I install-start the bundle I get the same error message
>>
>> Any help is appreciated
>>
>> Thanks
>> Wade
>>
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@felix.**apache.org<us...@felix.apache.org>
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Mvh
Snorre Lothar von Gohren Edwin
MeetMe: http://doodle.com/vonGohren
+47 411 611 94

Re: Noob Help

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Try to exclude it in your Import-Package in your pom.xml (e.g., 
"!oracle.xml.*").

-> richard

On 10/25/13, 00:15 , Wade Girard wrote:
> I have been experimenting with felix and learning OSGi for the last week. I really like what it has to offer and believe that I can use it for an upcoming project that I am working on.
>
> I have been using maven to build bundles, and creating small test bundles, that has been going well. I have run into a snag though while trying to create a bundle from an existing jar file project. To figure out the dependencies that I need to include in the jar, by adding to the "Private-Package" in the pom.xml for the bundle plugin, I have been building-installing-starting, and then just adding each missing package as it's reported.
>
> I am currently stuck on this one though
>
> org.osgi.framework.BundleException: Unresolved constraint in bundle x.y.x [41]: Unable to resolve 41.0: missing requirement [41.0] osgi.wiring.package; (osgi.wiring.package=oracle.xml.parser)
>
> That package is not being used in my project directly, I do use an xml reader to read rss feeds, that uses the com.sun.syndication.io.XmlReader class.
>
> If I add "oracle.xml.*" to the list of packages, then the build gives the warning message
> [WARNING] Warning building bundle x.y:z:bundle:2.0.0 : Instructions for Private-Package that are never used: oracle\.xml\..*|oracle\.xml
> and when I install-start the bundle I get the same error message
>
> Any help is appreciated
>
> Thanks
> Wade


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


Re: Noob Help

Posted by Roland <ro...@gmx.de>.
Hi,
This means that your project has an unresolved package-dependency to the
package oracle.xml.parser. You have to add a particular artifact to the
dependency-section of your POM that exports the package oracle.xml.parser.
Try to search for this package in the central maven repository or install it
manually to your own maven proxy.

Regards
Roland



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Noob-Help-tp5005743p5005748.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