No thread context classloader when invoking server main, breaks ServiceLoader lookups (javax.script on Purpur)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 24
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
Booting Purpur 1.21.7 with tack 0.1.1-beta (source build) dies while
loading the world. Purpur gets null back from its javax.script
lookup (Rhino), so Entity.scriptEngine is null. Same jar works
fine under plain java and under Paperclip.
Env: Debian hosts, server runs in Docker on
amazoncorretto:26-al2023 (glibc, tack needs it).
tack invokes main on a JNI-attached thread without setting a
context classloader first, so ServiceLoader falls back to
bootstrap and never sees the app classpath. Setting it before
the call, the way Paperclip does, fixes it. The snippet below
is what we run in exec_jvm (src/launcher.rs), right before
the main_class lookup, on 11 prod servers since late August:
let system_loader = env
.call_static_method(
jni_str!("java/lang/ClassLoader"),
jni_str!("getSystemClassLoader"),
jni_sig!("()Ljava/lang/ClassLoader;"),
&[],
)?
.l()
.into_error()?;
let current_thread = env
.call_static_method(
jni_str!("java/lang/Thread"),
jni_str!("currentThread"),
jni_sig!("()Ljava/lang/Thread;"),
&[],
)?
.l()
.into_error()?;
env.call_method(
¤t_thread,
jni_str!("setContextClassLoader"),
jni_sig!("(Ljava/lang/ClassLoader;)V"),
&[JValue::Object(&system_loader)],
)?;
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/launcher.rs at the exec_jvm entry point and inspect the JNI thread setup immediately before the main_class lookup. Reproduce the reported Purpur/Rhino ServiceLoader failure if possible; done means Purpur receives a working javax.script engine when launched through tack.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100