11:23, EET
March 1, 2023
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!
12:40, EET
April 3, 2012
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).
19:31, EET
March 1, 2023
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.
Most Users Ever Online: 1919
Currently Online:
21 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 734
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1523
Posts: 6449
Newest Members:
christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley, Thomassnism, biancacraft16, edgardo3518Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1