Skip to content

m2e runs jOOQ codegen with unresolved dynamic DB properties in IDE (works via CLI) #2064

@palminha

Description

@palminha

Environment

  • IDE: VSCode 1.105.1 (Universal), redhat.java 1.46.0
  • OS: macOS Sequoia 15.6.1

Summary

In a Maven project that generates jOOQ sources during generate-sources, the IDE build (m2e) triggers org.jooq:jooq-codegen-maven but fails with:

org.jooq.exception.DetachedException: Cannot execute query. No JDBC Connection configured

The same module builds fine on the command line with the appropriate profile:

mvn -P <profile> clean generate-sources

Context

The JDBC URL/credentials are computed at build time by a pre-step (e.g., Groovy/Testcontainers) that runs before jOOQ codegen and sets properties such as:

  • ${search.db.url}
  • ${search.db.user}
  • ${search.db.password}

In CLI Maven, that pre-step runs, properties are populated, and codegen succeeds. In the IDE, m2e appears to execute the jOOQ goal without those properties resolved, leading to the failure above.

Expected behavior

m2e resolves the plugin configuration the same way CLI Maven does (including properties produced by earlier executions in the same build), so jOOQ codegen runs successfully;

Actual behavior

On project import / Maven → Update Project (and sometimes Project → Clean), m2e runs jooq-codegen-maven with unresolved ${…} JDBC properties and fails with “No JDBC Connection configured”, leaving the project with build errors until code is generated via CLI.

Steps to Reproduce

  1. Import the attached minimal project into VS Code with Java extensions
  2. The project contains:
    • A pre-step bound before generate-sources (e.g., gmavenplus:execute) that starts a Testcontainers PostgreSQL and sets ${search.db.url}, ${search.db.user}, ${search.db.password} into the session/execution properties.
    • A jooq-codegen-maven execution bound to generate-sources that consumes those properties.
  3. Trigger a workspace build (Project → Clean, then Maven → Update Project).
  4. Observe Maven Console / Error Log: jOOQ codegen fails with the exception above.
  5. Run mvn -P <profile> clean generate-sources on the CLI; codegen succeeds. Refresh the IDE; errors disappear.

Relevant pom.xml snippets

<!-- Pre-step: computes DB props at build time -->
<plugin>
  <groupId>org.codehaus.gmavenplus</groupId>
  <artifactId>gmavenplus-plugin</artifactId>
  <version>${gmavenplus.version}</version>
  <executions>
    <execution>
      <id>prepare-runtime-db</id>
      <phase>generate-resources</phase>
      <goals><goal>execute</goal></goals>
      <configuration>
        <scripts>
          <script><![CDATA[
            // starts Testcontainers Postgres and sets properties
            // session.getProject().getProperties().put("search.db.url", jdbcUrl);
            // session.getProject().getProperties().put("search.db.user", user);
            // session.getProject().getProperties().put("search.db.password", pass);
          ]]></script>
        </scripts>
      </configuration>
    </execution>
  </executions>
</plugin>

<!-- jOOQ codegen consuming the dynamic properties -->
<plugin>
  <groupId>org.jooq</groupId>
  <artifactId>jooq-codegen-maven</artifactId>
  <version>${jooq.codegen.version}</version>
  <executions>
    <execution>
      <id>jooq-generate</id>
      <phase>generate-sources</phase>
      <goals><goal>generate</goal></goals>
      <configuration>
        <jdbc>
          <url>${search.db.url}</url>
          <user>${search.db.user}</user>
          <password>${search.db.password}</password>
        </jdbc>
        <!-- rest of config -->
      </configuration>
    </execution>
  </executions>
</plugin>

Notes

  • This looks like the broader class where m2e doesn’t execute or propagate dynamic properties produced by earlier plugin executions during the workspace build, so downstream plugin configs see unresolved ${…}.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions