Modify

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#22183 closed defect (fixed)

NoClassDefFoundError: Could not initialize class org.openstreetmap.josm.actions.SessionSaveAction

Reported by: anonymous Owned by: anonymous
Priority: major Milestone: 22.09
Component: Core Version:
Keywords: template_report Cc: michel.lethiec@…, OMNIBUS, nelson.canhoto92@…, Klumbumbus

Description

What steps will reproduce the problem?

What is the expected result?

What happens instead?

Please provide any additional information below. Attach a screenshot if possible.

Build-Date:2022-06-17 19:35:03
Revision:18495
Is-Local-Build:true

Identification: JOSM/1.5 (18495 SVN fr) Linux Ubuntu 18.04.6 LTS
Memory Usage: 109 MB / 1820 MB (73 MB allocated, but free)
Java version: 1.8.0_301-b09, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
Look and Feel: javax.swing.plaf.metal.MetalLookAndFeel
Screen: :0.0 1920×1080 (scaling 1.00×1.00)
Maximum Screen Size: 1920×1080
Best cursor sizes: 16×16→16×16, 32×32→32×32
Environment variable LANG: fr_FR.UTF-8
System property file.encoding: UTF-8
System property sun.jnu.encoding: UTF-8
Locale info: fr_FR
Numbers with default locale: 1234567890 -> 1234567890
Desktop environment: GNOME-Flashback:GNOME
fonts-noto: fonts-noto:-

Plugins:
+ apache-commons
+ cadastre-fr
+ ejml
+ geotools
+ jaxb (35952)
+ jts
+ log4j (35924)
+ reverter
+ routing

Last errors/warnings:
- 00017.692 E: Exception raised in EDT: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError. Cause : java.lang.ExceptionInInitializerError. Cause : java.lang.NullPointerException
- 00025.266 W: Version principale du greffon gpsbabelgui manquante.
- 00029.674 W: Version principale du greffon gpsbabelgui manquante.
- 00032.262 W: Version principale du greffon gpsbabelgui manquante.
- 00033.717 E: Handled by bug report queue: java.lang.NoClassDefFoundError: Could not initialize class org.openstreetmap.josm.actions.SessionSaveAction

OSM API: http://www.openstreetmap.org/api


=== REPORTED CRASH DATA ===
BugReportExceptionHandler#handleException:
No data collected.

Warning issued by: BugReportExceptionHandler#handleException

=== STACK TRACE ===
Thread: main (1)
java.lang.NoClassDefFoundError: Could not initialize class org.openstreetmap.josm.actions.SessionSaveAction
	at org.openstreetmap.josm.gui.MainMenu.<init>(MainMenu.java:181)
	at org.openstreetmap.josm.gui.MainFrame.initialize(MainFrame.java:93)
	at org.openstreetmap.josm.gui.MainApplication.initializeMainWindow(MainApplication.java:415)
	at org.openstreetmap.josm.spi.lifecycle.InitializationTask.call(InitializationTask.java:33)
	at org.openstreetmap.josm.spi.lifecycle.Lifecycle.runInitializationTasks(Lifecycle.java:103)
	at org.openstreetmap.josm.spi.lifecycle.Lifecycle.initialize(Lifecycle.java:71)
	at org.openstreetmap.josm.gui.MainApplication.mainJOSM(MainApplication.java:953)
	at org.openstreetmap.josm.gui.MainApplication$3.processArguments(MainApplication.java:277)
	at org.openstreetmap.josm.gui.MainApplication.main(MainApplication.java:741)

Attachments (2)

22183.patch (11.3 KB ) - added by taylor.smock 2 years ago.
Better reporting of suppressed/ignored exceptions in EDT and worker threads
22183.1.patch (1.6 KB ) - added by taylor.smock 2 years ago.
Use synchronization to wait for non-null contentPanePrivate. Not ideal (due to synchronization), but should be safe.

