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!
Related
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.
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.
I've created several Java applications for CICS and used CICS Explorer and deployed them to CICS TS 4.2. Everything I've read says to deploy in this manner, but what if I want to create an application to deploy to a 3rd party environment? According to everything from IBM I need to use CICS Explorer. I've actually been able to avoid CICS explorer with a nasty hack that involves creating the bundle on Z/OS, downloading the bundle, editing the cics.xml file and redeploying elsewhere. Works but the whole process leaves something to be desired.
Is there a documented alternative to using CICS Explorer to deploy CICS Java apps? I did read something about the ability to deploy osgi bundles that are not cics bundles but I've not been able to find any more information on this.
Thanks for you question. Before I can answer I have a couple of my own if you don't mind. Firstly when you say you want to deploy an application to “a 3rd party environment” what do you mean; is this a different CICS system or something else? Secondly what issues do you have with using CICS Explorer to create and deploy the application?
You can maybe use the CICS build toolkit, this allows you to create/build a deployable CICS bundle project structure from an Eclipse project. It also allows you to modify specific variables in CICS bundle resource attributes using values in a properties file, this includes the JVM server name.
Time passes and, from 2019, there's another solution to this question.
If you build your Java using Maven or Gradle, you can use the CICS bundle Maven plugin or CICS bundle Gradle plugin. They take your Java module and wrap it up into a CICS bundle ready for you to deploy to either CICS or an artifact repository.
The plugins work for any release of CICS TS, but if you also have CICS TS 5.6 and above then you can use the CICS bundle deployment API directly from those plugins to also deploy to CICS as part of your development build.
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
I had this crazy idea since a long time so decided to finally ask. Is there some project for integrating bundles directly into the the build process without explicitly doing extra work of including an osgi container and adding bundles etc. So the basic idea being in you build.sbt or pom.xml you just specify your dependency like you normally do and instead of fetching the jars, sbt or mvn fetches bundles (if available) for your dependency. And on building the project a container of your choice would be downloaded and bundles (and jars) would be added to it automatically ? Just like a fairy tale.
EDIT: By the last part i meant something along the lines of felix gogo which will create a script for adding bundles to run container with them. Althogh thats too much to ask for but after the build i can just run a script and my whole project will run on an osgi container free from jar hell.
This already works today. You simply use the maven bundle plugin to create a bundle of your code during the build process. Many of the jars in maven central already are bundles. So you just specify them as normal dependencies.
I am not sure what you want to achieve in the last part. Downlaoding the container and adding the bundles. The build process just creates the jar. Why should it load a container?
If you want to do this for testing purposes then pax exam is what you search. It does exactly what your describe for your unit tests. It downloads a container, adds your bundles and deploys and runs your test in the container.