Unable to publish bundle in CQ5 - osgi

I have created a simple OSGi bundle using the tutorial given here. The bundle is working fine in the author instance and is also visible in the felix console ( http://localhost:4502/system/console/bundles )
However, even after multiple attempts at publishing the bundle, it is still not available in the publish instance. I have tried publishing is in a package and ddirectly in the tree activation page
I had used the below properties to make it work in the author instance:
Export-Package: *
Import-Package: *
Private-Package: *
Please advice. !!!

Not sure what you mean by "publishing a bundle".
If you have installed your bundle by copying it to the JCR repository of a CQ5 author system (under /apps/yourapp/install for example), which is the recommended way, you should be able to replicate that install folder to your publish instances so that the bundle gets activated there.
That will of course only work if any dependencies that the bundle requires are available on the publish instances.

AFAIK, there is no direct way to publish a bundle from author to publish environment. You will need to upload the JAR file of the bundle in the publish instance felix console (http://localhost:4503/system/console/bundles )
The JAR file will be available in the /apps/<site-name>/install directory.
If you have access, the CQ5 forum had the solution at this link
Hope it works...

Related

Liberty: Custom User Registry with unresolved dependencies

Am a noob in OSGI development. Due to requirements, I had created a osgi bundle project, for a custom user registry feature in Eclipse with WDT and subsequently a feature project to export a .esa file for it.
I'm then able to install the feature into our websphere liberty, however when start it hit the error below:
Unresolved Requirement Require-Bundle: com.ibm.websphere.v85.core
The bundle require the plugin in order to build for the custom user registry. Once I have added the required plugin com.ibm.websphere.v85.core i can build successfully.
I have tried to include the bundle together when i export the feature, but the same error persist.
Any advice on how to solve this dependency issue?
I'm not sure how your eclipse workspace is setup, but that bundle is a WAS traditional bundle that doesn't exist in Liberty. Instead of adding Require-Bundle you should use Import-Package to import any packages you need. I would also suggest checking the plug-in development environment preferences for eclipse to make sure you have it configured with Liberty as the target platform rather than WAS traditional.

What is the recommended usage pattern for karaf-maven-plugin?

I have a bunch of java classes and a bundle activator class that I need to deploy to karaf.
I see that the karat-maven-plugin has kar packaging and karaf-assembly.
Also it generates features.xml
I can generate features.xml directly and it generates lines with wrap: for some of my dependent non-osgi jars.
But when I run karat-assembly, I run into the issue of the assembly goal not realizing that these jars are not osgi and end up with errors.
What it the recommended way to get a custom karaf with my application installed ?
Does the karat-assembly packaging need to have a features.xml generated and provided beforehand ? Or is it supposed to do the feature set generation by itself ? If it is the latter, then how do I get around the problem of the karat-assembly not recognizing non-osgi jars ?
I have spent a LOT of time with google and am stumped.
This is my procedure for creating a custom karaf distribution. It may not be "best practice" but it works for me. Maybe you can customize for your needs.
After developing my Camel routes and testing I generate my feature file based on a feature template found in /src/main/feature/feature.xml. The karaf-maven-plugin will generate the feature will in the feature folder inside /target.
I do a clean deploy to our maven artifactory.
I have a custom Karaf project do a clean install on that project. The project has dependencies to the initial project and I add all the features as boot level feature.
Once build I unzip the distribution and run the Karaf app. If everything looks ok its ready to be shipped.

How to Import Javafx8 in a bundle in OSGI

I'm working on an OSGI application with Felix. Now I want to use some JavaFx8 classes in a bundle but I have the following error :
Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (osgi.wiring.package=javafx.geometry
How can I import JavaFx8 SDK packages in my bundle.
Thanks in advance,
You can add the library to the felix classpath and append the necesary package(s) to the org.osgi.framework.system.packages.extra option.
http://felix.apache.org/site/apache-felix-framework-configuration-properties.html
If you do so, the bundle no. 0 will export the required packages. I can provide more detailed instructions later my pc, right now i am on mobile.
I'm working on an OSGI application with Felix. Now I want to use some
JavaFx8 classes in a bundle
I need to create a complete GUI and I'll need an important number of
imports.
I've released some Early Access versions of Drombler FX, a new Rich Client Platform for JavaFX based on OSGi (Apache Felix) and Maven.
As an application framework it makes sure JavaFX and OSGi will get started properly and it provides the main window.
You can read more about Drombler FX here: http://puces-blog.blogspot.ch/search/label/Drombler
There's a Getting Started page which explains how to create, build and run a Drombler FX sample application with a few simple steps.
After several researches, I finally fixed the problem by adding the packages I need in the pom.xml of the project :
<configuration><provision>
<param>--platform=felix</param>
<param>--noConsole</param>
<param>--systemPackages=javafx.animation,javafx.application,javafx.collections,javafx.embed.swing,javafx.geometry,javafx.scene,javafx.scene.layout,javafx.scene.transform,javax.swing,javax.swing.border,org.osgi.framework</param>
</provision></configuration>
or by adding the following properties to the same file ( pom of the project ):
<properties>
<org.osgi.framework.system.packages.extra>javafx.animation,javafx.application,javafx.collections,javafx.embed.swing,javafx.geometry,javafx.scene,javafx.scene.layout,javafx.scene.transform,javax.swing,javax.swing.border,org.osgi.framework
</org.osgi.framework.system.packages.extra>
<org.osgi.service.http.port>8080</org.osgi.service.http.port>
<org.osgi.service.http.port.secure>8443</org.osgi.service.http.port.secure>
For More information check the link.

CICS Explorer bundle could not be resolved

I am working on a simple Java-DB2 insert program connected to cics region via CICS explorer. I created a plugin for an external jar(com.ibm.db2.jcc), exported the plugin as a deployable plugin and added this in the build path of the program. The package has also been added in the dependencies (import-package) of the program. But installing the bundle in the cics region, I am getting an exception.
The bundle ABC could not be resolved. Reason:Missing constraint:Import-package:com.ibm.db2.jcc;version="0.0.0".
Can someone help me trace the problem?
I'm assuming the program you're writing is in an OSGi bundle that's being deployed into a CICS JVM Server as your OSGi environment, using CICS's OSGi CICS bundle parts. It sounds like you're taking an existing binary dependency and rebundling it as an OSGi bundle, and want to have your program resolve it using OSGi.
Based on these assumptions, it sounds like you're having to add the bundle to your build path automatically, which I don't think you should have to do. Once you've set up your target platform (http://pic.dhe.ibm.com/infocenter/cicsts/v5r1/index.jsp?topic=%2Fcom.ibm.cics.ts.java.doc%2Ftopics%2Fdeveloping_sdk.html) any dependencies should then be resolved either from OSGi bundles in your workspace, or your target platform. It should then just be a case of adding an OSGi bundle part for each of your bundles, and exporting your CICS bundle to your region. Explorer should take care of exporting all of your relevant dependencies to CICS.
If you wanted, it should be possible to add the DB2 jar file as a lib without rebundling as an OSGi bundle, by adding the library to your Bundle-Classpath manifest declaration, but you might already have considered this!

How to activate OSGI bundle?

I am working in Adobe CQ5. I made my project that contains only implementation, and the project title is Web Crawler.
And that project is started by one class that simply adds initial seeds.
I made OSGI bundle of my project and I deploy that also.
Now my question is how can I start my bundle, i.e, how can I add seeds ?
For that I read this link that tells me to make Activator class and put your function in the start method. I done the same. But that does not helps me to run the bundle.
Please help me how can I run the given bundle.
Edit No. 1
Can you tell me how can I make MANIFEST.MF file given in given tutorial ?
Look at the bndtools tutorial which is the easiest way to get you started with OSGi
bndtools is a user friendly tool based on Eclipse. With bndtools, you won't get lost in plugin hell. bndtools will also help you avoid BundleActivators since they were not such a good idea, Declarative Services is what OSGi should have been from day one. It also allows you to test the bundles without having to restart.
to create the manifest, if you are using maven (you should) you can use the maven bundle plugin. It will automatically generate a manifest file for you.
Then, to deploy and start your bundle you can use the maven-sling-plugin, which can deploy your bundles into sling.
If you want to manually activate your bundle, CQ5 provides a web based osgi console. you can activate it there. If it fails, there is probably an error in the start method of the activator class.

Resources