OSGi: including extra system packages in Eclipse Equinox - osgi

In the Apache Felix OSGi framework, configuration files offer an option to include additional system packages in the Felix ecosystem. The line in the Felix config looks like this:
# To append packages to the default set of exported system packages,
# set this value.
org.osgi.framework.system.packages.extra=gnu.java.net.local
I am switching my current OSGi framework from Felix to Eclipse Equinox, and I've found that one of my bundles depends on the gnu.java.net.local package that I previously had access to in Felix, but I can't find anything in the (vague) configuration documentation for Equinox
that seems equivalent to the setting in Felix. Does anyone know the Equinox way of including this extra package?
If you're looking at the link I shared above (to the Equinox configuration documentation), the "System Properties" section is the one that lists configuration file options. I'm not sure if there is a more complete documentation elsewhere.

The property you mentioned is available in every OSGi container. It is listed in the OSGi core specification. See chapter 4.2.2 Launching properties.
You can define it in the config file of equinox or as a system property like:
java -jar equinox.jar -Dorg.osgi.framework.system.packages.extra=gnu.java.net.local

Related

How to convert EAR application into one large OSGI bundle and deploy it in Equinox container?

As part of cost cutting, management want to cease usage of websphere application servers in developer systems.
I was given task to convert the EAR file to one fat OSGI bundle and deploy it in equinox container. if successful, this set up will be shared among developers and will only be used in developer machines and not in higher enviroments.
I have searched many websites but didn't find any concrete solution.
Kindly share your ideas if any to solve the problem.
I strongly encourage you look at Open Liberty: https://openliberty.io
Open Liberty is an open source project launched by IBM last year at Java One. The goal of the project is simple: get awesome Java EE technology into the hands of developers.
Open Liberty supports Java EE 7 and MicroProfile as well as other technologies.
Unless you have a strong technical reason to convert the EAR into an OSGi bundle, you can use Open Liberty in your development environment. The install is easy:
unzip openliberty-18.0.0.1.zip
Give it a try. I think you'll be pleasantly surprised.
If you have questions, Open Liberty has a very active community and twitter or hit me up on twitter #barecode.
An EAR file is simply a JAR file that contains nested JAR files. Those nested JARs form the classpath of the application.
Converting to an OSGi bundle should be as simple as writing a META-INF/MANIFEST.MF for the top-level JAR containing the header Bundle-ClassPath header that lists the contained JARs, e.g.:
Bundle-ClassPath: a.jar, b.jar, c.jar, ...
If the EAR file also directly contains classes that are part of the application classpath, then the new bundle's JAR file should be prepended to the Bundle-ClassPath as an entry named '.' (dot), e.g.:
Bundle-ClassPath: ., a.jar, b.jar, c.jar, ...
Note that the manifest also needs to contain the mandatory OSGi headers, Bundle-Manifest: 2 and Bundle-SymbolicName: .... There is plenty of information available about this online.

Using OrientDB in an OSGi environment

