On 07/09/2022 11:10, Siano, Stephan wrote:
Hi,

Hello,

I thing there is a difference in the OSGi specs about importing java.* packages.
The OSGI core spec 6.0 says in section 3.4:
Bundles do not import the java.* packages and can therefore not specify their 
dependencies on
these variations in the environment using the Import-Package header. The OSGi 
Execution Environment defines how frameworks can inform bundles about the 
available execution environments. The
primary purpose of an execution environment is to define the variations in the 
java.* namespace,
an execution environment can also include packages in other namespaces.

The OSGi core spec 7.0 says in section 3.4:
For Java platform versions prior to Java SE 9, the Framework must also set the 
org.osgi.framework.system.packages launching property to the list of Java 
platform packages generally known to be available at runtime. Since there is no 
standard way to interrogate the Java platform for the packages currently 
available at runtime, a Framework implementation may use a predefined list of 
packages for the Java platform version.

In additional to specifying the version of the execution environment via an 
osgi.ee requirement, see osgi.ee Namespace, a Bundle may also import java.* 
packages using the Import-Package header. Imports of java.* packages by a 
bundle will be used during the resolution process, see Resolving Process, to 
ensure the bundle has visibility to the requested packages by wiring the 
bundle's import of a java.* package to the export of the java.* package by the 
Framework's system bundle. However, a bundle always loads classes in java.* 
packages via parent delegation. See Parent Delegation. Therefore, a bundle is 
not required to import a java.* package to have visibility to the classes in 
the package, if the package is present in the current runtime. It only needs to 
import a java.* package to have the resolution process ensure the package is 
available from the execution environment. This can avoid a NoClassDefFoundError 
during execution of the bundle due to a missing java.* package required by the 
bundle.

Is it possible that importing a java.* package is only valid for OSGi 7.0 
upwards. Doesn't karaf 4.2 only implement the OSGi 6.0 spec? AFAIK 7.0 is 
implemented in Karaf 4.3 and 8.0 is implemented in 4.4.

Not only that, but bnd's default behaviour depends on Java/OSGi requirements discovered at compile-time: https://github.com/bndtools/bnd/issues/2507

Regards,
Robert


Best regards
Stephan

-----Original Message-----
From: Jean-Baptiste Onofré <j...@nanthrax.net>
Sent: Wednesday, 7 September 2022 10:44
To: dev <dev@karaf.apache.org>
Subject: Re: osgi.wiring.package; filter:="(osgi.wiring.package=java.io)" for 
JDK upgrade from 8 to 11

I would check what's in etc/jre.properties for java.io. It could also depends 
to the maven-bundle-plugin version you are using to build your bundle (and OSGi 
R).

If you have a simple test case in order for me to reproduce it, I can take a 
look.

Regards
JB

On Wed, Sep 7, 2022 at 10:28 AM Munish Gupta 
<munis...@motivitylabs.com.invalid> wrote:

Thanks for the reply JB.

I am getting it while our product using KARAF runtime (4.2.15) is starting with 
Open JDK 11. It was coming when KARAF is trying to deploy our application 
specific bundle.
Later I downloaded KARAF binary distribution from website and tried to do KAR 
install for examples shared there. It happened again there as well.

Is there anything specific need to be mentioned as export OR import for these 
java specific (Java.IO package) while using it with OpenJDK 11. I also might be 
doing something wrong but some sort of clue can help here.

Regards
Munish

-----Original Message-----
From: Jean-Baptiste Onofré <j...@nanthrax.net>
Sent: Wednesday, September 7, 2022 1:34 PM
To: dev <dev@karaf.apache.org>
Subject: Re: osgi.wiring.package;
filter:="(osgi.wiring.package=java.io)" for JDK upgrade from 8 to 11

Hi,

Can you explain where you got this error ? Just starting the runtime ?

Regards
JB

On Tue, Sep 6, 2022 at 3:47 PM Munish Gupta <munis...@motivitylabs.com.invalid> 
wrote:

Hi Team,



I’m using Karaf 4.2.15 in my project and when I’m trying to run the
Karaf.bat command in the bin file I’m getting the below error log.



osgi.wiring.package; filter:="(osgi.wiring.package=java.io)"



I have upgraded my JDK from 8 to 11 and then on I’m getting this issue.



I have tried with plain karaf(4.2.15) and tried to install (
feature:install ) some examples which are provided in the karaf
directory. Done the Maven build as per the directions given in the
Read.Md document. Tried to install the feature:install
karaf-servlet-example-registration . There also I am getting the
same error.



Please find the attached image for more information.



I have tried with both JDK 1.8 and OpenJDK 11, both are yielding the
same output.



Can you help me find the issue here?



Best Regards,

*Munish Gupta*

Technical Delivery Manager

Mob: +91 9533735490

[image: Logo Description automatically generated]

*[image: Logo Description automatically generated]*

*[image: Logo Description automatically generated]*

*[image: Text, logo Description automatically generated]*

*US:* 222 W Las Colinas Blvd, Suite 1410N, Irving, Texas 75039.
Ph. | +1 214.730.0798

*INDIA:* 6th floor, Dallas Center,
Knowledge City, 83/1, Plot No A1,
Raidurg, Hyderabad 500 032

Confidentiality Note : This message is confidential. It may also be
privileged or otherwise protected by work product immunity or other
legal rules. This email and any files transmitted with it are
confidential and intended solely for the use of the individual or
entity to whom they are addressed. If you have received it by
mistake, please let us know by e-mail reply and delete it from your
system; you may not copy this message or disclose its contents to anyone.





Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to