Drools OSGi integration - Apache Felix - java

i'm trying to integrate drools engine inside an Apache Felix container.
I can't find ANY official resource regarding the installation process. The official documentation of drools 6.4.0.Final only state that drools is OSGi ready
Can someone give me useful informations ?
What I did so far:
I've tried integrating the OSGi bundle that is contained in the Drools zip distribution that can be downloaded from the official site. I couldn't find documentations out there neither technical release notes in the .zip file, so I started adding to my target platform (based on Apache felix) the kie-ci-osgi-6.4.0.Final.jar contained in the osgi-binaries folder.
I saw that there were lots of unresolved dependencies, so i tryed to manually add every jar, before giving up because I couldn't find nor understand what's was happening.
After that I tryed the same flow with this jar. I also dowloaded with maven cli every dependencies without success

Related

gt-tools on Jboss 7.1.1

I am working on a legacy project that runs on JBoss 7.1.1 and I am using the geotools library (14.5 version).
When the the project is deployed I get a lot of warnings like this
WARN [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015893: Encountered invalid class name 'org.geotools.referencing.operation.transform.WarpTransform2D$Provider' for service type 'org.geotools.referencing.operation.MathTransformProvider'
and when I am trying to execute code related to geotools I get back
Problem asking Directory of spatial files (shapefiles) if it can process request:java.lang.NoSuchMethodError: org.geotools.data.DataUtilities.canProcess(Ljava/util/Map;[Lorg/geotools/data/DataAccessFactory$Param;)Z: java.lang.NoSuchMethodError: org.geotools.data.DataUtilities.canProcess(Ljava/util/Map;[Lorg/geotools/data/DataAccessFactory$Param;)Z
I suspect that is a problem with some library dependency but I do not know how to proceed to fix it.
The project uses ant as a build tool. It builds an EAR package that when expanded contains a lib folder with all the relevant libraries, including the ones reported as problematic above. I see nothing worth mentioning in the included MANIFEST.MF of the EAR, JAR, and WAR subpackages.
Any ideas how I can debug and solve this problem?
Thanks!
This could be a number of things (and with out seeing the project dependencies it's hard to be sure which).
You may be missing a referencing jar - see the FAQ for more details
You may have failed to handle the META-INF/services files correctly when adding jars to your WAR file and JAR files - see this FAQ for details of this.
You might need so additional files to make JBOSS work see this page to see how GeoServer (which is built using GeoTools) does it.
And, you may want to consider upgrading to a currently supported version like 23.x or 24.x.

is bndtools a future bundle tools for OSGI bundle?

I saw there are some community osgi.enroute, equinox and etc are encouraging bndtools for osgi bundle. However, there are a lot of a special key that I have never seen and can't find in their official website. For e.g.
Require-Capability:\
osgi.service;filter:="blahblahblah";effective:=active
Provide-Capability: osgi.service;objectClass=net....
And there are sometimes doing like
META-Persistence:
Webcontext-path:
Ok, where is this documentation from? Who the hell know if putting like this it will auto look up? Which mean I put JDBC-Driver then it will lookup?
Are they any bndtool cheat sheet or docs that can refer all this stuff.
As I know maven felix plugin had helped us to bundle nicely private export and import. What for I want to migrate to bndtools?
And I see apache karaf(popular OSGI runtime) is still using felix maven plugin which is more clear and understandable.
Is this a reason why OSGI until now still less popular than other JAVA framework? Can I still stick to the maven Felix plugin bundle rather than using these complicated tools?
The newest enroute examples use a maven build. So they are not very different from apache karaf builds. For creating bundles with maven you have two choices. The maven-bundle-plugin (from felix) and the bnd-maven-plugin from the bnd community.
Both use bnd under the hood, so they only have small differences. bnd-maven-plugin uses bnd.bnd by default for configuration. maven-bundle-plugin can also use this configuration style. I see the trend that many project use bnd-maven-plugin as it is more up to date with bnd versions but you can use both.
The real differences are with building the deployment artifact. In bndtools you build a jar out of a bndrun file while in karaf you usually create a feature file. This is where you really have to decide which way you go. If you use a self contained jar for your application then bndtools is a great choice. If you plan to deploy into karaf then karaf features are the best choice.
Btw. In both cases bndtools plugin for eclipse provides some nice support. Especially looking into the Manifest of jars and editing support for bnd.bnd files is nicely supported.
Regarding configurations needed in the bnd.bnd file. These configurations are needed in the same way if you use the felix maven-bundle-plugin.
The good news is that if you use the newest specs / examples then you rarely have to touch the bnd.bnd or the plugin config in maven. There are annotations for almost every needed configuration. There is good documentation inside the OSGi specs themself but the easiest approach is starting with examples.

Feedback on Maven multi-module project setup with OSGi

I am getting in touch with OSGi and trying to setup a project using Apache Felix and Maven. I'd like to use a Multi-Module build and declarative services. The project is hosted on GitHub: osgi-maven-example (Note that the link points to a specific commit and not to the HEAD of the repository.)
I have got a few questions about the overall setup of the project:
According to Neil Bartlett the bnd-maven-plugin should preferably used over the Apache Felix Bnd Plugin because it respects Maven's lifecycle. Judging by the age of the bnd-maven-plugin, this seems to be a relatively new approach and I am therefore not sure if it is a good idea to do so.
I am using the declarative services package (org.apache.felix.scr.annotations) from Apache Felix to define my components. These annotations are used by the maven-scr-plugin to generate service descriptors which are included in the MANIFEST.MF by the use of the following line in the bnd.bnd file: Service-Component: OSGI-INF/*.xml. Is this the way declarative services are intended to be used?
IntelliJ displays a warning in the GermanGreeter-class:
What exactly does this mean? Do I need to care about this? How can I fix it?
Although I am pretty happy over this working example, I am curious if I am using all these technologies in their intended way and I would be very grateful if I could get some feedback on the overall setup before I am starting to use it in a bigger project.
There is now an official set of annotations for DS, under the package org.osgi.service.component.annotations. These annotations are packaged in the jar "compendium" (org.osgi/cmpn), and bnd has a directive to generate components descriptors : -dsannotations : *
the first part of your question is subject to opinions... maven-bundle-plugin is more "maven centric" : it's more easy to integrate it in a maven build. bnd-maven-plugin is more "bnd centric" : you manipulate standard bnd files, but it broke some maven convention. both have advantage and inconvenient
I agree with Jeremie that you should use the standardized annotations. They can be used with both the felix maven-bundle-plugin as well as the bnd-maven-plugin. For an example of the first see Apache Karaf Tutorial part 10 - Declarative services. For the second this post from Neil is a good source of informations. You should not need the scr plugin.
The maven-bundle-plugin is quite stable and easy to use. The problem with it is that it redefines the maven lifecycle which can cause problems with some project setups. The bnd-maven-plugin needs a bit more maven xml in the parent but then has the advantage that it fits better into complex builds as it does not tweak maven.

Using (Scala) library from Java Web App, getting NoClassDefFoundError

I've been working on a rather "standard" Java web application for a long time now. I develop in Eclipse using Eclipse's server plugin to run the app in Tomcat. The app's setup is straight forward: Spring for bootstrapping, Wicket for web, Hibernate for ORM, Maven for dependency management.
Today I have added Akka 2.0 to the project. I added it to my POM as per the manual:
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor</artifactId>
<version>2.0.2</version>
</dependency>
Maven finds the dependency and I can see it showing up in the Maven dependencies in Eclipse's package explorer. The referenced Scala Library also shows up (version 2.9.2 as it seems).
I can use the library just as one would expect: Eclipse finds the classes, I can jump to source files etc. Everything works perfectly. But once I start the app and it comes across any part of the program with references to Akka it throws a NoClassDefFoundError.
Since all other libraries still work as expected, my best guess is that is has something to do with the fact that Akka is a library developed in Scala. Since I've hardly used Scala myself though, I could not find any solution to the issue myself and Google isn't really that helpful when it comes to such generic exceptions.
Do you have any advice?
Verify that the required library (AKKA) is in your deployment assembly under Eclipse: open the project's properties and look for "Deployment Assembly" on the left.
[I'm using Eclipse Indigo]
You could verify the presence (or lack) of the expected jar file by examining the deployment under tomcat.

Where to check out SLF4J Simple?

I'm trying to check out slf4j-simple-1.6.2 from a trusted repository (preferably, SLF4J's official repo) and pull it down into an Eclipse project. I'm doing this because I need to tweak SLF4J Simple's code so that it binds to my own logging implementation.
I'm hoping there is a way to do this without having to use Maven, because I've never used Maven before and feel much more comfortable running Ant builds.
Nevertheless, I've searched SLF4J's site high and low and cannot find any trusted links to their repository.
Even once I get the project imported into Eclipse, I still need to figure out how to get it building with Ant.
Could someone please help me:
Find the repo
Confirm whether an Ant build is possible
Thanks in advance!
The zip download here also contains the sources.
The official source code repository is hosted on GitHub. However, I believe you are doing it the wrong way.
The idea of SLF4J is to have a dependency on slf4j-api and let the developer to add exactly one binding. Instead of tweaking original bindings just write your own one. Of course you can use simple binding a starting point, but modifying existing open source libraries and maintaining patched versions is a lot of work.
As you said, slf4j is present in the official Maven repository.
So basically, you have 2 simple solutions without using Maven:
Download the JAR / sources / javadocs from this Maven repository, and copy them in your own project directory.
Use Ivy. This is an extension of Ant to give a better dependencies management. It can connect to Maven repositories. So you will be able to retrieve your slf4j dependency without having to use Maven.

Categories