I'm trying to build an application that uses an embedded OrientDB (currently "memory:") graph database.
I'm using OrientDB 2.2
I am using Eclipse bndtools for my development environment.
I have added orientdb-core and orientdb-graphdb osgi bundles as build dependencies to my bundle, but on its own that isn't enough, I need access to the tinkerpop blueprint classes as well. There doesn't seem to be a tinkerpop blueprints osgi bundle that I can see.
I can include the blueprints-core jar as a build dependency, and that gets rid of the compile errors, but I then get into all sorts of issues trying to resolve the bundles so I can run something. (the primary error there that I don't seem to be able to get rid of is a complain about not being able to resolve "com.carrotsearch.hppc" -- I include that in my bundle, and export it, but still no joy there)
Shouldn't orientdb-graphdb either depend on a suitable bundle, or include and export the classes?
It sounds like you're running into the classic problem of wrapping a third-party, non-OSGi library as an OSGi bundle.
The best tutorial for this is on the EnRoute site. Note that you don't need to be using EnRoute for this tutorial to be relevant.

How to package OSGi subsystems with bndtools

I am evaluating bndtools as an alternative to the websphere OSGi tooling in eclipse, to package liberty profile features.
Liberty profile uses OSGi subsystems packed as a .esa for extensions to the runtime. It appears that it is possible to package a subsystem using BND, based on this file in the bnd git repo.
https://github.com/bndtools/bnd/blob/master/biz.aQute.bndlib/src/aQute/bnd/exporter/subsystem/SubsystemExporter.java
But I can't find any documentation about how to setup an ESA project. Can someone give me some pointers?

Packing multiple OSGi bundles in the same jar

I am very new to the OSGi platform.
Having an OSGi bundle B1 that has a dependency to another bundle B2, which is very probably not provided by the container, can I package both bundles in the same jar?
If yes: howto do that? what would happen if the jar is installed and the bundle is already installed?
Yes you can do this... kind of.
Normally OSGi bundles are JAR files because they need to have a META-INF/MANIFEST.MF. The OSGi framework cannot directly read your "multi-bundle" JAR.
However, installing bundles in OSGi involves calling the BundleContext.installBundle method. This method has two flavours, one of them takes an InputStream as a parameter; this InputStream should supply the content of the OSGi bundle. Therefore you can take your big JAR and read it with a JarInputStream, passing the individual entries to the installBundle method.
Although OSGi doesn't directly support multiple bundles in the same jar, there is a standard for multiple bundles in the same archive, which solves the distribution problem you're trying to address. Unfortunately, it may introduce an extra problem in your scenario, because it's part of enterprise OSGi, rather than core OSGi, so it wouldn't be part of a bare bones Equinox or Felix framework. If you have more control over the starting platform your users are using, it may do what you need.
The basic idea is that you package all your bundles into a zip with a .esa extension, along with a simple manifest. You can then distribute the esa file. This tutorial includes lots more detail:
http://coderthoughts.blogspot.co.uk/2013/04/osgi-subsystems.html?m=1

Where is the defining JAR of the portlet taglibs in IBM Websphere Portal 7?

I'm trying to build portlets for websphere in Eclipse Juno. Everything works so far, building and running the WAR files on WPS7 is ok.
But in my JSP editor I get a lot of warnings:
Can not find the tag library descriptor for "/WEB-INF/tld/portal.tld"
In my JSP file I'm using the usual taglib line:
<%#taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
Now I wonder if I have to bring the actual JAR file that defines this tag into my eclipse or if there is something else that I missed.
The reason you are getting this error message has nothing to do with the taglib declaration you had quoted. The latter refers to the standard Portlet tag library (JSR-168), whereas the former has to do with WebSphere Portal's proprietary tags, needed to use WebSphere Portal-specific facilities.
I am guessing that portal.tld is referred-to by your web.xml.
When developing portlets under RAD, IBM's RAD plugins ensure that this TLD file is known to the JSP compiler, by virtue of attaching the WebSphere Portal runtime - in its entirety - to the Dynamic Web Project's classpath.
Under Eclipse Juno, this isn't done for you. You will have to find the JAR file that contains it (which might vary from one WebSphere Portal release to another) and add it to your compile-time classpath.
Having said that, you may want to consider why you need that web.xml declaration in the first place. With Portal 7.0, most of IBM's tag libraries can be referred to by their URI's, rather than having to specifically mention the TLD file.
I'm using a Portal 8 installation but the structure should be similar.
I found a jar containing portal.tld at [Portal Install root]\Portal Server\base\wp.engine.tags\shared\app\wp.engine.tags.jar
Though as a more complete solution you might want to include the whole base folder into your classpath. The server runtime RAD adds to my portlet project include lots of jars from that folder as part of the basic setup. It also includes many jars from [WAS Install root]\App Server\plugins. Since you're just using Eclipse instead of RAD (which would help manage the Portal server jars) you'll probably want to create a user library to manage all these jars.
In RAD/Eclipse, assuming you have the Portal 8 Stubs and Developer Tools installed, you can go to Project->Project Properties -> Java Build Path, to the Libraries tab, Go to Add Library -> Server Runtime , and you should see "Websphere Portal 8" or whichever version you have installed ... once that library is added your URI problems should be resolved.This essentially adds every jar file in the entire portal installation to the build path. If you do not have the stubs and development tools installed, or if you are using another IDE, you will need to add the jar files manually to the build path ....

Resources