jodconverter / jodconverter

JODConverter automates document conversions using LibreOffice or Apache OpenOffice.
https://github.com/jodconverter/jodconverter
Other
1.42k stars 288 forks source link

Not working with quartz? #368

Open MingNiu opened 10 months ago

MingNiu commented 10 months ago

Spring Boot 2.7.18 Gradle 7.6.3 JDK 17

Gradle config:

image image image

project start error:

Caused by: java.lang.AbstractMethodError: Receiver class com.zaxxer.hikari.metrics.micrometer.MicrometerMetricsTrackerFactory does not define or inherit an implementation of the resolved method 'abstract com.zaxxer.hikari.metrics.MetricsTracker create(java.lang.String, com.zaxxer.hikari.metrics.PoolStats)' of interface com.zaxxer.hikari.metrics.MetricsTrackerFactory.
    at com.zaxxer.hikari.pool.HikariPool.setMetricsTrackerFactory(HikariPool.java:273) ~[HikariCP-java7-2.4.13.jar:na]
    at com.zaxxer.hikari.HikariDataSource.setMetricsTrackerFactory(HikariDataSource.java:243) ~[HikariCP-java7-2.4.13.jar:na]
    at org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration$HikariDataSourceMetricsConfiguration$HikariDataSourceMeterBinder.bindMetricsRegistryToHikariDataSource(DataSourcePoolMetricsAutoConfiguration.java:153) ~[spring-boot-actuator-autoconfigure-2.7.18.jar:2.7.18]
    at org.springframework.boot.actuate.autoconfigure.metrics.jdbc.DataSourcePoolMetricsAutoConfiguration$HikariDataSourceMetricsConfiguration$HikariDataSourceMeterBinder.bindTo(DataSourcePoolMetricsAutoConfiguration.java:145) ~[spring-boot-actuator-autoconfigure-2.7.18.jar:2.7.18]
    at org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryConfigurer.lambda$addBinders$1(MeterRegistryConfigurer.java:87) ~[spring-boot-actuator-autoconfigure-2.7.18.jar:2.7.18]
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:na]
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) ~[na:na]
    at java.base/java.util.stream.SortedOps$RefSortingSink.end(SortedOps.java:395) ~[na:na]
    at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
    at java.base/java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[na:na]
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[na:na]
    at org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryConfigurer.addBinders(MeterRegistryConfigurer.java:87) ~[spring-boot-actuator-autoconfigure-2.7.18.jar:2.7.18]
    at org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryConfigurer.configure(MeterRegistryConfigurer.java:68) ~[spring-boot-actuator-autoconfigure-2.7.18.jar:2.7.18]
    at org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryPostProcessor.postProcessAfterInitialization(MeterRegistryPostProcessor.java:64) ~[spring-boot-actuator-autoconfigure-2.7.18.jar:2.7.18]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:455) ~[spring-beans-5.3.31.jar:5.3.31]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1808) ~[spring-beans-5.3.31.jar:5.3.31]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.31.jar:5.3.31]
    ... 70 common frames omitted

project dependencies tree:

image

Why does quartz use HikariCP-java7 after introducing the jodConvertor dependency?

MingNiu commented 10 months ago

I'm trying to solve the problem.

Any help?

solution one:

image

solution two:

image
sbraconnier commented 10 months ago

I'm not sure this have anything to do with jodconverter, which doesn't use quartz, nor HikariCP.

Can you share your whole dependency tree with and without the jodconverter dependency?

Thanks.

MingNiu commented 10 months ago

with_jodconverter.txt without_jodconverter.txt

sbraconnier commented 10 months ago

I wasn't able to reproduce your issue with a minimal project. I don't see HikariCP-java7 dependency in my dependency tree and the application starts without problem. I'm using gradle 8.4 tho. My build.gradle.kts file is:

plugins {
    kotlin("jvm") version "1.9.21"
    id("org.springframework.boot") version "2.7.18"
}

group = "org.example"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    implementation(platform("org.springframework.boot:spring-boot-dependencies:2.7.18"))

    implementation("org.jodconverter:jodconverter-spring-boot-starter:4.4.7")
    implementation("org.jodconverter:jodconverter-remote:4.4.7")

    implementation("org.springframework.boot:spring-boot-starter-quartz")

    implementation("org.springframework.boot:spring-boot-starter-actuator")
    implementation("io.micrometer:micrometer-registry-prometheus")
}

tasks.test {
    useJUnitPlatform()
}

kotlin {
    jvmToolchain(17)
}

You probably have another dependency causing this. Can you share your whole dependency config from your gradle file?

MingNiu commented 9 months ago

This problem occurs when using spring dependency management plugin.

springDependencyManagementVersion=1.0.15.RELEASE

image
sbraconnier commented 9 months ago

Then you seem to be hitting this reported issue

It's supposed to be fixed witrh the version you are using tho so I'm not sure why you still have this problem ??... Maybe try to clear your project/gradle/maven cache.

On my end, I don't have this problem (the application starts successfully) using this minimal configuration:

plugins {
    id("java")
    id("idea")
    id("org.jetbrains.kotlin.jvm") version "1.9.21"
    id("org.jetbrains.kotlin.plugin.spring") version "1.9.21"
    id("org.springframework.boot") version "2.7.18"
    id("io.spring.dependency-management") version "1.0.15.RELEASE"
}

kotlin {
    jvmToolchain(17)
}

