How to install Spring Roo add-ons while offline - installation

At work, our dev environment is an internal network with no connectivity to the internet.
I'm currently trying to use Spring Roo's database reverse engineer function but can't seem to get the add-on org.springframework.roo.wrapping.mysql-connector-java to install correctly offline. I have tried the following:
Following this link jtds driver addon problem
I used the roobot.xml to find the url for the wrapping.mysql-connector-java and downloaded the jar.
According to Roo docs Roo Docs Packaging & Distribution I used the following command to load the osgi jar.
roo> osgi start --url file:///<path-to-addon-project/target/<addon-bundle-name>.<version>.jar
But that resulted in the following errors:
org.osgi.framework.BundleException: Unresolved constraint in bundle org.springframework.roo.wrapping.mysql-connector-java[75]: Unable to resolve 75.0: missing requirement [75.0] package; (package=org.slf4j)
We have an internal repo with the slf4j jars but I can't figure out how to configure Roo to point to it.
I copied the ROO_HOME of an installation I did on a home computer with the requested mysql add-on but when I tried running it in my work environment I get multiple:
Auto-deploy install: org.osgi.framework.BundleException: Bundle symbolic name and version are not unique:...
Any help would be appreciated, thanks

I would recommend creating a maven repository manager on your dev network and seeding it with all of your dependencies. I was unable to use Spring/Roo offline without it as I kept running into the type of trouble that you are. I used Sonatype Nexus OSS. It was a pain to seed the repository, but it made Roo usable offline. Hope that helps.

Related

Error while executing Simple Spring Boot Application in Spring Tool Suite

