<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif;color:#20124d">I stopped looking for the cause of the NoClassDefFoundError, and trapped it as you advised.</div><div class="gmail_default" style="font-family:georgia,serif;color:#20124d"><br></div><div class="gmail_default" style="font-family:georgia,serif;color:#20124d">I generated a local 15.4.1 on our artifactory, and it works – as intended.<br>Not commiting anything on your github of course.</div><div class="gmail_default" style="font-family:georgia,serif;color:#20124d"><br></div><div class="gmail_default" style="font-family:georgia,serif;color:#20124d">Thank you very much!</div><div class="gmail_default" style="font-family:georgia,serif;color:#20124d"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 25 janv. 2024 à 10:45, Luc Chapon <<a href="mailto:sxilderik@gmail.com">sxilderik@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div>Thanks ! </div><div dir="auto"><br></div><div dir="auto">The fact is, the same war and same jvm work fine with Tomcat. And that is puzzling us. </div><div><br></div><div>Message envoyé d'un téléphone portable. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 24 janv. 2024 à 21:29, Attila Szegedi <<a href="mailto:szegedia@gmail.com" target="_blank">szegedia@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Hm… Are you using the Java module system? Or is this Wildfly otherwise messing with class loading? If loaded through the Java module system, Nashorn should have no problem accessing sun.misc.Unsafe as it <a href="https://github.com/openjdk/nashorn/blob/main/src/org.openjdk.nashorn/share/classes/module-info.java#L145C5-L145C30" rel="noreferrer" target="_blank">properly declares</a> “require jdk.unsupported”. It does look like it might be somehow bundled in a WAR file though. Maybe that repackages it somehow?<div><br></div><div>If you’re intent on “emergency” modifying your copy of Nashorn, I'd add another catch clause at <a href="https://github.com/openjdk/nashorn/blob/main/src/org.openjdk.nashorn/share/classes/org/openjdk/nashorn/internal/runtime/Context.java#L338" rel="noreferrer" target="_blank">Context.java:338</a> like<div><br></div><div>catch(NoClassDefFoundError e) {</div><div> initFailure = new RuntimeException(e);</div><div> return null;</div><div>}</div><div><div><br></div><div>Although I’d be curious to know more about this error and circumstances under which it occurs. I’d be happy to try to debug it if you could give me a small reproducer. Alternatively, you could also run the java process with -verbose:class but it might not give us many clues.</div><div><br></div><div>Attila.</div><div><br><div><div><blockquote type="cite"><div>On 2024. Jan 24., at 18:55, Luc Chapon <<a href="mailto:sxilderik@gmail.com" rel="noreferrer" target="_blank">sxilderik@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">This is my StackTrace.</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">Since the line shown is the one trying to load a non existent method, I assumed that was the problem.</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">The Exception seems to be NoClassDefFoundError instead…</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><br></div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">The environement is Wildfly 30 / jdk 17</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><br></div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><div style="padding:0px 0px 0px 2px"><div style="font-family:Consolas;font-size:10pt;white-space:pre-wrap"><div style="margin:0px">18:31:00,119 ERROR [io.undertow.request] (default task-2) UT005023: Exception handling request to /HNS/HNSAdmin/query.pilot: java.lang.NoClassDefFoundError: sun/misc/Unsafe</div><div style="margin:0px"> at deployment.HNS.war//org.openjdk.nashorn.internal.runtime.Context$AnonymousContextCodeInstaller.lambda$getDefineAnonymousClass$0(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">Context.java:330</span>)</div><div style="margin:0px"> at java.base/java.security.AccessController.doPrivileged(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">AccessController.java:318</span>)</div><div style="margin:0px"> at deployment.HNS.war//org.openjdk.nashorn.internal.runtime.Context$AnonymousContextCodeInstaller.getDefineAnonymousClass(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">Context.java:328</span>)</div><div style="margin:0px"> at deployment.HNS.war//org.openjdk.nashorn.internal.runtime.Context$AnonymousContextCodeInstaller.<clinit>(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">Context.java:317</span>)</div><div style="margin:0px"> at deployment.HNS.war//org.openjdk.nashorn.internal.runtime.Context.lambda$compile$9(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">Context.java:1506</span>)</div><div style="margin:0px"> at deployment.HNS.war//org.openjdk.nashorn.internal.runtime.ScriptEnvironment.useAnonymousClasses(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">ScriptEnvironment.java:491</span>)</div><div style="margin:0px"> at deployment.HNS.war//org.openjdk.nashorn.internal.runtime.Context.compile(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">Context.java:1506</span>)</div><div style="margin:0px"> at deployment.HNS.war//org.openjdk.nashorn.internal.runtime.Context.compileScript(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">Context.java:1451</span>)</div><div style="margin:0px"> at deployment.HNS.war//org.openjdk.nashorn.internal.runtime.Context.compileScript(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">Context.java:761</span>)</div><div style="margin:0px"> at deployment.HNS.war//org.openjdk.nashorn.api.scripting.NashornScriptEngine.compileImpl(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">NashornScriptEngine.java:528</span>)</div><div style="margin:0px"> at deployment.HNS.war//org.openjdk.nashorn.api.scripting.NashornScriptEngine.compileImpl(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">NashornScriptEngine.java:517</span>)</div><div style="margin:0px"> at deployment.HNS.war//org.openjdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">NashornScriptEngine.java:395</span>)</div><div style="margin:0px"> at deployment.HNS.war//org.openjdk.nashorn.api.scripting.NashornScriptEngine.eval(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">NashornScriptEngine.java:151</span>)</div><div style="margin:0px"> at java.scripting/javax.script.AbstractScriptEngine.eval(<span style="color:rgb(0,102,204);text-decoration-line:underline;text-decoration-style:solid">AbstractScriptEngine.java:262</span>)</div><div style="margin:0px"><br></div><p style="margin:0px"></p></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mer. 24 janv. 2024 à 18:20, Attila Szegedi <<a href="mailto:szegedia@gmail.com" rel="noreferrer" target="_blank">szegedia@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Hi!<div><br></div><div>Are you experiencing this with Nashorn 15.4 from <a href="https://github.com/openjdk/nashorn" rel="noreferrer" target="_blank">https://github.com/openjdk/nashorn</a>? This issue is supposed to have been fixed since Nashorn 15.3 in this change <a href="https://github.com/openjdk/nashorn/pull/16" rel="noreferrer" target="_blank">https://github.com/openjdk/nashorn/pull/16</a> according to the changelog: <a href="https://github.com/openjdk/nashorn/blob/main/CHANGELOG.md" rel="noreferrer" target="_blank">https://github.com/openjdk/nashorn/blob/main/CHANGELOG.md</a></div><div><br></div><div>You say it fails, but it’s encased in a try-catch specifically for this reason. Can you give me a stack trace of how it fails?</div><div><br></div><div>Attila.</div><div><br><div><br><blockquote type="cite"><div>On 2024. Jan 24., at 13:02, Luc Chapon <<a href="mailto:sxilderik@gmail.com" rel="noreferrer" target="_blank">sxilderik@gmail.com</a>> wrote:</div><br><div><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">Hello all</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><br></div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">First message here</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><br></div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">We are facing a problem re Nashorn (latest) and java17</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><br></div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">In Context.java, line 330, you try to get a handle to a no longer existent method, Unsafe.defineAnonymousClass</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><br></div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">And fail of course.</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><br></div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">I’m trying to rewrite this part for our own temporary urgent need according to this.<br><br><a href="https://www.oracle.com/java/technologies/javase/17-relnote-issues.html" rel="noreferrer" target="_blank">https://www.oracle.com/java/technologies/javase/17-relnote-issues.html</a><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><div style="box-sizing:border-box;margin:0px;padding:0px;list-style:none;background-repeat:no-repeat;font-family:OracleSansVF,OracleSansVFCyGr,OracleSansFB,-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",sans-serif;font-size:14.63px;background-color:rgb(251,249,248)">core-libs</div></div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><b style="box-sizing:border-box;margin:0px;padding:0px;list-style:none;background-repeat:no-repeat;font-family:OracleSansVF,OracleSansVFCyGr,OracleSansFB,-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",sans-serif;font-size:14.63px;background-color:rgb(251,249,248)"><a href="https://www.oracle.com/java/technologies/javase/17-relnote-issues.html#JDK-8243287" style="box-sizing:border-box;margin:0px;padding:0px;list-style:none;background-repeat:no-repeat;color:rgb(0,107,143);text-decoration-line:none" rel="noreferrer" target="_blank"><span style="box-sizing:border-box;margin:0px;padding:0px;list-style:none;background-repeat:no-repeat">➜</span></a> Removal of sun.misc.Unsafe::defineAnonymousClass</b></div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><p style="box-sizing:border-box;margin:0px 0px 1.1em;padding:0px;list-style:none;background-repeat:no-repeat;line-height:1.55;font-family:OracleSansVF,OracleSansVFCyGr,OracleSansFB,-apple-system,BlinkMacSystemFont,"Segoe UI","Helvetica Neue",sans-serif;font-size:14.63px;background-color:rgb(251,249,248)"><code style="box-sizing:border-box;margin:0px;padding:0px;list-style:none;background-repeat:no-repeat">sun.misc.Unsafe::defineAnonymousClass</code> API has been removed in JDK 17. The API replacement is <code style="box-sizing:border-box;margin:0px;padding:0px;list-style:none;background-repeat:no-repeat">java.lang.invoke.MethodHandles.Lookup::defineHiddenClass</code> and <code style="box-sizing:border-box;margin:0px;padding:0px;list-style:none;background-repeat:no-repeat">java.lang.invoke.MethodHandles.Lookup::defineHiddenClassWithClassData</code>.</p></div></blockquote><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><br></div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">Are you aware of the problem? Is there a fix already available?</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><br></div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">Thank you!</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><br></div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">Luc Chapon</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">ChapsVision</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)">Suresnes, France</div><div class="gmail_default" style="font-family:georgia,serif;color:rgb(32,18,77)"><br></div></div>
</div></blockquote></div><br></div></div></blockquote></div>
</div></blockquote></div><br></div></div></div></div></div></blockquote></div>
</blockquote></div>