Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A transitive maven dependency may prevent karaf in pax exam from starting properly [PAXEXAM-925] #1006

Open
ops4j-issues opened this issue Jan 13, 2019 · 0 comments
Labels

Comments

@ops4j-issues
Copy link

Steinar Bang created PAXEXAM-925

I've encounteret two places where a transitive maven dependency have prevented karaf in pax exam tests from loading karaf features.

The first problem was when I added mockrunner dependencies to be able to use MockHttpServletRequest and MockHttpServletRespons in a pax exam test:

  1. I added the following dependencies to the pom.xml file of the pax exam project:
     <properties>
         <mockrunner.version>2.0.2-SNAPSHOT</mockrunner.version>
     </properties>
     <dependencyManagement>
         <dependencies>
             <dependency>
                 <groupId>com.mockrunner</groupId>
                 <artifactId>mockrunner-core</artifactId>
                 <version>${mockrunner.version}</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
                 <groupId>com.mockrunner</groupId>
                 <artifactId>mockrunner-servlet</artifactId>
                 <version>${mockrunner.version}</version>
                 <scope>test</scope>
             </dependency>
         </dependencies>
     </dependencyManagement>
  1. The purpose of the dependencies was to provide version numbers to the pax exam config, that's why the dependencies were provided:
    @Configuration
    public Option[] config() {
        final String jmxPort = freePortAsString();
        final String httpPort = freePortAsString();
        final String httpsPort = freePortAsString();
        final MavenArtifactUrlReference karafUrl = maven().groupId("org.apache.karaf").artifactId("apache-karaf-minimal").type("zip").versionAsInProject();
        final MavenArtifactUrlReference paxJdbcRepo = maven().groupId("org.ops4j.pax.jdbc").artifactId("pax-jdbc-features").versionAsInProject().type("xml").classifier("features");
        final MavenArtifactUrlReference mockrunnerRepo = maven().groupId("com.mockrunner").artifactId("mockrunner-servlet").versionAsInProject().type("xml").classifier("features");
        final MavenArtifactUrlReference ukelonnFeatureRepo = maven().groupId("no.priv.bang.ukelonn").artifactId("karaf").versionAsInProject().type("xml").classifier("features");
        return options(
            karafDistributionConfiguration().frameworkUrl(karafUrl).unpackDirectory(new File("target/exam")).useDeployFolder(false).runEmbedded(true),
            configureConsole().ignoreLocalConsole().ignoreRemoteShell(),
            systemTimeout(720000),
            keepRuntimeFolder(),
            logLevel(LogLevel.DEBUG),
            editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiRegistryPort", RMI_REG_PORT),
            editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiServerPort", RMI_SERVER_PORT),
            editConfigurationFilePut("etc/org.ops4j.pax.web.cfg", "org.osgi.service.http.port", httpPort),
            editConfigurationFilePut("etc/org.ops4j.pax.web.cfg", "org.osgi.service.http.port.secure", httpsPort),
            replaceConfigurationFile("etc/org.ops4j.pax.logging.cfg", getConfigFile("/etc/org.ops4j.pax.logging.cfg")),
            systemProperty("org.ops4j.pax.logging.DefaultSer‌​viceLog.level").value("DEBUG"),
            vmOptions("-Dtest-jmx-port=" + jmxPort),
            junitBundles(),
            features(paxJdbcRepo),
            features(mockrunnerRepo, "mockrunner-servlet"),
            features(ukelonnFeatureRepo, "ukelonn-with-derby"));
    }
  1. In the karaf.log of the pax exam test, I could see karaf start, and then nothing happened, no error messages until the test timed out. No karaf features were loaded
Dec 28, 2018 11:24:01 AM org.apache.karaf.main.Main launch
INFO: Installing and starting initial bundles
Dec 28, 2018 11:24:01 AM org.apache.karaf.main.Main launch
INFO: All initial bundles installed and set to start
Dec 28, 2018 11:24:01 AM org.apache.karaf.main.lock.SimpleFileLock lock
INFO: Trying to lock /home/sb/workspaces/ws03/ukelonn/ukelonn.tests/target/exam/72ae121c-3e79-422e-a5a6-6985c16e8238/lock
Dec 28, 2018 11:24:01 AM org.apache.karaf.main.lock.SimpleFileLock lock
INFO: Lock acquired
Dec 28, 2018 11:24:01 AM org.apache.karaf.main.Main$KarafLockCallback lockAquired
INFO: Lock acquired. Setting startlevel to 100
  1. By trial and error I figured out that one of the transitive dependencies of the dependencies I included was the culprit, and when I excluded the culprit, karaf started normally in pax exam, and all features were loaded:
        <dependency>
            <groupId>com.mockrunner</groupId>
            <artifactId>mockrunner-core</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>nekohtml</groupId>
                    <artifactId>nekohtml</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.mockrunner</groupId>
            <artifactId>mockrunner-servlet</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>nekohtml</groupId>
                    <artifactId>nekohtml</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.mockrunner</groupId>
            <artifactId>mockrunner-servlet</artifactId>
            <version>${mockrunner.version}</version>
            <type>xml</type>
            <classifier>features</classifier>
        </dependency>

The second problem I had was that the pax-jdbc features repository for pax-jdbc 1.3.0 had a transitive dependency to karaf 4.1.1 that gave karaf 4.1.7 in pax exam startup problems. I.e. it wasn't a dependecy in the feature file that gave the problem, but a transitive dependency of the feature file dependency.

  1. The feature file dependency that caused karaf not to start properly in pax exam:
        <dependency>
            <groupId>org.ops4j.pax.jdbc</groupId>
            <artifactId>pax-jdbc-features</artifactId>
            <version>1.3.1</version>
            <type>xml</type>
            <classifier>features</classifier>
        </dependency>
  1. The feature file with exclusion of the troublesome transitive dependency (here karaf startet properly in pax exam)
        <dependency>
            <groupId>org.ops4j.pax.jdbc</groupId>
            <artifactId>pax-jdbc-features</artifactId>
            <version>1.3.1</version>
            <type>xml</type>
            <classifier>features</classifier>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.karaf</groupId>
                    <artifactId>org.apache.karaf.client</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

Affects: 4.10.0, 4.13.1
Votes: 0, Watches: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant