apache / pulsar

Apache Pulsar - distributed pub-sub messaging system
https://pulsar.apache.org/
Apache License 2.0
14.27k stars 3.59k forks source link

[Bug] Maven: pulsar-client 4.0.0 does not integrate pulsar-client-admin-api & pulsar-client-api 4.0.0 #23509

Open qmonmert opened 1 month ago

qmonmert commented 1 month ago

Search before asking

Read release policy

Version

Pulsar version : 4.0.0

Minimal reproduce step

Add this dependency in pom.xml

    <dependency>
      <groupId>org.apache.pulsar</groupId>
      <artifactId>pulsar-client</artifactId>
      <version>4.0.0</version>
    </dependency>

What did you expect to see?

image

What did you see instead?

image

Anything else?

No response

Are you willing to submit a PR?

lhotari commented 1 month ago

@qmonmert Please configure your application to use the Pulsar BOM, the documentation has been updated recently (1 minute ago) to also cover Spring Boot gradle builds where there has been a similar issue in the past: https://pulsar.apache.org/docs/4.0.x/client-libraries-java-setup/#pulsar-bom

Does this address your problem?

lhotari commented 1 month ago

The pom at https://repo1.maven.org/maven2/org/apache/pulsar/pulsar-client/4.0.0/pulsar-client-4.0.0.pom includes

<dependency>
  <groupId>org.apache.pulsar</groupId>
  <artifactId>pulsar-client-api</artifactId>
  <version>4.0.0</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>org.apache.pulsar</groupId>
  <artifactId>pulsar-client-admin-api</artifactId>
  <version>4.0.0</version>
  <scope>compile</scope>
</dependency>

Therefore, I think that the solution is to use Pulsar BOM as explained in https://pulsar.apache.org/docs/4.0.x/client-libraries-java-setup/#pulsar-bom

qmonmert commented 1 month ago

@lhotari thanks but I tried your solution and it doesn't work on my project

image

but on a simple project it seems to work

image image
qmonmert commented 1 month ago

@lhotari your solution works if I remove this dependency: org.springframework.boot in dependencyManagement but I need

image OK ✅

image KO ❌

lhotari commented 1 month ago

@lhotari your solution works if I remove this dependency: org.springframework.boot in dependencyManagement but I need

@qmonmert Have you checked the recent updates to the instructions for Spring Boot applications? Setting pulsar.version property should be sufficient. https://pulsar.apache.org/docs/4.0.x/client-libraries-java-setup/#spring-boot Are you dealing with a Spring Boot app?

qmonmert commented 1 month ago

@lhotari yes a spring boot app

qmonmert commented 1 month ago

