0

I'm trying to create a new project in Java that is composed by several modules (following the Java Modules concept introduced on Java 9). In one of those modules, I'm trying to use vert.x codegen to generate a service that will be exposed to the other modules.

Now that problem is that when I try to compile the service module I got the following error:

module-info.java:[5,22] module not found: io.vertx.codegen.

For your reference, I will put my module configuration (as stated on module-info.java) and my POM file.

Module-info.java:

module mo.com.test.daomodule {
    requires io.vertx.core;
    requires io.vertx.client.sql.mssql;
    requires io.vertx.client.sql;
    requires io.vertx.codegen;
    requires io.vertx.serviceproxy;
    requires org.apache.logging.log4j.core;
    requires org.apache.logging.log4j;
    
    exports mo.com.test.dao.db.service;
    exports mo.com.test.dao.db; 
}

My pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>mo.com.test</groupId>
        <artifactId>MainProject</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    
     <properties>
         <vertx.version>4.2.1</vertx.version>
         <jdbc.version>9.4.0.jre11</jdbc.version>
         <log4j2api.version>2.14.1</log4j2api.version>
         <log4j2core.version>2.14.1</log4j2core.version>
     </properties>
    
    <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-stack-depchain</artifactId>
            <version>${vertx.version}</version>
            <type>pom</type>
            <scope>import</scope>
          </dependency>
        </dependencies>
    </dependencyManagement>
    
    <dependencies>
        
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-core</artifactId>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-json-schema</artifactId>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-jdbc-client</artifactId>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-mssql-client</artifactId>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-codegen</artifactId>  
            <version>${vertx.version}</version>
            <classifier>processor</classifier>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-service-proxy</artifactId>
            <version>${vertx.version}</version>
        </dependency>
        
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>${jdbc.version}</version>
            <type>jar</type>
        </dependency>
        
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>${log4j2api.version}</version>
            <type>jar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j2core.version}</version>
            <type>jar</type>
        </dependency>
    
    </dependencies>
    
    <groupId>mo.com.test</groupId>
    <artifactId>daomodule</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <name>daomodule</name>
</project>

By checking above, I have added the necessary imports in the POM file and add include the vert.x modules as required in the module-info.java.

No my question is, what can I do to solve this compilation problem? Is there anything missing on my POM or my module-info.java?

2
  • You have to change your module-info ... Commented Nov 25, 2021 at 12:05
  • @khmarbaise how should I change the module-info? More info would be appreciated to help me guide through. Commented Nov 26, 2021 at 1:18

1 Answer 1

0

If you're only using the generated code at runtime, and the generated code has no dependencies on the code in the codegen jar file, then I do not think you need requires io.vertx.codegen; in your module-info.java file.

If you do need this at runtime, then I think the <scope>processor</scope> is part of the issue. I believe that you would need to remove that scope so that the jar file will be available past the compile phase. I can't actually find any documentation on that scope value, so I'm assuming that it's something valid.

Also, the way you configure annotation processors in maven requires you to configure the compiler plugin. Refer to the answer here: https://stackoverflow.com/a/41777832/359035

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.