eclipse-tycho / tycho

Tycho project repository (tycho)
https://tycho.eclipseprojects.io
Eclipse Public License 2.0
170 stars 189 forks source link

java.lang.NoClassDefFoundError: org/eclipse/jgit/internal/JGitText #3489

Closed rgrunber closed 4 weeks ago

rgrunber commented 8 months ago

I recently started seeing the following error in our Maven builds that use Tycho. There's not much info in the stacktrace and I couldn't find any references to JGitText in Tycho, so I thought it might have been a Jenkins plugin issue, but I see the error in GitHub Actions also. It doesn't appear to be harmful.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  02:09 min
[INFO] Finished at: 2024-01-30T08:06:00Z
[INFO] ------------------------------------------------------------------------
Error: Exception in thread "Thread-4" java.lang.NoClassDefFoundError: org/eclipse/jgit/internal/JGitText
    at org.eclipse.jgit.internal.util.ShutdownHook.cleanup(ShutdownHook.java:85)
    at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jgit.internal.JGitText
    ... 2 more

https://github.com/redhat-developer/vscode-java/actions/runs/7708013160

We run builds on every new change, and the first one from last week where this started happening was on the bump from 4.0.4 to 4.0.5.

I've seen it in JDT UI main builds : https://ci.eclipse.org/jdt/job/eclipse.jdt.ui-github/job/master/12/console

However, there's also similar builds of the same project on Jenkins where the issue doesn't occur : https://ci.eclipse.org/ls/job/jdt-ls-master/1956/console

laeubi commented 8 months ago

@rgrunber this is due to jgit registering a shutdownhook but never unregister it, then when it is finally executed (maven build terminates) "something" went wrong but the text can't be loaded as the classloader is gone, so this is actually leaking.

i have already described it here in more details:

so unless there is a fix in JGit and a new release there is sadly nothing much we can do about it.

rgrunber commented 8 months ago

Thanks for the reference. Feel free to close unless you'd rather track it.

mickaelistria commented 7 months ago

@laeubi is there an issue open to JGit about the root bug?

laeubi commented 7 months ago

Not that I'm aware of, JGit wants me to fill a huge Issue template and last time I tried to contribute said they are not using Github for contributions so I kind of gave up on this. I really don't want this old Bugzilla/Gerrit "feeling" back ;-)

But if you like you can open one and then link it here.

mickaelistria commented 7 months ago

I submitted https://github.com/eclipse-jgit/jgit/issues/36 to JGit. (@laeubi it was not that much of a big issue template, it wasn't taking much more time to fill it than to fill a freetext)

laeubi commented 7 months ago

@mickaelistria it seems now we have the text printed, but jgit now just fails earlier:

https://ci.eclipse.org/tycho/job/tycho-github/job/PR-3557/1/testReport/junit/org.eclipse.tycho.test.buildextension/CiFriendlyVersionsTest/testJgitBuildQualifier/

mickaelistria commented 7 months ago

jgit now just fails earlier

It's probably even worse ;) Can we consider adding a catch clause somewhere in Tycho to ignore this failure and turn it into a log line?

laeubi commented 7 months ago

As this more seem to originate from Maven I think no... I initially assumed it was a problem with the internal OSGi framework but think its more generally a problem when the classloader is disposed as @tomaswolf explained here, in general a Shutdownhook must be used with care and I think JGit is using them wrong as described at https://docs.oracle.com/javase/8/docs/technotes/guides/lang/hook-design.html one should simply cancel a hook when it is no longer needed instead of it lingering around forever.

mickaelistria commented 7 months ago

Is it already possible to leverage the JGit fix in Tycho?

laeubi commented 7 months ago

If it is released to maven central somewhere (or a snapshot repo) it should be possible to add an additional <dependency> element to the jgit timestamp provider.

tomaswolf commented 7 months ago

The JGit snapshot maven repo is https://repo.eclipse.org/content/repositories/jgit-snapshots .

fbricon commented 3 months ago

The JGit bug fix is available in 6.10.0, released last month.

sratz commented 4 weeks ago

Fixed in 5.0.0-SNAPSHOT (via #3994) and 4.0.9 (via #3966)