Download all attachments as: .zip

Change History (60)

comment:1 by GerdP, 2 years ago

Did you build JOSM on your own? If yes, try again with
ant clean dist

comment:2 by GerdP, 2 years ago

Owner: changed from team to anonymous
Status: newneedinfo

comment:3 by skyper, 2 years ago

Summary: josm crashed at startupNoClassDefFoundError: Could not initialize class org.openstreetmap.josm.actions.SessionSaveAction

Similar #22205 and #22221.

Last edited 2 years ago by skyper (previous) (diff)

comment:4 by taylor.smock, 2 years ago

Ticket #22244 has been marked as a duplicate of this ticket.

FTR:

- 00000.954 E: Exception raised in EDT: java.util.concurrent.ExecutionException: java.lang.ExceptionInInitializerError. Ursache: java.lang.ExceptionInInitializerError. Ursache: java.lang.NullPointerException: Cannot invoke "javax.swing.JComponent.getInputMap(int)" because "org.openstreetmap.josm.gui.MainApplication.contentPanePrivate" is null

We probably ought to be opening the bug report ticket for the ExecutionException.

Last edited 2 years ago by taylor.smock (previous) (diff)

comment:5 by taylor.smock, 2 years ago

Ticket #22205 has been marked as a duplicate of this ticket.

comment:6 by taylor.smock, 2 years ago

For those running into this problem, can you please run JOSM with the --trace option (on Ubuntu Linux, josm --trace).

Please note that --trace may expose sensitive information (specifically login information for various services, like OSM), so please only paste stack traces. Stack traces look like this:

java.lang.NoClassDefFoundError: Could not initialize class org.openstreetmap.josm.actions.SessionSaveAction
	at org.openstreetmap.josm.gui.MainMenu.<init>(MainMenu.java:181)
	at org.openstreetmap.josm.gui.MainFrame.initialize(MainFrame.java:93)
	at org.openstreetmap.josm.gui.MainApplication.initializeMainWindow(MainApplication.java:415)
	at org.openstreetmap.josm.spi.lifecycle.InitializationTask.call(InitializationTask.java:33)
	at org.openstreetmap.josm.spi.lifecycle.Lifecycle.runInitializationTasks(Lifecycle.java:103)
	at org.openstreetmap.josm.spi.lifecycle.Lifecycle.initialize(Lifecycle.java:71)
	at org.openstreetmap.josm.gui.MainApplication.mainJOSM(MainApplication.java:953)
	at org.openstreetmap.josm.gui.MainApplication$3.processArguments(MainApplication.java:277)
	at org.openstreetmap.josm.gui.MainApplication.main(MainApplication.java:741)

I am specifically interested in a java.lang.NullPointerException stack trace. It should have java.lang.ExceptionInInitializerError and java.util.concurrent.ExecutionException around it (please copy those as well).

comment:7 by skyper, 2 years ago

Ticket #22251 has been marked as a duplicate of this ticket.

comment:8 by taylor.smock, 2 years ago

Ticket #22256 has been marked as a duplicate of this ticket.

comment:9 by taylor.smock, 2 years ago

Ticket #22260 has been marked as a duplicate of this ticket.

comment:10 by taylor.smock, 2 years ago

Ticket #22261 has been marked as a duplicate of this ticket.

comment:11 by taylor.smock, 2 years ago

Cc: michel.lethiec@… added

comment:12 by taylor.smock, 2 years ago

I haven't been able to reproduce. I'm kind of wondering if this was a bad build -- I haven't seen any issues from -latest users. It is all people on r18513. With that said, we just released r18531. If we don't see any new tickets with r18531, I think we can close this.

comment:13 by GerdP, 2 years ago

Ticket #22270 has been marked as a duplicate of this ticket.

comment:14 by taylor.smock, 2 years ago

Ticket #22273 has been marked as a duplicate of this ticket.

comment:15 by taylor.smock, 2 years ago

