1

I am currently migrating app from openJDK 8 to openJDK 9/11. Project uses Maven 3.5.2 (also tried with 3.6). I am using Ubuntu 18.04 as primary OS. My IDE is IntelliJ IDEA 2018.3.2

After adding module-info.java most of the maven dependencies worked fine with

requires ${module.name}

I have problems with elasticsearch and wiremock. By requiring them I am getting "module not found"

In pom.xml they included as follows:

<dependency>
    <groupId>com.github.tomakehurst</groupId>
    <artifactId>wiremock</artifactId>
    <version>1.58</version>
    <exclusions>
        <exclusion>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>servlet-api</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty</artifactId>
        </exclusion>
    </exclusions>
    <classifier>standalone</classifier>
</dependency>
<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>1.3.2</version>
</dependency>

By requiring wiremock in module-info.java

module com.mydomain {
    requires guava;
    ...
    ...
    requires wiremock;
    requires elasticsearch;

    exports com.mydomain.p1;
    exports com.mydomain.p2;
}

With wiremock version <version>1.58</version> in pom.xml during compiling I am getting

[WARNING] Can't extract module name from mysql-connector-mxj-5.0.12.jar: TestDb.class found in top-level directory (unnamed package not allowed in module)
[WARNING] Can't extract module name from wiremock-1.58-standalone.jar: Provider class com.fasterxml.jackson.core.JsonFactory not in module
[WARNING] Can't extract module name from ical4j-3.0.1.jar: Provider class moduleName = ical4j-module not in module
[WARNING] Can't extract module name from elasticsearch-1.3.2.jar: Provider class com.fasterxml.jackson.core.JsonFactory not in module
[WARNING] ********************************************************************************************************************
[WARNING] * Required filename-based automodules detected. Please don't publish this project to a public artifact repository! *
[WARNING] ********************************************************************************************************************
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project project: Compilation failure: Compilation failure: 
[ERROR] /home/artem/Documents/project/src/main/java/module-info.java:[95,14] module not found: wiremock
[ERROR] /home/artem/Documents/project/src/main/java/module-info.java:[97,14] module not found: elasticsearch

Updating to new versions do not help. If using wiremock with <version>2.1.6</version> or higher Intellij says module not found to:

requires commons.lang;
requires json;

And

[ERROR] Failed to execute goal on project project: Could not resolve dependencies for project com.mydomain:project:jar:0.0.1-SNAPSHOT: Failure to find com.github.tomakehurst:wiremock:jar:standalone:2.21.0 in https://repository.mulesoft.org/nexus/content/repositories/public was cached in the local repository, resolution will not be reattempted until the update interval of codehaus-release-repo has elapsed or updates are forced
Arttu
  • 351
  • 2
  • 14
  • Yes, mostly that. If the error is while executing the service, just check what all modules are [resolved at the startup](https://stackoverflow.com/questions/48339598/list-the-modules-resolved-during-the-application-startup) and you'll find it. If at compile time, then ensure that you add requires for `wiremock` as well in the `module-info.java`. – Naman Feb 11 '19 at 13:41
  • @nullpointer Yes, it is during compiling time. When I requires for `wiremock` in the `module-info.java` during compilation it says `module not found` – Arttu Feb 11 '19 at 13:46
  • Please update the question with complete details. I am able to add a dependency to `wiremock` version shared in the question, though it brings in split package conflicts with `com.google.common` on my modulepath. What did you mean by *version 2 and higher it breaks other modules like* ? – Naman Feb 11 '19 at 13:53
  • @nullpointer I tried to structure my question better. and after your comment I made test project and indeed I can require `wiremock`. But only until I import somesting from wiremock. For example import `wiremock.com.google.common.collect.Lists;`. After that import I am getting `[ERROR] Failed to execute goal on project devday: Could not resolve dependencies for project de.consol:devday:jar:1.0-SNAPSHOT: Could not find artifact com.google.common:google-collect:jar:1.0-rc1 in central (https://repo.maven.apache.org/maven2) ` – Arttu Feb 11 '19 at 15:09
  • Have you tried with WireMock 2.21.0. As described in the WireMock mailinglist this version is released with support for both Java JDK 1.7 and 1.8+. Perhaps this WM 2.21.0 support for 1.8 [release](https://groups.google.com/d/msg/wiremock-user/d2ccElkl474/CfjSBDoZFQAJ) will help you – A. Kootstra Feb 11 '19 at 15:49
  • @A.Kootstra yes, no luck. – Arttu Feb 12 '19 at 07:18

0 Answers0