@lhotari here my pom.xml which is working on version 3.3.1 of pulsar but not after

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>tech.jhipster.pulsarapp</groupId>
  <artifactId>pulsarapp</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>pulsarapp</name>
  <description>Chips Project</description>
  <packaging>jar</packaging>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring-boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.approvaltests</groupId>
      <artifactId>approvaltests</artifactId>
      <version>${approvaltests.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>net.jqwik</groupId>
      <artifactId>jqwik</artifactId>
      <version>${jqwik.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java</artifactId>
      <version>${protobuf.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-configuration-processor</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.pulsar</groupId>
      <artifactId>pulsar-client</artifactId>
      <version>${pulsar.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.protobuf</groupId>
      <artifactId>protobuf-java-util</artifactId>
      <version>${protobuf.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.reflections</groupId>
      <artifactId>reflections</artifactId>
      <version>${reflections.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>pulsar</artifactId>
      <version>${testcontainers.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <properties>
    <java.version>21</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <maven.version>3.6.3</maven.version>

    <maven-enforcer-plugin.version>3.5.0</maven-enforcer-plugin.version>
    <compiler-plugin.version>3.13.0</compiler-plugin.version>
    <surefire-plugin.version>3.5.1</surefire-plugin.version>
    <failsafe-plugin.version>3.5.1</failsafe-plugin.version>
    <maven-checkstyle-plugin.version>3.5.0</maven-checkstyle-plugin.version>
    <approvaltests.version>24.8.0</approvaltests.version>
    <jqwik.version>1.9.1</jqwik.version>
    <protobuf.version>4.28.2</protobuf.version>
    <protobuf-maven-plugin.version>2.6.4</protobuf-maven-plugin.version>
    <proto-backwards-compatibility.version>1.0.7</proto-backwards-compatibility.version>
    <os-maven-plugin.version>1.7.1</os-maven-plugin.version>
    <jacoco.version>0.8.11</jacoco.version>
    <spring-boot.version>3.3.4</spring-boot.version>
    <reflections.version>0.10.2</reflections.version>
    <properties-maven-plugin.version>1.2.1</properties-maven-plugin.version>
    <sonar-maven-plugin.version>4.0.0.4121</sonar-maven-plugin.version>
    <pulsar.version>4.0.0</pulsar.version>
    <testcontainers.version>1.20.2</testcontainers.version>
  </properties>

  <build>
    <extensions>
      <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>${os-maven-plugin.version}</version>
      </extension>
    </extensions>
    <resources>
      <resource>
        <directory>${basedir}/src/main/resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>config/*.properties</include>
          <include>config/*.yml</include>
        </includes>
      </resource>
      <resource>
        <directory>${basedir}/src/main/resources</directory>
        <excludes>
          <exclude>config/*.properties</exclude>
          <exclude>config/*.yml</exclude>
        </excludes>
      </resource>
    </resources>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>${maven-enforcer-plugin.version}</version>
          <executions>
            <execution>
              <id>enforce-versions</id>
              <goals>
                <goal>enforce</goal>
              </goals>
            </execution>
            <execution>
              <id>enforce-dependencyConvergence</id>
              <goals>
                <goal>enforce</goal>
              </goals>
              <configuration>
                <rules>
                  <DependencyConvergence />
                </rules>
                <fail>false</fail>
              </configuration>
            </execution>
          </executions>
          <configuration>
            <rules>
              <requireMavenVersion>
                <message>You are running an older version of Maven: minimum required version is ${maven.version}</message>
                <version>${maven.version}</version>
              </requireMavenVersion>
              <requireJavaVersion>
                <message>You are running an incompatible version of Java: minimum required version is ${java.version}</message>
                <version>${java.version}</version>
              </requireJavaVersion>
            </rules>
          </configuration>
        </plugin>
        <plugin>
          <groupId>io.github.ascopes</groupId>
          <artifactId>protobuf-maven-plugin</artifactId>
          <version>${protobuf-maven-plugin.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>generate</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <protocVersion>${protobuf.version}</protocVersion>
            <sourceDirectories>
              <sourceDirectory>src/main/proto</sourceDirectory>
            </sourceDirectories>
            <failOnMissingSources>false</failOnMissingSources>
          </configuration>
        </plugin>
        <plugin>
          <groupId>com.salesforce.servicelibs</groupId>
          <artifactId>proto-backwards-compatibility</artifactId>
          <version>${proto-backwards-compatibility.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>backwards-compatibility-check</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${jacoco.version}</version>
          <executions>
            <execution>
              <id>pre-unit-tests</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
            </execution>
            <execution>
              <id>post-unit-test</id>
              <phase>test</phase>
              <goals>
                <goal>report</goal>
              </goals>
            </execution>
            <execution>
              <id>pre-integration-tests</id>
              <goals>
                <goal>prepare-agent-integration</goal>
              </goals>
            </execution>
            <execution>
              <id>post-integration-tests</id>
              <phase>post-integration-test</phase>
              <goals>
                <goal>report-integration</goal>
              </goals>
            </execution>
            <execution>
              <id>merge</id>
              <phase>verify</phase>
              <goals>
                <goal>merge</goal>
              </goals>
              <configuration>
                <fileSets>
                  <fileSet implementation="org.apache.maven.shared.model.fileset.FileSet">
                    <directory>${project.basedir}</directory>
                    <includes>
                      <include>**/*.exec</include>
                    </includes>
                  </fileSet>
                </fileSets>
                <destFile>target/jacoco/allTest.exec</destFile>
              </configuration>
            </execution>
            <execution>
              <id>post-merge-report</id>
              <phase>verify</phase>
              <goals>
                <goal>report</goal>
              </goals>
              <configuration>
                <dataFile>target/jacoco/allTest.exec</dataFile>
                <outputDirectory>target/jacoco/</outputDirectory>
              </configuration>
            </execution>
            <execution>
              <id>check</id>
              <goals>
                <goal>check</goal>
              </goals>
              <configuration>
                <dataFile>target/jacoco/allTest.exec</dataFile>
                <rules>
                  <rule>
                    <element>CLASS</element>
                    <limits>
                      <limit>
                        <counter>BRANCH</counter>
                        <value>MISSEDCOUNT</value>
                        <maximum>0</maximum>
                      </limit>
                      <limit>
                        <counter>LINE</counter>
                        <value>MISSEDCOUNT</value>
                        <maximum>0</maximum>
                      </limit>
                    </limits>
                  </rule>
                </rules>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>${spring-boot.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>repackage</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <mainClass>tech.jhipster.pulsarapp.PulsarappApp</mainClass>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>properties-maven-plugin</artifactId>
          <version>${properties-maven-plugin.version}</version>
          <executions>
            <execution>
              <id>default-cli</id>
              <phase>initialize</phase>
              <goals>
                <goal>read-project-properties</goal>
              </goals>
              <configuration>
                <files>
                  <file>sonar-project.properties</file>
                </files>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.sonarsource.scanner.maven</groupId>
          <artifactId>sonar-maven-plugin</artifactId>
          <version>${sonar-maven-plugin.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${compiler-plugin.version}</version>
        <configuration>
          <release>${java.version}</release>
          <parameters>true</parameters>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${surefire-plugin.version}</version>
        <configuration>
          <runOrder>alphabetical</runOrder>
          <excludes>
            <exclude>**/*IT*</exclude>
            <exclude>**/*CucumberTest*</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>${failsafe-plugin.version}</version>
        <executions>
          <execution>
            <id>integration-test</id>
            <goals>
              <goal>integration-test</goal>
            </goals>
          </execution>
          <execution>
            <id>verify</id>
            <goals>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <classesDirectory>${project.build.outputDirectory}</classesDirectory>
          <runOrder>alphabetical</runOrder>
          <includes>
            <include>**/*IT*</include>
            <include>**/*CucumberTest*</include>
          </includes>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-enforcer-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>${maven-checkstyle-plugin.version}</version>
        <executions>
          <execution>
            <id>validate</id>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <configLocation>checkstyle.xml</configLocation>
          <includeTestSourceDirectory>true</includeTestSourceDirectory>
          <consoleOutput>true</consoleOutput>
          <failsOnError>true</failsOnError>
        </configuration>
      </plugin>
      <plugin>
        <groupId>io.github.ascopes</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>com.salesforce.servicelibs</groupId>
        <artifactId>proto-backwards-compatibility</artifactId>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
      </plugin>
    </plugins>
    <defaultGoal>spring-boot:run</defaultGoal>
  </build>
</project>
visxu commented 3 weeks ago

@qmonmert Hi, you can define your ${pulsar.version} property in pom.xml, it works. Hope it helps.

image

KO ❌

image

OK ✅

lhotari commented 3 weeks ago

here my pom.xml which is working on version 3.3.1 of pulsar but not after

@qmonmert Would you be able to share a complete reproducer app that I could checkout and use for reproducing the issue on my side? That would be helpful in addressing this issue. Thanks!

qmonmert commented 3 weeks ago

@lhotari we used now spring-boot-starter-pulsar you can see the PR https://github.com/jhipster/jhipster-lite/pull/11210

I pushed an example of pulsar app generated by https://github.com/jhipster/jhipster-lite on my github https://github.com/qmonmert/pulsarapp

You can remove (in pom.xml)

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-pulsar</artifactId>
</dependency>

and replace by

<dependency>
  <groupId>org.apache.pulsar</groupId>
  <artifactId>pulsar-client</artifactId>
  <version>${pulsar.version}</version>
</dependency>

and add

<pulsar.version>4.0.0</pulsar.version>

to reproduce the bug

cc @pascalgrimaud