#22273 is the first one with r18531. I really wish we knew what exactly was causing the NPE.

It is occurring either on L589 (registerActionShortcut) or L638 (getRegisteredActionShortcut), based purely off of NullPointerException: Cannot invoke "javax.swing.JComponent.getInputMap(int)" because "org.openstreetmap.josm.gui.MainApplication.contentPanePrivate" is null. And I'd bet it is registerActionShortcut that is the problem. But I have no clue why it is not happening reliably (and no one with the problem has gotten back to us with the output I asked for in comment:6).

comment:16 by taylor.smock, 2 years ago

Ticket #22275 has been marked as a duplicate of this ticket.

comment:17 by taylor.smock, 2 years ago

Can someone with this problem please give me information from comment:6? Or upload the actual jar file that is getting run?

I've been starting/stopping JOSM in a while loop, and at ~1200 runs (Ubuntu 22.04.1), I haven't encountered this issue, so I either need the information from comment:6 or better steps to reproduce. All indications from the bug reports is that this happens on startup.

The two while loops (run in different terminals), for the record:

  • run=0; while [ true ]; do josm; ((run+=1)); echo "Run $run"; done
    • JOSM takes 40-60s to start up
    • Only has window title "Java OpenStreetMap Editor" once startup has finished
  • while [ true ]; do if [ $(wmctrl -l | wc -l) -le 2 ]; then wmctrl -c "Java OpenStreetMap Editor"; fi; sleep 2; done
    • This closes windows with the title "Java OpenStreetMap Editor" every two seconds

comment:18 by skyper, 2 years ago

@Taylor:
Did you test it with a user defined shortcut in preferences for either source:/osm/applications/editors/josm/plugins/utilsplugin2/images/dumbutils/sourcetag.png Add Source Tag from utilsplugin2 or for source:trunk/resources/images/session.svg Save Session As…? The plugin could have been removed mean while. Even a toolbar item could have been defined for one or both of the two actions.

in reply to:  18 comment:19 by taylor.smock, 2 years ago

I've tried. It didn't crash for me. Did you get it to crash?

comment:20 by skyper, 2 years ago

Sorry, do not have much time, e.g. I never tried. In the short sessions with rather new preferences it never crashed.

comment:21 by taylor.smock, 2 years ago

Most of the bug reports with useful user-provided information indicated it occurred on startup, so if it doesn't crash there you are fine. Which is why I had a while loop starting/stopping JOSM.

comment:22 by taylor.smock, 2 years ago

Ticket #22293 has been marked as a duplicate of this ticket.

comment:23 by taylor.smock, 2 years ago

Ticket #22318 has been marked as a duplicate of this ticket.

comment:24 by taylor.smock, 2 years ago

Ticket #22321 has been marked as a duplicate of this ticket.

comment:25 by taylor.smock, 2 years ago

Ticket #22323 has been marked as a duplicate of this ticket.

comment:26 by skyper, 2 years ago

Priority: normalmajor

comment:27 by taylor.smock, 2 years ago

I'm seriously looking at modifying the bug report code so that we get the missing exceptions, but that isn't something I want to do right around a release.

comment:28 by taylor.smock, 2 years ago

