0

Colleagues, it so happened that I am now using the servicemix 7.0 technology in one old project. There are several commands that I run manually.

build image servicemix docker build --no-cache -t servicemix-http:latest .

start container and copy data from local folder source and folder .m docker run --rm -it -v %cd%:/source -v %USERPROFILE%/.m2:/root/.m2 servicemix-http

start console servicemix and run command feature:repo-add file:/../source/source/transport/feature/target/http-feature.xml

run command feature:install http-feature

copy deploy files from local folder to deploy folder into servicemix docker cp /configs/. :/deploy

update image servicemix docker commit servicemix-http

Now I describe the gitlab-ci.yml for deployment. And the question concerns the servicemix commands that were launched from the karaf console. feature:repo-add feature:install Is there any way to script them?

Aleks R.
  • 3
  • 1

1 Answers1

0

If all you need is to install features from specific feature repositories on startup you can add the features and feature-repositories to /etc/org.apache.karaf.features.cfg.

You can use ssh with private-key to pass commands to Apache karaf.

ssh karaf@localhost -p 8101 -i ~/.ssh/karaf_private_key -- bundle:list

You can also try running commands through Karaf_home/bin/client, albeit had no luck using it with Windows 10 ServiceMix 7.0.1 when I tried. It kept throwing me NullReferenceException so guessing my java installation is missing some security related configuration.

Works well when running newer Karaf installations on docker though and can be used through docker exec as well.

# Using password - (doesn't seem to be an option for servicemix)
docker exec -it  karaf /opt/apache-karaf/bin/client -u karaf -p karaf -- bundle:list

# Using private-key
docker exec -it  karaf /opt/apache-karaf/bin/client -u karaf -k /keys/karaf_key -- bundle:list
Pasi Österman
  • 2,002
  • 1
  • 6
  • 13
  • I tried to add the /etc/org.apache.karaf.features.cfg file to this config to the "featuresRepositories" section to add myRepo - it works, but when I added it to the "featuresBoot" section to install myFeature - karaf hangs. I tried this solution (https://stackoverflow.com/questions/61020044/pre-programmed-feature-installs-at-apache-karaf-launch) but it's not clear to me what the hex number at the end means. – Aleks R. Apr 21 '22 at 11:21
  • Make sure that org.apache.karaf.features.cfg file is properly formatted, all lines in featuresRepositories and featuresBoot list except for the last ones should end with , \ . Also check that the file is using UTF-8 encoding and Unix lineendings(LF). – Pasi Österman Apr 22 '22 at 07:59
  • You can also check if `\data\log\servicemix.log` gives you any hints why karaf might be hanging. You can also try adding features one at the time to see if one of the features is causing the problem. – Pasi Österman Apr 22 '22 at 08:04
  • The advice to remove all unnecessary from the file myFeature.xml worked. I turned to the logs and nothing happened for about 3 minutes. That is, the Karaf hung. After I saw the error "Unknown protocol: wrap" and everything became clear. But again, the correct solution is to add wrap - doesn't work! I went the wrong way and changed the boot order in the featuresBoot = \ (..., \ wrap), \ (my-feature) - Also it works! I stop here - it would seem so simple, but a lot of time has been spent. Thank you. – Aleks R. Apr 25 '22 at 07:34
  • Good to hear, if that helped you can mark the answer as accepted. – Pasi Österman Apr 25 '22 at 10:22