I have recently installed Spring Tool Suite 4.0.1 on Ubuntu 18.04 and tried to run hello world spring application but it gives the following compile-time error. I have searched on google a lot but cannot find the relevant info.
Error:
"Description Resource Path Location Type
Archive for required library: '/home/anshul/.m2/repository/org/springframework/spring-test/5.1.2.RELEASE/spring-test-5.1.2.RELEASE.jar' in project 'demo' cannot be read or is not a valid ZIP file"
It looks like the JAR file in your local Maven repository is corrupted. The easiest way to solve this is to completely wipe out the local Maven repo (delete everything under .m2/repository and kick off an Update Maven Project... in STS. That will trigger Maven to download the dependencies again.

What is the point of a features.xml if I have to install the bundles in it manually?

I have a features.xml with a few bundles listed. But they all need to be installed apparently. So all that the features.xml does is gather the dependencies in one spot....
Unless I am horribly mistaken. In which case how does one resolve a situation where I have a lot of dependencies in features.xml and they are all not in any order. Right now I am going through the exercise of installing each bundle and starting them up one by one...
Tell me what I am doing wrong- of which there may be several things
Edit:
Features were generated by maven plugin.
When I install feature, I get unresolved error
Error executing command: Unable to resolve root: missing requirement [root] osgi.identity; osgi.identity=myBundleApp; type=karaf.feature; version="[1.0.0.RC1,1.0.0.RC1]"; filter:="(&(osgi.identity=myBundleApp)(type=karaf.feature)(version>=1.0.0.RC1)(version<=1.0.0.RC1))" [caused by: Unable to resolve myBundleApp/1.0.0.RC1: missing requirement [myBundleApp/1.0.0.RC1] osgi.identity; osgi.identity=org.eclipse.jetty.websocket.server; type=osgi.bundle; version="[9.3.6.v20151106,9.3.6.v20151106]"; resolution:=mandatory [caused by: Unable to resolve org.eclipse.jetty.websocket.server/9.3.6.v20151106: missing requirement [org.eclipse.jetty.websocket.server/9.3.6.v20151106] osgi.extender; filter:="(osgi.extender=osgi.serviceloader.registrar)"]]
But the feature.xml already has <bundle>mvn:org.eclipse.jetty.websocket/websocket-server/9.3.6.v20151106</bundle>
The point of features.xml is to define a repository of features that can be used to provision an OSGi application in Apache Karaf. In another words, it's purpose is exactly to NOT have to install bundles manually! As documentation states:
When you install a feature, Apache Karaf installs all resources described in the feature. It means that it will automatically resolves and installs all bundles, configurations, and dependency features described in the feature.
That said, please keep in mind:
this is Karaf specific functionality. It will not work with other OSGi containers
before you can install a feature you need to make Karaf aware of the repository containing it. You can use feature:repo-list command to check what repos Karaf is aware of and feature:repo-add command to add repositories. Please see this documentation for more details.
URLs pointing to bundles, features, configurations, ... inside features.xml have to point to a reasoures Karaf understands and can access
Features (much like bundles) need to be resolved before they be activated.

How to deploy a karaf feature from a local maven repository?

I've created by first project for karaf (4.0.1). So far I've got the following:
an application bundle built with the maven-bundle-plugin. There are going to be more...
a karaf feature created with the karaf-maven-plugin.
a karaf-assembly created with the same plugin
So I'm ready to deliver to the customer - but I'm stuck over the development process. This question answered almost all my remaining questions save one:
After having built my project by running maven install I think I should be able to to get my feature running on a local karaf instance using something like the command feature:install.
I can install my application bundle from local maven by using bundle:install but then I'm down to managing dependencies myself.
Really can't figure out while bundle:install works against my local maven repository and feature:install doesn't.
Found the soloution here. I knew I'd need feature:repo-add - but the name of this command and the official documentation sent me thinking in entirely the wrong direction.
This command does not add a (maven) repository, but adds the location of a feature in the maven repository chain (so I'm thinking the old name addUrl was probably easier to understand).
Anyway - using feature:repo-add mvn:<groupId>/<artifactId>/<version>/xml/features works.
I've just had the similar issue and I've found solution here: http://karaf.922171.n3.nabble.com/Add-additional-local-maven-repository-how-td4028299.html
I've edited the etc/org.ops4j.pax.url.mvn.cfg and uncommented the option org.ops4j.pax.url.mvn.localRepository, setting it to my local repository location:
org.ops4j.pax.url.mvn.localRepository=C:/data/maven-repo
Before installing a feature, you have to register the features repository that provides the feature using feature:repo-add
using feature:repo-add mvn:<groupId>/<artifactId>/<version>/xml

How to install a bundle on boot in Karaf

I came across this post but it doesn't quite answer my question. I am using blueprint to set up a H2 database in Karaf and it requires that I first install H2 driver and OSGi enterprise package because it contains JDBC library.
install -s mvn:org.osgi/org.osgi.enterprise/4.2.0
install -s mvn:com.h2database/h2/1.3.174
I added the blueprint XML file to Karaf's deploy folder and it keeps giving error messages until I install H2 and enterprise package. Ideally, I would like to install both enterprise and H2 before the blueprint script kicks in, so I am thinking somehow add it to karaf's boot process but I am not sure how.
Any insights will be much appreciated.
One option would be to hot deploy a features XML before deploying your bundle.
See the Karaf deployer guide for more details. Here is an XML example:
<features>
<feature name="features_test">
<bundle>mvn:org.osgi/org.osgi.enterprise/4.2.0</bundle>
<bundle>mvn:com.h2database/h2/1.3.174</bundle>
</feature>
</features>
One way to achieve this is to publish the blueprint file to the maven repo. This way you can reference it in feature files. See the maven build helper plugin with goal attach artifacts. Many feature files are deployed tnis way.
You can also put your blueprint file into an ordinary bundle. Then it will also work in other containers than karaf.

Karaf development

Im currently develop bundles for karaf and have some questions...
I wrote a bundle/webservice based on cxf, I try to deploy it in karaf but it could not start that bundle because it could not resolve some packages e.g.
org.osgi.framework.BundleException: Unresolved constraint in bundle org.springframework.aop [56]: Unable to resolve 56.0: missing
requirement [56.0] package; (&(package=org.aopalliance.aop)(version>=1.0.0)(!(version>=2.0.0)))
so here is a question, this package dependency comes from spring-aop (3.1.0.RELEASE), so where is the problem? what dependency is missing? how can I solve such problems?
In that case i did not clearly understand the development process. should i deploy all missing bundles in deploy? because i would like to keep thirdparty libs spereated from my developed bundles. And what bundles i have to deploy? Is it a trial and error process? Is there a common way to let maven do the dependency stuff?
I discovered a folder "system" and read on the docu that it is a repository like maven, is it for the features?
I had for test cases a karaf with some pre deployed bundles and put my webservice bundle into it, but again execeptions...
Caused by: java.lang.ClassNotFoundException: javax.servlet.http.HttpServlet
What dependency is missing?
I already read the tutorial about camel and karaf, but it did not explain the deployment stuff, so could anyone suggest me a good tutorial?
Thanks!
Chris
Short answer
Scroll down to the bit referring to "camel-cxf" and run the two commands features:addurl and features:install. I have a feeling this will resolve all your problems.
spring-aop
On Karaf console type:
exports | grep org.aopalliance.aop
I think you'll see lines like:
XX org.aopalliance.aop; version=3.1.0.RELEASE
So while the spring-aop bundle has the right packages they're the wrong version, the range being requested is >=1.0.0 and <2.0.0, so 3.1.0 doesn't satisfy that.
Deploying/Installing
You can drop bundles into ${karaf.home}/deploy or use the console.
You can install maven bundles from the Karaf console with:
install -s mvn:groupId/artifactId/version/packaging/classifier
Where -s starts the bundle and packaging/classifier are optional.
You can find a lot of OSGi ready maven dependencies here http://ebr.springsource.com/repository/app/ - I had a quick look but your spring aop dependency is very old, what version of CXF are you using?
Read up about Karaf features - they're basically XML files that list suites of bundles that can be installed. Very useful for deploying large numbers of bundles and they can be installed into a maven repository.
There are some standard features available in Karaf, try:
features:install war
This will give you a jetty webcontainer and may resolve your ClassNotFoundException: javax.servlet.http.HttpServlet as long as it's the right version
Camel also has a features file which probably sort all your issues, try this:
features:addurl mvn:org.apache.camel.karaf/apache-camel/2.9.0/xml/features
features:install camel-cxf
Tutorials
There's quite a bit available, some on http://karaf.apache.org and http://fusesource.com but also take a look at the PDF manual that comes in the Karaf distribution.
Always beware that info may be out-of-date
Please post your MANIFEST.MF file. I think you didn't not mention the tag in maven-bundle-plugin dependency.

Resources