OK. Here is what I think I'll do:

  • Do a release with r18543
  • Apply the patch
  • Ask those encountering this problem to use josm-latest (I'll point them at the appropriate installer)

If I get better bug reports

  • Fix the actual bug
  • Make a new release

EDIT: I've attached a jar file for those who have reported this bug and know how to start the JOSM jar file. Considering the lack of responses from the bug reporters, I don't think any of them will use it.
EDIT2: As of r18549, the patch is in JOSM core. As such, the attached jar file has been removed.

Last edited 2 years ago by taylor.smock (previous) (diff)

by taylor.smock, 2 years ago

Attachment: 22183.patch added

Better reporting of suppressed/ignored exceptions in EDT and worker threads

comment:29 by skyper, 2 years ago

Ticket #22325 has been marked as a duplicate of this ticket.

comment:30 by skyper, 2 years ago

Ticket #22345 has been marked as a duplicate of this ticket.

comment:31 by skyper, 2 years ago

Ticket #22348 has been marked as a duplicate of this ticket.

comment:32 by taylor.smock, 2 years ago

In 18549/josm:

See #22183: NoClassDefFoundError: Could not initialize class org.openstreetmap.josm.actions.SessionSaveAction

The root cause is a suppressed NPE whose stack trace is not given
in the bug report.

This adds a method to BugReport to add suppressed exceptions to a report.
In the future, if we keep the code long-term, methods in Logging which take
exceptions may assume the exception is suppressed, and add it to the
suppressed exceptions.

comment:33 by taylor.smock, 2 years ago

I've removed the custom jar file.

Users with this problem should attempt to reproduce using the new josm-latest revision (r18549). See https://github.com/JOSM/josm/releases/tag/18549 for installers for the various operating systems. Users should use the Java 17 installers if they use a newer revision. I will link the installers for r18549 on Mac and Windows below. Linux users should update using whatever method their Linux distribution recommends.

comment:34 by taylor.smock, 2 years ago

Ticket #22354 has been marked as a duplicate of this ticket.

comment:35 by skyper, 2 years ago

Ticket #22358 has been marked as a duplicate of this ticket.

comment:36 by skyper, 2 years ago

Ticket #22362 has been marked as a duplicate of this ticket.

comment:37 by skyper, 2 years ago

Ticket #22364 has been marked as a duplicate of this ticket.

comment:38 by skyper, 2 years ago

Cc: OMNIBUS added

#22358 is the first report with little more info.

comment:39 by skyper, 2 years ago

Ticket #22390 has been marked as a duplicate of this ticket.

comment:40 by skyper, 2 years ago

Ticket #22392 has been marked as a duplicate of this ticket.

comment:41 by skyper, 2 years ago

Cc: nelson.canhoto92@… added

in reply to:  38 comment:42 by taylor.smock, 2 years ago

Replying to skyper:

#22358 is the first report with little more info.

Oddly enough, not using r18549, but it was using Java 18 (maybe some behavior changed in Java 18 which gives us better stack traces?).

Anyway, it looks like it is a race condition. I'll see if I can put something together to fix this. I won't be 100% certain (since I've never been able to reproduce), I think I can just synchronize and wait for contentPanePrivate to be non-null.

by taylor.smock, 2 years ago

Attachment: 22183.1.patch added

Use synchronization to wait for non-null contentPanePrivate. Not ideal (due to synchronization), but should be safe.

comment:43 by taylor.smock, 2 years ago

NVM. I'm not seeing how that code is ever called prior to the setting of contentPanePrivate. So something is preventing us from setting the contentPanePrivate.

EDIT: I think I might do the following to get more information:

  • src/org/openstreetmap/josm/gui/MainApplication.java

    diff --git a/src/org/openstreetmap/josm/gui/MainApplication.java b/src/org/openstreetmap/josm/gui/MainApplication.java
    a b  
    856856        if (contentPane instanceof JComponent) {
    857857            contentPanePrivate = (JComponent) contentPane;
    858858        }
     859        if (!GraphicsEnvironment.isHeadless() && contentPanePrivate == null) {
     860            throw new JosmRuntimeException("MainFrame content pane is " + (contentPane == null ? "null" : contentPane.getClass().getName()));
     861        }
    859862        mainPanel = mainFrame.getPanel();
    860863
    861864        if (args.hasOption(Option.LOAD_PREFERENCES)) {
Last edited 2 years ago by taylor.smock (previous) (diff)

comment:44 by taylor.smock, 2 years ago

In 18561/josm:

See #22183: NoClassDefFoundError: Could not initialize class org.openstreetmap.josm.actions.SessionSave...

Add check after the setting of contentPanePrivate to figure out why it might be null.

comment:45 by taylor.smock, 2 years ago

For those affected, if it occurs on a semi-reliable basis, can you use the appropriate installers from https://github.com/JOSM/josm/releases/tag/18561 for your system? Or just the jar file once it updates (josm-latest.jar).

The code should throw an error much earlier, and will help debug why contentPanePrivate is null.

Last edited 2 years ago by taylor.smock (previous) (diff)

comment:46 by skyper, 2 years ago

Ticket #22396 has been marked as a duplicate of this ticket.

comment:47 by taylor.smock, 2 years ago

Ticket #22406 has been marked as a duplicate of this ticket.

comment:48 by skyper, 2 years ago

Ticket #22408 has been marked as a duplicate of this ticket.

comment:49 by taylor.smock, 2 years ago

Ticket #22411 has been marked as a duplicate of this ticket.

comment:50 by taylor.smock, 2 years ago

Ticket #22434 has been marked as a duplicate of this ticket.

comment:51 by taylor.smock, 2 years ago

#22434 has a usable stack trace. Based off of the saved stack traces in #22434, it looks like this issue is occurring due to JOSM starting thinking it has access to ipv6, detecting that it does not in fact have access to ipv6, and attempting to restart. This fails, due to SessionSaveAction not being able to initialize, which in turn causes JOSM startup to not finish.

comment:52 by taylor.smock, 2 years ago

Resolution: fixed
Status: needinfoclosed

In 18570/josm:

Fix #22183: NoClassDefFoundError: Could not initialize class org.openstreetmap.josm.actions.SessionSaveAction

This was caused by JOSM detecting that it had started in IPv6 mode, but no IPv6
network was available. When this occurs, JOSM immediately sets a preference key
and restarts so that users are not confused about a lack of network connectivity.

The JOSM restart action then proceeds to attempt to save any active layers, but
since this occurs during startup, there are no active layers and the save actions
have not yet been initialized. The save actions cannot be initialized before
contentPanePrivate has been initialized, but the IPv6 call is done prior to
that happening, which may then trigger a JOSM restart, which calls exitJosm,
which then calls the save layers actions.

comment:53 by taylor.smock, 2 years ago

Cc: Klumbumbus added

I'm on the fence as to whether or not I should release a hotfix now that I think we have a fix (based off of the additional stack traces from #22434).

The only reason I'm somewhat ambivalent is due the non-bugfix commits since r18565. But most of the non-bugfixes are small, and I believe only r18566 changed a text (for addresses) that may be translated.

EDIT: To clarify, r18570 fixes the issue from #22434. I just don't know if other users are triggering the bug in different ways.

Last edited 2 years ago by taylor.smock (previous) (diff)

comment:54 by taylor.smock, 2 years ago

Milestone: 22.10

comment:55 by Klumbumbus, 2 years ago

I think you should release a hot fix.

I don't consider changes of translatable strings shortly before a release as crucial (anymore) because:

https://translations.launchpad.net/josm

JOSM has >13k translatable strings. Only a handful of languages keeps up with >99% translated strings.

  • For all other languages with hundreds or thousands of untranslated strings, a few more don't matter at all.
  • For languages with >99% translation rate, a few out of 13k is still >99%, so it doesn't matter too. Additional if an end user actually stubmles over a untranslated string in a >99%-language it might be a good thing, because it reminds him that translation doesn't happen by itself but needs people and might animate him to contribute to the translations :)

comment:56 by taylor.smock, 2 years ago

Fair enough. I'll wait for r18570 to show up as josm-latest, then I'll start the release process. So probably tomorrow.

comment:57 by taylor.smock, 2 years ago

In 22.09 hotfix.

comment:58 by taylor.smock, 2 years ago

Milestone: 22.1022.09

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain anonymous.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.