Skip to content

When tests added to the JOSM plugin, which is based on the gradle-josm-plugin, build fails with java.lang.NoClassDefFoundError

This issue is more like "I am asking here for help". It is probably not an issue at all, but just bad settings and my lack of knowledge. Thank you in advance for pointing me in the right direction.

I am trying to add some tests into the mapathoner plugin. The ut branch is https://git.sr.ht/~qeef/mapathoner/log/ut and the failing commit is the last one: https://git.sr.ht/~qeef/mapathoner/commit/4327ca04fe18f16be21022db8e67a9b827eee79f#test/unit/org/openstreetmap/josm/plugins/mapathoner/MapathonerTest.java-1-31

(Particularly, at DataSet ds = OsmReader.parseDataSet(fis, null); line.)

build.gradle is https://git.sr.ht/~qeef/mapathoner/tree/ut/item/build.gradle

first few lines of the stack trace:

java.lang.NoClassDefFoundError: Could not initialize class org.openstreetmap.josm.data.osm.Node
	at org.openstreetmap.josm.data.osm.OsmPrimitiveType.<clinit>(OsmPrimitiveType.java:18)
	at org.openstreetmap.josm.io.AbstractReader.doParseDataSet(AbstractReader.java:331)
	at org.openstreetmap.josm.io.OsmReader.doParseDataSet(OsmReader.java:504)
	at org.openstreetmap.josm.io.OsmReader.parseDataSet(OsmReader.java:554)
	at org.openstreetmap.josm.io.OsmReader.parseDataSet(OsmReader.java:537)
	at org.openstreetmap.josm.plugins.mapathoner.MapathonerTest.get_buildings_of(MapathonerTest.java:28)
	at org.openstreetmap.josm.plugins.mapathoner.MapathonerTest.test_non_orthogonal_buildings(MapathonerTest.java:36)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86)

I tested with the newest version of the Gradle and Gradle JOSM Plugin with the same result: https://git.sr.ht/~qeef/mapathoner/log/0476d78ce36000b74f4aaf06672ef8b26082e006

Thank you for your help.

(Please, note that the links provided are temporary and when the issue is solved, the links will probably not be accessible.)

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information