How to see inside an installed Karaf feature - java

How to see what an installed Karaf feature have inside?
Does it have other features in it?
What bundles and with what start-level does it install?
I talking about features like cxf of http.

You can use the command:
feature:info <featurename>
to get details about the feature. It shows dependent features, bundle and config for this feature.
If you want even more details you can check the feature repos:
feature:repo-list
Each install feature repo will be shown with a mvn uri.
For example for cxf 3.2.5 you would see.
cxf-3.2.5 mvn:org.apache.cxf.karaf/apache-cxf/3.2.5/xml/features
Karaf can directly display the content of these urls
cat mvn:org.apache.cxf.karaf/apache-cxf/3.2.5/xml/features
This will display the xml of the cxf feature. You can also find this directly in the maven central repo.
If a feature does strange things during its installation then there is also a way to debug:
feature:install -v http
This will install the karaf http feature and on the way log in detail what is done. Like bundles being deinstalled, installed, refreshed, restart, configs being deployed. This helps a lot when things do not go like expected.

Related

Best way to execute embedded Jetty

I have a web application that is structured into a standard war. I want to use embedded Jetty server as my servlet container. Since this is all one code base, I figured that the main() that executes the Jetty server would also be in my war with the rest of the code.
So how do I go about executing my main(), which is in the war, to launch the Jetty server? I looked at the examples but the examples do not have this setup, which to me seems like a normal setup.
Would the Jetty server need to be told where the war file is (the war file that happens to be where its also located) or would Jetty by default find and check WEB-INF for the various XML files what Jetty processes?
I see something close to this using the Jetty Maven Plugin, but the consensus is that that plugin is not for production.
I was able to setup an executable file easily using the Maven plugin called Jetty Console Maven Plugin There is not much documentation about how to use it on the Internet. The author, simplercity, took down their blog entry for how to use it. But I did find one post on stackoverflow on how to use it.
The current version of this plugin is 1.55. It can be found here. One issue that I encountered is that while most of the artifacts that are required for this plugin are on version 1.55 one of them, jetty-console-ajp-plugin, is on version 1.53. This caused a problem for me because when I had all the other plugins set to 1.55 there was a signer exception error I got when I tried to execute my war. I found the solution in this stackoverflow answer. The fix was to use only 1.53 version of all the plugins. There might be a better solution that allows you to use 1.55 with 1.53 ajp-plugin. Other than that the plugin worked great and I implore the author of Jetty Console Maven Plugin to either bring his blog post on how to use it back up or create new documentation for it.
To execute a standalone application in Java it doesn't need to be a war. A jar is fine enough. A war contains information about how a web archive/application should be deployer into a J2EE container. When you run it standalone this isn't necessary. The main method will be enough. You can have a look at maven shade plugin. It will help you build a runnable jar.
(As a sidenote - a runnable jar is a rather simple thing. The manifest file of the jar file needs to contain the key MainClass and that is it.)

Deploy osgi bundles to Geronimo remotly

We have some custom repository which contains different builds (set of osgi bundles). There are any Geronimo 3 remote servers. I should by a command get some build from repository and make hot deploy to a set of stands. It maybe existing tool or java api. As I know Cargo don't work with remote Geronimo. I will be grateful for any suggestion.
Geronimo 3 is based on apache karaf. So the mechanisms provided by karaf may be of help.
Connect to the ssh console and use commands like bundle:install or feature:install
Use the remote JMX port and the MBeans provided there. Again you have the choice between installing bundles or features
In both cases bundles and features can be refered with http or mvn uri. I personally normally use the mvn uris that karaf also uses internally.
So the process is to first build your bundles/features to a maven repository and then trigger the install command and access the mvn repo you deployed to.
You can add you own maven repo in the etc/org.ops4j.pax.url.cfg.

How to find the version of Jetty used in Restlet framework version 2.1?

Need to know the version of Jetty that an application based on Restlet framework uses. All I know is that the version of Restlet framework used is 2.1 from the pom.xml file in the project.
use the "--version" flag:
java -jar start.jar --version
If you add -X to the build command line it should show the way maven resolves dependencies, giving you a full dependency chain including what version of jetty would be getting pulled in.
Some of the tooling for various IDE's will give you this information as well, if you open the pom.xml in Eclipse with the m2eclipse tooling you should see a pretty graph with this info.

Installing a feature in servicemix

I am running Apache servicemix 4.5.2. I want to install a feature, i.e. a jar file.
The feature I wanted is jtidy.
The pom dependence is:
<dependency>
<groupId>jtidy</groupId>
<artifactId>jtidy</artifactId>
<version>4aug2000r7-dev</version>
</dependency>
and the repository is
http://repo1.maven.org/maven2/jtidy/jtidy/4aug2000r7-dev/jtidy-4aug2000r7-dev.jar
I know the command features:install webconsole, for example but jtidy is not in my features:list. I've also tried using the addurl command but it didn't work.
(addurl mvn:http://repo1.maven.org/maven2/jtidy/jtidy/4aug2000r7-dev)
The Karaf documentation recommends to add a feature descriptor using the Features XML schema but unfortunately the link is broken.
Up to know what i did is to download the jtidy.jar and copied it to my deploy directory. It works, but I don't think that this is the correct way.
Do anybody knows how to install jtidy in servicemix correctly?
Thanks!
There's difference between installing a feature and installing a single JAR or OSGi bundle.
A feature is defined in an XML file. A feature consists of a number of bundles, configs, ... that are installed together. Have a look at http://karaf.apache.org/manual/latest-2.3.x/users-guide/provisioning.html to learn more about features in Karaf.
In this case, you want to install a single JAR into the container. You can use the command osgi:install to do this, followed by a URL pointing to the JAR (e.g. mvn:jtidy/jtidy/4aug2000r7-dev).
However, in your case, there's one more complexity. jtidy is not an OSGi bundle by itself. The easiest way to add the necessary OSGi metadata, would be to use the wrap: protocol to automatically add the OSGi metadata to the JAR.
So, to wrap things up - to install this jtidy dependency in Apache ServiceMix, you can use
osgi:install wrap:mvn:jtidy/jtidy/4aug2000r7-dev

Run Apache Felix 4.0.2 in IntelliJ IDEA 11

According to this post, IDEA uses Osmorc to run OSGi frameworks. It, in turn, uses Pax Runner to launch different framework implementations.
The toolchain in IDEA 11 can only run Apache Felix up to 3.0.2, but I have to run version 4.0.2. Is it possible? Do other OSGi framework launchers exist for IDEA?
You can configure the OSGI frameworks that Osmorc uses from the plugin+ project settings.
I use IntelliJ IDEA 11.1.2 and Osmorc 1.4.2.
Here is a screenshot where I configure the OSGI container (at IDE Settings-->OSGi) to some local
installation of Apache Felix 4.0.1.
You can also define your custom framework/container and then select the desired
OSGI framework to use at Project Settings-->OSGI as seen below:
In order to create Run configurations, you first need to create some OSGi facets.
Hopefully, you are also using maven and the maven-bundle-plugin which will greatly
reduce the amount of configuration you need to do(since OSmorc automatically syncs with your pom.xml), but even if you do not, you can manually edit the information for creating the bundles.
So, what you need to do next is create some OSGi facets. Go to Project "Structure-->Facets"
and add a new OSGi facet for each bundle you wish to create. It you have automatic detection turned on, then the facets maybe already there. If not, then add them manually and then configure them as you see appropriate, like in the following example.
Finally edit your "Run Configurations" and add a new OSGi run configuration.
Select the framework you wish to use and the bundles you wish to start as well as
other parameters, like in the following example:

Categories

Resources