repositories {
    mavenCentral()
}

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-quartz")
    implementation("org.springframework.boot:spring-boot-starter-data-jpa")

    implementation("org.jodconverter:jodconverter-spring-boot-starter:4.4.7")
    implementation("org.jodconverter:jodconverter-remote:4.4.7")

    runtimeOnly("com.h2database:h2")
}

Here's my logs:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::               (v2.7.18)

2024-02-26 09:54:51.698  INFO 9408 --- [           main] org.example.MainKt                       : Starting MainKt using Java 17.0.9
2024-02-26 09:54:51.701  INFO 9408 --- [           main] org.example.MainKt                       : No active profile set, falling back to 1 default profile: "default"
2024-02-26 09:54:52.333  INFO 9408 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2024-02-26 09:54:52.352  INFO 9408 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 6 ms. Found 0 JPA repository interfaces.
2024-02-26 09:54:52.973  INFO 9408 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2024-02-26 09:54:53.255  INFO 9408 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2024-02-26 09:54:53.323  INFO 9408 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2024-02-26 09:54:53.416  INFO 9408 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.6.15.Final
2024-02-26 09:54:53.674  INFO 9408 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2024-02-26 09:54:53.896  INFO 9408 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2024-02-26 09:54:54.217  INFO 9408 --- [           main] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2024-02-26 09:54:54.232  INFO 9408 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2024-02-26 09:54:54.479  INFO 9408 --- [           main] org.quartz.impl.StdSchedulerFactory      : Using default implementation for ThreadExecutor
2024-02-26 09:54:54.494  INFO 9408 --- [           main] org.quartz.core.SchedulerSignalerImpl    : Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
2024-02-26 09:54:54.494  INFO 9408 --- [           main] org.quartz.core.QuartzScheduler          : Quartz Scheduler v.2.3.2 created.
2024-02-26 09:54:54.495  INFO 9408 --- [           main] org.quartz.simpl.RAMJobStore             : RAMJobStore initialized.
2024-02-26 09:54:54.496  INFO 9408 --- [           main] org.quartz.core.QuartzScheduler          : Scheduler meta-data: Quartz Scheduler (v2.3.2) 'quartzScheduler' with instanceId 'NON_CLUSTERED'
  Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
  NOT STARTED.
  Currently in standby mode.
  Number of jobs executed: 0
  Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
  Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.

2024-02-26 09:54:54.496  INFO 9408 --- [           main] org.quartz.impl.StdSchedulerFactory      : Quartz scheduler 'quartzScheduler' initialized from an externally provided properties instance.
2024-02-26 09:54:54.496  INFO 9408 --- [           main] org.quartz.impl.StdSchedulerFactory      : Quartz scheduler version: 2.3.2
2024-02-26 09:54:54.496  INFO 9408 --- [           main] org.quartz.core.QuartzScheduler          : JobFactory set to: org.springframework.scheduling.quartz.SpringBeanJobFactory@c9b5a99
2024-02-26 09:54:54.529  INFO 9408 --- [           main] o.s.s.quartz.SchedulerFactoryBean        : Starting Quartz Scheduler now
2024-02-26 09:54:54.529  INFO 9408 --- [           main] org.quartz.core.QuartzScheduler          : Scheduler quartzScheduler_$_NON_CLUSTERED started.
2024-02-26 09:54:54.542  INFO 9408 --- [           main] org.example.MainKt                       : Started MainKt in 3.518 seconds (JVM running for 4.116)
MingNiu commented 9 months ago
image

jetbrains: https://www.jetbrains.com/help/idea/2023.3/run-debug-configuration-spring-boot.html#logs

image

Idea classpath:

image

gradle bootRun classpath:

image

quartz pom:

image

When I removed jodconverter dependency, the problem disappeared. It's so strange... There must be something that makes HikariCP-java7 "provided" scope.

sbraconnier commented 9 months ago

Well, I only have the community edition of Intellij, so I can't test with the spring boot Run/Debug configuration you are using.

My tests work using the regular Run/Debug configuration or using the gradle bootRun task:

Command line: gradlew bootRun

Can you test that ? If it works, then the problem is with the spring boot plugin for intellij.

Also, please invalidate your cache (Menu File->Invalidate Caches...) before executing your test.

MingNiu commented 9 months ago

“gradlew bootRun” works. Idea Ultimate Run/Debug configuration without "Add dependencies with provided scope to classpath" works. Idea community edition works.

sbraconnier commented 9 months ago

Well that is very strange indeed. The spring-boot BOM is added as a platform implementation to every jodconverter java projects, but I cannot understand why this would impact your build/run:

dependencies {
    implementation platform("org.springframework.boot:spring-boot-dependencies:2.7.18")
}

I cannot work on this without the Ultimate intellij license. Maybe ask them (the intellij team) about this problem with the information you have. I'll try to apply for a free license but I'm not sure the jodconverter project qualifies according to their rules. I should make my local sandbox public in order to qualifies for the "at least one commit a month". I code a lot to anwser people questions!!

MingNiu commented 9 months ago

Answer from intellij Team: https://youtrack.jetbrains.com/issue/IDEA-348142/Add-dependencies-with-provided-scope-to-classpath-breaks-the-classpath

sbraconnier commented 9 months ago

Wow! Thanks you to have reported this to their team and for the feedback here!! It seems they will fix it on their end!

MingNiu commented 9 months ago

Thank you very much for your help,. Hope they fix this soon.