Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Maven Package for OSGi
March 1, 2023
11:23, EET
Avatar
marekd
New Member
Members
Forum Posts: 2
Member Since:
March 1, 2023
sp_UserOfflineSmall Offline

Hi,

I need to evaluate the integration into an OSGi-package for a custom eclipse-installation.
Therefore the described way of copying the jar into the CLASSPATH and to reference it does not work.
The OSGi-package needs to reference all needed packages via pom (maven), respectively MANIFEST.MF.

Or, different question, same topic:
I executed the ‘maven-install-helper’, some files where created in my local .m2-repository.
But I am not able to include this local repository into the targetdefinition:

m2-repo
p2
file://${user.home}/.m2/repository

always results in a “no repository found at file” (the path is correct). So the reference to com.prosys* in my MANIFEST.MF is of course invalid.

Can someone help me or at least give me a hint what to try?

Thank you very much!

March 1, 2023
12:40, EET
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

It has been a very long time since I last checked anything related to OSGi. We do not use that ourselves. The SDK jar is not a so called “OSGi bundle” (i.e. manifest within the jar doesn’t contain anything OSGi related, per internet https://www.ibm.com/docs/en/was-zos/9.0.5?topic=files-example-osgi-bundle-manifest-file it would have some special values). So if you use a tool that would assume such (or search is as such e.g. from the local maven cache), then it will fail.

So basically in this kind of situation, you will need to just use the SDK as a (any other) lib and make the “OSGi bundle” yourself and have the SDK as a dependency to that. However, be very careful that you do not repackage the BouncyCastle dependency of the SDK if you would do any “uber jars” (because it is a JCA provider and thus signed thus it will break signature if modified), or if you get a random error this is the first thing to look. But I sort of have a vague memory of there being some ways to have OSGi bundles have external 3rd party dependencies.

Note that things are not Serializable etc. basically all interactions with the SDK must happen within the same OSGi bundle (or like, you most likely can have multiple completely separate interactions, but you most likely are unable to transfer any SDK-specific classes between OSGi bundle boundaries directly, because as far as I’m understood each bundle has their own separate classloader, also note that there are somewhat a lot of classes needed to be loaded for the SDK to work).

Also, you want to call disconnect all UaClients, shut down all UaServers and then call StackUtils.shutdown() when you would unload the bundle to close resources, some of these are static in the StackUtils and would normally only shut down when the JVM shuts down (which might “never” happen in OSGi in the context of a module)

What the maven-install-helper maven project of the SDK distribution just does is to make the SDK available on the local machine (in the maven cache), by doing maven install on it. It is then on the machine similarly to anything you would have pulled from maven central i.e. the same as basically any other 3rd party dependency. That is to say, there is nothing OSGi-specific here.

Some old links from the past that may or may not be useful:
https://stackoverflow.com/questions/16933929/what-is-the-intended-use-case-for-bundle-classpath-in-osgi-bundles
https://stackoverflow.com/questions/1340483/osgi-handling-3rd-party-jars-required-by-a-bundle
https://github.com/everit-org/osgi-bouncycastle-adapter
https://vzurczak.wordpress.com/2017/09/04/bouncycastle-osgi-and-uber-jars/

So basically you will want to search things like “OSGi 3rd party external dependency”, and treat the SDK (and the dependencies of the SDK) as such for OSGi purposes.

Let us know if this helped, or if there is something more modern tutorial on the matter (i.e. including general 3rd party dependencies in OSGi bundles).

March 1, 2023
19:31, EET
Avatar
marekd
New Member
Members
Forum Posts: 2
Member Since:
March 1, 2023
sp_UserOfflineSmall Offline

Thank you very much!
This was the hint I needed.
I added
Bundle-ClassPath: .,resources/lib/prosys-opc-ua-sdk-evaluation-4.10.0-58.jar
to MANIFEST.MF and added the file into build.properties (section bin.includes) to include the jar into my OSGi-package.
I added slf4j, bouncycastle as dependencies in my pom so I could add the Import-Packages to the Manifest.
I copied the code from the ‘SimpleClient’-sample.
Right now I get an exception during client.connect() regarding bouncycastle which I have to investigate now.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
26 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 681

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com

Moderators: Jouni Aro: 1010, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1