Opened 13 months ago

Last modified 10 months ago

#22913 new defect

NoClassDefFoundError: Could not initialize class

Reported by: anonymous Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: template_report java17 openSUSE Cc: stoecker


What steps will reproduce the problem?

  1. Click "New picture from clipboard"

What is the expected result?

A new layer with clipboard contents

What happens instead?

'Picturelayer' plugin reports "An unexpected exception"

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

Disable plugin 'openedata'& 'geotools' and the error disappears

Relative:URL: ^/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2023-04-27 16:45:28 +0200 (Thu, 27 Apr 2023)
Build-Date:2023-04-28 01:30:56

Identification: JOSM/1.5 (18719 en) Linux openSUSE Leap 15.4
Memory Usage: 3680 MB / 8012 MB (2254 MB allocated, but free)
Java version: 17.0.6+0-suse-150400.3.15.1-x8664, N/A, OpenJDK 64-Bit Server VM
Look and Feel: javax.swing.plaf.metal.MetalLookAndFeel
Screen: :0.0 4480×1440 (scaling 1.00×1.00) :0.1 1920×1080 (scaling 1.00×1.00)
Maximum Screen Size: 4480×1440
Best cursor sizes: 16×16→16×16, 32×32→32×32
Environment variable LANG: da_DK.UTF-8
System property file.encoding: UTF-8
System property sun.jnu.encoding: UTF-8
Locale info: en_DK
Numbers with default locale: 1234567890 -> 1234567890
Desktop environment: KDE
Java package: java-17-openjdk:x86_64-
apache-commons-logging: apache-commons-logging:noarch-1.2
Program arguments: [start.joz]
Dataset consistency test: No problems found

+ FastDraw (36057)
+ Mapillary (2.1.3)
+ OpeningHoursEditor (35924)
+ PicLayer (1.0.2)
+ SimplifyArea (35978)
+ apache-commons (36034)
+ areaselector (1652822522)
+ austriaaddresshelper (master-4e80dc2e4261d321150187f4951684ad97342d5e)
+ buildings_tools (36011)
+ centernode (v1.0.4)
+ conflation (0.6.11)
+ easypresets (1623509627)
+ ejml (35924)
+ geotools (36068)
+ jackson (36034)
+ jaxb (35952)
+ josm_magic_wand (1.1.0)
+ jts (36004)
+ log4j (36034)
+ opendata (36076)
+ reverter (36043)
+ tageditor (36011)
+ terracer (35978)
+ todo (123)
+ turnlanes-tagging (v0.0.5)
+ turnrestrictions (36011)
+ undelete (36011)
+ utilsplugin2 (36011)

Tagging presets:
+ <josm.userdata>/EasyPresets.xml
+ ${HOME}/Diverse_OSM/Presets/Butikker.xml

Map paint styles:

Last errors/warnings:
- 00005.549 E: Failed to locate image 'presets/nautical/waterway_riverbank.svg'
- 00005.549 W:  null: Could not get presets icon presets/nautical/waterway_riverbank.svg
- 00005.555 E: Failed to locate image 'presets/nautical/waterway_riverbank.svg'
- 00005.555 W:  Under_vejen_pipeline: Could not get presets icon presets/nautical/waterway_riverbank.svg
- 00009.935 W: Unable to find supported projection for layer Ortofoto forår 2019. Using EPSG:3857.
- 00009.935 W: Unable to find supported projection for layer Ortofoto forår 2019. Using EPSG:3857.
- 00010.067 W: Unable to find supported projection for layer Ortofoto forår 2021. Using EPSG:3857.
- 00010.067 W: Unable to find supported projection for layer Ortofoto forår 2021. Using EPSG:3857.
- 00021.105 E: Handled by bug report queue: java.lang.IllegalAccessError: class (in unnamed module @0x314b9e4b) cannot access class (in module java.base) because module java.base does not export to unnamed module @0x314b9e4b
- 00074.353 E: Handled by bug report queue: java.lang.NoClassDefFoundError: Could not initialize class

No data collected.

Warning issued by: BugReportExceptionHandler#handleException

