Skip to content

Commit cfd2c9a

Browse files
cryptobenchclaude
andcommitted
Fix ServiceLoader classloader issue for plugin environments
Set thread context classloader before creating ACME Session so ServiceLoader can find providers in the plugin JAR. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent bb4ff63 commit cfd2c9a

File tree

19 files changed

+123
-6
lines changed

19 files changed

+123
-6
lines changed

dependency-reduced-pom.xml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.easywebmap</groupId>
5+
<artifactId>EasyWebMap</artifactId>
6+
<name>EasyWebMap</name>
7+
<version>1.0.0</version>
8+
<description>Live web map viewer for Hytale servers</description>
9+
<build>
10+
<resources>
11+
<resource>
12+
<filtering>true</filtering>
13+
<directory>src/main/resources</directory>
14+
</resource>
15+
</resources>
16+
<plugins>
17+
<plugin>
18+
<artifactId>maven-compiler-plugin</artifactId>
19+
<version>3.11.0</version>
20+
<configuration>
21+
<source>25</source>
22+
<target>25</target>
23+
</configuration>
24+
</plugin>
25+
<plugin>
26+
<artifactId>maven-jar-plugin</artifactId>
27+
<version>3.3.0</version>
28+
<configuration>
29+
<archive>
30+
<manifest>
31+
<mainClass>com.easywebmap.EasyWebMap</mainClass>
32+
</manifest>
33+
</archive>
34+
</configuration>
35+
</plugin>
36+
<plugin>
37+
<artifactId>maven-shade-plugin</artifactId>
38+
<version>3.6.1</version>
39+
<executions>
40+
<execution>
41+
<phase>package</phase>
42+
<goals>
43+
<goal>shade</goal>
44+
</goals>
45+
<configuration>
46+
<relocations>
47+
<relocation>
48+
<pattern>org.bouncycastle</pattern>
49+
<shadedPattern>com.easywebmap.shaded.bouncycastle</shadedPattern>
50+
</relocation>
51+
<relocation>
52+
<pattern>org.jose4j</pattern>
53+
<shadedPattern>com.easywebmap.shaded.jose4j</shadedPattern>
54+
</relocation>
55+
</relocations>
56+
<filters>
57+
<filter>
58+
<artifact>*:*</artifact>
59+
<excludes>
60+
<exclude>META-INF/*.SF</exclude>
61+
<exclude>META-INF/*.DSA</exclude>
62+
<exclude>META-INF/*.RSA</exclude>
63+
</excludes>
64+
</filter>
65+
</filters>
66+
<transformers>
67+
<transformer />
68+
</transformers>
69+
</configuration>
70+
</execution>
71+
</executions>
72+
</plugin>
73+
</plugins>
74+
</build>
75+
<dependencies>
76+
<dependency>
77+
<groupId>com.google.code.gson</groupId>
78+
<artifactId>gson</artifactId>
79+
<version>2.10.1</version>
80+
<scope>provided</scope>
81+
</dependency>
82+
<dependency>
83+
<groupId>com.google.code.findbugs</groupId>
84+
<artifactId>jsr305</artifactId>
85+
<version>3.0.2</version>
86+
<scope>provided</scope>
87+
</dependency>
88+
<dependency>
89+
<groupId>com.hypixel.hytale</groupId>
90+
<artifactId>HytaleServer</artifactId>
91+
<version>1.0.0</version>
92+
<scope>system</scope>
93+
<systemPath>${hytale.server.path}</systemPath>
94+
</dependency>
95+
</dependencies>
96+
<properties>
97+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
98+
<maven.compiler.target>25</maven.compiler.target>
99+
<hytale.server.path>${project.basedir}/lib/HytaleServer.jar</hytale.server.path>
100+
<maven.compiler.source>25</maven.compiler.source>
101+
</properties>
102+
</project>

src/main/java/com/easywebmap/ssl/AcmeManager.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,16 @@ private boolean obtainCertificate() {
104104
KeyPair domainKeyPair = loadOrCreateKeyPair(domainKeyFile);
105105

106106
String acmeUrl = plugin.getConfig().isProductionAcme() ? PRODUCTION_URL : STAGING_URL;
107-
Session session = new Session(acmeUrl);
107+
108+
// Set context classloader so ServiceLoader can find ACME providers in plugin JAR
109+
ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
110+
Thread.currentThread().setContextClassLoader(AcmeManager.class.getClassLoader());
111+
Session session;
112+
try {
113+
session = new Session(acmeUrl);
114+
} finally {
115+
Thread.currentThread().setContextClassLoader(originalClassLoader);
116+
}
108117

109118
Account account = findOrRegisterAccount(session, accountKeyPair);
110119
System.out.println("[EasyWebMap] ACME account ready");

target/EasyWebMap-1.0.0.jar

9.99 MB
Binary file not shown.
1.85 KB
Binary file not shown.
5.89 KB
Binary file not shown.
504 Bytes
Binary file not shown.
1.79 KB
Binary file not shown.
7.08 KB
Binary file not shown.
Binary file not shown.
5.77 KB
Binary file not shown.

0 commit comments

Comments
 (0)