0

I am testing CXF REST services in Karaf using Pax Exam. The tests almost always run without a hitch on my machine. When run in Jenkins (under Maven build) they typically fail. The failures seem random and unpredictable. The error I receive during the failure deals with attempt to run a Karaf command. The commands are executed by the following snippet:

    def byteArrayOutputStream = new ByteArrayOutputStream();
    def printStream = new PrintStream(byteArrayOutputStream);
    CommandProcessor commandProcessor = getOsgiService(CommandProcessor.class);
    CommandSession commandSession = commandProcessor.createSession(System.in, printStream, System.err);
    commandSession.put("APPLICATION", System.getProperty("karaf.name", "root"));
    commandSession.put("USER", "karaf");
    commandSession.execute(command)

These are the commands I am trying to execute in the tests setup method:

'features:addurl mvn:org.apache.cxf.karaf/apache-cxf/2.7.2/xml/features', 'features:install http', 'features:install cxf'

This is the exception:

org.apache.felix.gogo.runtime.CommandNotFoundException: Command not found: features:addurl

Apparently occasionally Karaf does not start correctly and cannot process these commands. The error like this one happen randomly in different tests on different Karaf commands. On my machine they are more likely to happen if the machine is under load.

What may cause Karaf to behave in such a manner? How to prevent these errors from happening?

Thank you,

Michael

Michael Smolyak
  • 593
  • 2
  • 6
  • 21

1 Answers1

0

There is is also pax-exam-karaf, it also has a feature installer which is usable from the configuration. If you want to stick to the "manual" installation you shoul make sure the features service is installed beforehand. For example let the service be injected.

Achim Nierbeck
  • 5,265
  • 2
  • 14
  • 22
  • I've had trouble with the pax-exam-karaf feature installer, so I use pax-exam-karaf with manual feature installation. Are you saying that I could wait for the features service and use the service to install new features instead of executing commands with CommandProcessor service? – jdgilday Mar 15 '13 at 12:51
  • Yep, that could also be achieved :) – Achim Nierbeck Mar 15 '13 at 13:26
  • What kind of issues do you have with pax-exam-karaf feature installer, it usually works like a charm. Karaf itself does test with it. – Achim Nierbeck Mar 15 '13 at 13:27