Thread: AWT-EventQueue-0 (20) of main
java.lang.NoClassDefFoundError: Could not initialize class
	at java.desktop/javax.imageio.spi.ImageWriterSpi.createWriterInstance(
	at java.desktop/javax.imageio.ImageIO$
	at java.desktop/javax.imageio.ImageIO$
	at java.desktop/sun.awt.X11.XDataTransferer.getPlatformMappingsForFlavor(
	at java.desktop/sun.awt.datatransfer.DesktopDatatransferServiceImpl.getPlatformMappingsForFlavor(
	at java.datatransfer/java.awt.datatransfer.SystemFlavorMap.flavorToNativeLookup(
	at java.datatransfer/java.awt.datatransfer.SystemFlavorMap.getNativesForFlavor(
	at java.desktop/sun.awt.datatransfer.DataTransferer.getFlavorsForFormats(
	at java.desktop/sun.awt.datatransfer.ClipboardTransferable.<init>(
	at java.desktop/sun.awt.X11.XClipboard.getContents(
	at org.openstreetmap.josm.plugins.piclayer.layer.PicLayerFromClipboard.createImage(
	at org.openstreetmap.josm.plugins.piclayer.layer.PicLayerAbstract.initialize(
	at org.openstreetmap.josm.plugins.piclayer.actions.newlayer.NewLayerFromClipboardAction.actionPerformed(
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(
	at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(
	at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(
	at java.desktop/javax.swing.DefaultButtonModel.setPressed(
	at java.desktop/javax.swing.AbstractButton.doClick(
	at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI.doClick(
	at java.desktop/javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(
	at java.desktop/java.awt.Component.processMouseEvent(
	at java.desktop/javax.swing.JComponent.processMouseEvent(
	at java.desktop/java.awt.Component.processEvent(
	at java.desktop/java.awt.Container.processEvent(
	at java.desktop/java.awt.Component.dispatchEventImpl(
	at java.desktop/java.awt.Container.dispatchEventImpl(
	at java.desktop/java.awt.Component.dispatchEvent(
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(
	at java.desktop/java.awt.Container.dispatchEventImpl(
	at java.desktop/java.awt.Window.dispatchEventImpl(
	at java.desktop/java.awt.Component.dispatchEvent(
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(
	at java.desktop/java.awt.EventQueue$
	at java.desktop/java.awt.EventQueue$
	at java.base/
	at java.base/$JavaSecurityAccessImpl.doIntersectionPrivilege(
	at java.base/$JavaSecurityAccessImpl.doIntersectionPrivilege(
	at java.desktop/java.awt.EventQueue$
	at java.desktop/java.awt.EventQueue$
	at java.base/
	at java.base/$JavaSecurityAccessImpl.doIntersectionPrivilege(
	at java.desktop/java.awt.EventQueue.dispatchEvent(
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(
	at java.desktop/

Attachments (0)

Change History (13)

comment:1 by skyper, 13 months ago

Keywords: java17 openSUSE added
Summary: New picture from clipboardNoClassDefFoundError: Could not initialize class

Looks like another duplicate of #21059.
You are missing some VM arguments on startup.
How do you install JOSM? You might want to take a look at Download.

comment:2 by taylor.smock, 13 months ago

Cc: stoecker added

Identification: JOSM/1.5 (18719 en) Linux openSUSE Leap 15.4

It looks like the user is probably just running java -jar ${josm.jar} since I don't see r18719 on .

With that said, it looks like the openSUSE JOSM start script is missing many arguments.

The current openSUSE start script looks like


LIBXCB_ALLOW_SLOPPY_LOCK=1 `perl -e '$res = "/usr/lib64/jvm/jre-11-openjdk/bin/java"; $res = "java" if !-f $res || qx(java -version 2>&1) !~ /version \"(\d+)/ || $1 >= 11; print $res'` -Xms128M -Xmx4096M -XX:+UseParallelGC -XX:+UseAdaptiveSizePolicy -jar /usr/share/java/josm-tested.jar "$@"

Looking at source:trunk/native/linux/tested/usr/bin/josm, the openSUSE start script is missing:

  • --add-modules java.scripting,java.sql,javafx.controls,,javafx.swing,javafx.web
  • --add-exports=java.base/
  • --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED
  • --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED"

Going through the openSUSE start script:

  • -XX:+UseParallelGC -- I have no clue if this is still useful; the default GC is G1 since Java 9, and G1 has had throughput improvements of ~15% between Java 8 and Java 17. There are some significant improvements to G1 in Java 18 (JDK-8017163).
  • -XX:+UseAdaptiveSizePolicy -- it looks like this is a default setting now, so probably not necessary
  • LIBXCB_ALLOW_SLOPPY_LOCK=1 -- almost certainly not necessary; it looks like it was a workaround for a libxcb locking bug issue in the 2008 timeframe.
  • -Xms128M -- sets the min heap, probably fine (MOTD is ~84M after GC)
  • -Xmx4096M -- sets the max heap, I don't think this is necessary anymore

comment:3 by stoecker, 13 months ago

Adapted SUSE package except for JavaFX where I still don't know how that would work for openSUSE.

in reply to:  3 comment:4 by taylor.smock, 13 months ago

I don't know how SUSE/openSUSE do their JavaFX installs, but if they put it in the same directory as the rest of the JDK (like Arch), then something like JAVAFX_HOME="$(ls /usr/lib/jvm/default-runtime/lib/javafx*.jar | tr "\n" ":" | sed '"'"'s/.$//'"'"')" should work. There is probably a better way though.

In any case, the only reason why we have a JavaFX dependency is MS Streetside (broken, it looks like MS killed the API it was using), matsim, and an audio player (in the JavaFX plugin), so not having JavaFX won't kill core functionality.

comment:5 by stoecker, 13 months ago

Package openjfx8 has "/usr/lib64/jvm/openjfx8/rt/lib/ext/jfxrt.jar" which seems to have the relevant stuff included.
But adding "--module-path /usr/lib64/jvm/openjfx8/rt/lib/ext/jfxrt.jar" seems not to help.

comment:6 by taylor.smock, 13 months ago

You probably want openjfx instead of openjfx8 -- I think openjfx8 was roughly the equivalent of the JavaFX that was in Java 8, while openjfx is what is currently released (AKA in a Java module form).

comment:7 by stoecker, 13 months ago

Well, that may be the reason... Nobody make a package for this yet :-)

comment:8 by anonymous, 13 months ago

as an Opensuse tumbleweed user, I also have this issue, mostly when spawning windows, like the download window. Not every time, but sometimes. I'm running JOSM simply by java -jar the file from the website. Running openjdk 17, as anything above doesn't work with JOSM.

comment:9 by taylor.smock, 13 months ago

@anonymous: Since you are running JOSM from the command line, you really need to look at either using our start script (see source:trunk/native/linux/tested/usr/bin/josm ) or keeping up with any additional arguments we end up needing. You (minimally) need to have at least the following:

  • --add-modules java.scripting,java.sql (we don't use JavaFX in JOSM core; you only need to append javafx.controls,,javafx.swing,javafx.web if you have the JavaFX plugin installed, although I think we only have the other additional modules for plugins)
  • --add-exports=java.base/
  • --add-exports=java.desktop/com.sun.imageio.plugins.jpeg=ALL-UNNAMED
  • --add-exports=java.desktop/com.sun.imageio.spi=ALL-UNNAMED

comment:10 by anonymous, 13 months ago

thanks for the reply. I will try changing the way I launch JOSM. It's just weird, since launching with simple java -jar seems to be the instructed way for the .jar on wiki pages like "Download" or "InstallNotes".

comment:11 by taylor.smock, 13 months ago

Technically, you should be able to just run java -jar -- we add the appropriate Add-Opens/Add-Exports to the manifest. With that said, now that I'm inspecting the generated manifest, I'm wondering if we need to fiddle with the generated Manifest.MF.

Add-Opens: java.base/java.lang java.base/java.nio java.base/jdk.intern
 al.loader java.base/jdk.internal.ref java.base/ java
 .desktop/javax.imageio.spi java.desktop/com.sun.imageio.plugins.jpeg 
 java.desktop/javax.swing.text.html java.prefs/java.util.prefs
Add-Exports: java.base/ java.desktop/ j
 ation jdk.deploy/com.sun.deploy.config

Of note (for us) is that java.desktop/javax.imageio.spi and java.desktop/com.sun.imageio.spi is split over multiple lines. I don't think we've seen any of the others in tickets recently.

comment:12 by taylor.smock, 13 months ago

Ignore what I said in comment:11.

From comment:10:ticket:21059,

These attributes are interpreted only in the main executable JAR file of an application, i.e., in the JAR file specified to the -jar option of the Java run-time launcher; they are ignored in all other JAR files.

So the exports we do for JOSM core cannot extend to plugins without the command line arguments, and the problem you are having is with plugins (PicLayerFromClipboard.createImage).

But now I'm wondering if we add a module-info file for JMapViewer and JOSM if plugins will be able to open up the modules they need to themselves via their own module-info files. We'd have to (minimally) add a hint as to what module name we would use (Automatic-Module-Name in the manifest), but that should be doable.

comment:13 by stoecker, 10 months ago

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

Modify Ticket

Change Properties
Set your email in Preferences
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to anonymous.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment

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