Automatic features provision on Fuse ESB/Servicemix with Maven - maven

Is there any way to provision/deploy features to Fuse ESB/Servicemix automaticaly though Maven, like cargo for Tomcat? Using ant+ssh is not an option.

I'm currently finalizing a client wrapped in a maven plugin that will do just that, but instead of the fusesource approach of using the hot deployment folder I connect directly to the remote karaf console and execute the commands required to (un)install features.
The auto deploy is part of automated regression tests executed by Jenkins through a set of SoapUI test scripts.
Basically I use apache SSHD to connect to karaf (see an example here: https://cwiki.apache.org/KARAF/63-programmatically-connect-to-the-console.html) and some custom code to execute the commands and parse the result.

Related

Is it possible to install the karaf server using maven?

I would like to use maven to deploy a complete karaf server including my own features. But so far I am unable to find a way to add the karaf server itself as a dependency. This would save a lot of manual steps, esp. for the other developers which would not have to setup karaf manually.
This would have the added benefit that I do not have to check in the karaf server into the repository in order to have all required parts available from the repository.
Question: is there a way to configure a project using karaf which will setup the karaf server and all required dependencies without manually downloading the files from the karaf website?
This can be done using the karaf-maven-plugin. There is even an example which does this shipped with karaf: examples/karaf-maven-example.
Here is what the examples do
karaf-maven-example-run uses the karaf-maven-plugin:run goal to download and start a Karaf instance.
karaf-maven-example-run-bundle uses the karaf-maven-plugin:run goal to download, start a Karaf instance and deploy the project bundle in this running instance.
karaf-maven-example-deploy uses the karaf-maven-plugin:deploy goal to deploy the module artifact into a Karaf instance (remote for example).
karaf-maven-example-client uses the karaf-maven-plugin:client goal to execute a shell command on a running Karaf instance.
karaf-maven-example-kar packages a features repository as a kar file, ready to be deployed.
karaf-maven-example-assembly uses the karaf-maven-plugin to create a Karaf distribution.
see here for more details.

Scoping out maven plugin execution depending on environments

I am using the ready-api-maven plugin for executing simple SOAP requests on my codebase which is deployed to a local JBoss server before the execution of the tests.
I am trying to figure out how to "scope out" the steps to deploy to a local JBoss server and run these tests when the build is executing on Jenkins. These tests are meant only for executing on a local system.
I'm quite new to maven and would really appreciate the help. Thank you
You can define it by using profiles. ex. you can specify two profiles: local and ci, in local profile you can specify to run the tests but in ci you can skip them.

Running springboot using maven vs. via java directly?

Essentially, the Jenkins CI job runs mvn spring-boot:run .... in a productions cluster as the only way to run the application. With this build step, in effect, we are running the springboot app only via maven and this has led to a very unstable jvm behavior. Also, I am unable to configure all the possible tweaks to the jvm e.g, turning on gc logging or changing to G1GC etc.. etc..
I just wanted to know if running my java springboot app should indeed be packaged into a fat jar and run with standard jvm flags, rather than from maven.
Please let me know your thoughts
Spring boot maven plugin has jvmArguments in order to set jvm settings.
......
<configuration>
<jvmArguments>-Xdebug</jvmArguments>
</configuration>
.......
The second option is to create a self-executable jar/war and use a standard way to run app - java -jar app.jar <jvm properties>
Our teams have been running fat jars similar to how others have stated with the simple java -jar ****.jar commands. However, once in production, you can utilize a container clustering system to construct the many microservices that make up your app. Seems like running maven and deploying source code, rather than artifacts seems dangerous. Hopefully this helps!

What is the purpose of tomcat-maven-plugin?

I'm having some difficulty understanding the purpose of this plugin. Is it to modify the settings in Tomcat during the build?
I am deploying to tomcat using maven, without the plugin and it seems to work fine. Not sure if I am missing something
Cheers
Maven Tomcat plugin basically just bootstraps an embedded Tomcat container for you. Saves you the trouble of configuring an external Tomcat instance for development purposes. It can also auto-start this Tomcat instance during the build and run integration tests on it, stopping it afterwards.
If you already have a functioning workflow that you're comfortable with, no need to introduce the plugin, but it's pretty easy to configure, can run multiple web apps, can run unassembled applications etc so it's convenient to have for local development.
An even more light-weight alternative would be the Jetty plugin which starts an embedded Jetty server instead.
Maven is actually a plugin execution framework where every task is actually done by plugins.
Maven Plugins are generally used to :
create jar file
create war file
compile code files
unit testing of code
create project documentation
create project reports
A plugin generally provides a set of goals and which can be executed using following syntax:
mvn [plugin-name]:[goal-name]
For example, a Java project can be compiled with the maven-compiler-plugin's compile-goal by running following command
mvn compiler:compile
for more information go to http://www.tutorialspoint.com/maven/maven_plugins.htm
so pulgins is used to execute goals.
suppose if you don't include plugin that is required in your execution environment then it will throw an error like
A required class is missing: Lorg/apache/maven/plugin/BuildPluginManager;
so by adding appropriate plugin in pom.xml it will resolve the dependencies and execute the goal succesfully.
to remove above error just add the following plugins :
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-amps-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
</plugin>
Maven is a framework used to build JAVA applications, it provides the following
Directory Structure
Configuration Files
Build Settings
It helps in easy and structured development, primarily used for REST API Calls.
Applications built on Maven Framework, would require the same to be deployed
Its better that you get the plugin installed, since on a long run you never know what dependency may go missing
-If this helps, Mark as Answer

How to work with frequent local snapshot bundle deployments on Karaf?

I decided to build an application on top of OSGI and Karaf - I really like this stuff. However, I'm struggling a bit with a daily deployment on my local, development machine. I mean.. I make a change and then I would like to test it on my local Karaf instance. And it can happen like couple times per hour.
The way I'm doing it now is a maven build that creates a JAR bundle and then it's copied into the Karaf's deploy directory. I think that it isn't elegant at all.
I was trying to find a way around (google). I read about Karaf's features but it seems that despite the fact that it is a nice mechanism for deploying whole app, it doesn't solve my problem. As I understand it right, it does not check whether new version of my SNAPSHOT jar appeared in my local maven repo, right?
The key to make the update mechanism of karaf work is to deploy from maven instead of using the deploy folder.
Install you bundle like this:
install -s mvn:groupid/artifactID/version
or
install -s mvn:groupid/artifactID/version/typeOfMavenArtifact
Second one is useful for installing for example war/wab artifacts. Full maven protocol specification can be found here.
Then Karaf knows where the bundle came from. You can also check this using la -u. This makes karaf show the update location which now should be a maven uri. You will not that all karaf bundles have an update location like this.
When you now create a new build of your project using maven it will end up in you local maven repository.
Then simply run
update <bundleid>
This makes karaf check the update location (in your case you local maven repo) and reload the bundle from there.
You can even further automate this by using
dev:watch
or for karaf 3+
bundle:watch
This will make karaf check you maven repo for changes in SNAPSHOT bundles it has deployed and automatically redeploy these.
This also works very well together with the remote debugging. Use
export KARAF_DEBUG=true
before starting karaf. It then will listen for a debugger on port 5005.
You can then start a remote debug eclipse session on the same port and nicely debug your application in karaf. This works very well even if you change your bundle using one of the approaches above. So you can debug, find your problem, change the code, build and continue debugging with the changed version.
I also use this frequently when I work at the karaf code base itself as this also works for most of karaf's own bundles.

Resources