lizhimins opened a new pull request, #6344:
URL: https://github.com/apache/rocketmq-dashboard/pull/6344

   `mysql-connector-j` is excluded from the fat JAR (`server/pom.xml:198-203`, 
GPL / ASF Category X) and downloaded into `/app/lib` at image build time, with 
`ENV LOADER_PATH=/app/lib` meant to put it on the classpath. That never 
happened: `ENTRYPOINT ["java", "-jar", "app.jar"]` runs the JAR's `Main-Class`, 
which `spring-boot-maven-plugin` writes as 
`org.springframework.boot.loader.launch.JarLauncher`, and `JarLauncher` does 
not read `LOADER_PATH` — only `PropertiesLauncher` does.
   
   So every image built from this Dockerfile since the connector was moved out 
of the JAR fails at startup:
   
   ```
   Caused by: java.lang.IllegalStateException: Cannot load driver class: 
com.mysql.cj.jdbc.Driver
        at 
org.springframework.boot.jdbc.autoconfigure.DataSourceProperties.findDriverClassName(DataSourceProperties.java:187)
   ```
   
   Verified against a built image before changing anything:
   
   ```
   $ python3 - <<'PY'   # inside rocketmq-server:latest
   Main-Class: org.springframework.boot.loader.launch.JarLauncher
   PropertiesLauncher present: 
['org/springframework/boot/loader/launch/PropertiesLauncher.class']
   mysql in BOOT-INF/lib: []          # the connector is only in /app/lib
   $ ls /app/lib
   mysql-connector-j-9.7.0.jar
   ```
   
   and launching that same image through `PropertiesLauncher` gets past the 
driver and into the pool:
   
   ```
   com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
   ```
   
   The fix keeps `java -cp app.jar ... PropertiesLauncher`, which resolves the 
nested `BOOT-INF/classes` and `BOOT-INF/lib` exactly as `JarLauncher` did and 
additionally honours `loader.path`. `-Dloader.path` is passed explicitly rather 
than relying on the `LOADER_PATH` env var, so the entrypoint still works if the 
variable is dropped; the env var is left in place because `docker-compose` 
deployments may set it.
   
   Nothing else invokes the JAR: `deploy/docker-compose.yml`'s only `command:` 
override belongs to the `mysql` service, and both runtime stages 
(`runtime-prebuilt`, `runtime`) inherit this entrypoint from `runtime-base`.
   
   Confirmed working end to end on a full deploy of `21d09842f` with this 
patch: container reaches `healthy`, `actuator/health` returns `UP`, and 
authenticated `/api/instances` and `/api/clusters` return rows from MySQL.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to