java.lang.NoSuchMethodError: 'void com.sun.jna.Memory.close()'

Hi,

I’m in the midst of upgrading a Vaadin 14 project to the latest Vaadin 24.4.2.

I’m running the application on Java 21-graalce.

Looks like there is an issue with versioning of the Oshi lib use by LicenseChecker.

I’ve found the following ticket related to this: but I have no idea to actually resolve this

https://github.com/vaadin/flow/issues/15782

Any ideas?

Thanks

Kristof.

java.lang.NoSuchMethodError: 'void com.sun.jna.Memory.close()'
	at oshi.util.Util.freeMemory(Util.java:83)
	at oshi.jna.ByRef$CloseableSizeTByReference.close(ByRef.java:110)
	at oshi.util.platform.mac.SysctlUtil.sysctl(SysctlUtil.java:61)
	at oshi.util.platform.mac.SysctlUtil.sysctl(SysctlUtil.java:40)
	at oshi.hardware.platform.mac.MacCentralProcessor.initProcessorCounts(MacCentralProcessor.java:136)
	at oshi.hardware.common.AbstractCentralProcessor.<init>(AbstractCentralProcessor.java:67)
	at oshi.hardware.platform.mac.MacCentralProcessor.<init>(MacCentralProcessor.java:49)
	at oshi.hardware.platform.mac.MacHardwareAbstractionLayer.createProcessor(MacHardwareAbstractionLayer.java:42)
	at oshi.util.Memoizer$1.get(Memoizer.java:61)
	at oshi.hardware.common.AbstractHardwareAbstractionLayer.getProcessor(AbstractHardwareAbstractionLayer.java:48)
	at com.vaadin.pro.licensechecker.MachineId.getComputerId(MachineId.java:37)
	at com.vaadin.pro.licensechecker.MachineId.get(MachineId.java:19)
	at com.vaadin.copilot.analytics.AnalyticsClient.<init>(AnalyticsClient.java:34)
	at com.vaadin.copilot.Copilot.handleConnect(Copilot.java:62)
	at com.vaadin.base.devserver.DebugWindowConnection.handleConnect(DebugWindowConnection.java:207)
	at com.vaadin.base.devserver.DebugWindowConnection.onConnect(DebugWindowConnection.java:187)
	at com.vaadin.flow.server.communication.PushHandler.lambda$onConnect$3(PushHandler.java:605)
	at java.base/java.util.Optional.ifPresent(Optional.java:178)
	at com.vaadin.flow.server.communication.PushHandler.lambda$onConnect$4(PushHandler.java:604)
	at com.vaadin.flow.server.communication.PushHandler.callWithServiceAndSession(PushHandler.java:227)
	at com.vaadin.flow.server.communication.PushHandler.onConnect(PushHandler.java:601)
	at com.vaadin.flow.server.communication.PushAtmosphereHandler.onConnect(PushAtmosphereHandler.java:103)
	at com.vaadin.flow.server.communication.PushAtmosphereHandler.onRequest(PushAtmosphereHandler.java:77)
	at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:217)
	at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:103)
	at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:67)
	at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:2284)
	at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:574)
	at org.atmosphere.websocket.DefaultWebSocketProcessor.open(DefaultWebSocketProcessor.java:213)
	at org.atmosphere.container.JSR356Endpoint.onOpen(JSR356Endpoint.java:254)
	at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.init(WsHttpUpgradeHandler.java:131)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:938)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
	at java.base/java.lang.Thread.run(Thread.java:1583)
	Suppressed: java.lang.NoSuchMethodError: 'void com.sun.jna.Memory.close()'
		at oshi.util.platform.mac.SysctlUtil.sysctl(SysctlUtil.java:53)
		... 35 common frames omitted

2024-06-16T15:14:11.999+02:00  WARN 35174 --- [nio-8080-exec-6] o.a.w.protocol.SimpleHttpProtocol        : java.lang.NoSuchMethodError: 'void com.sun.jna.Memory.close()'. Unable to deliver the websocket messages to installed component. Status 500 Message Server Error
2024-06-16T15:14:12.014+02:00  WARN 35174 --- [nio-8080-exec-6] o.a.websocket.DefaultWebSocketProcessor  : Failed invoking AtmosphereFramework.doCometSupport()

java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because "this.commands" is null
	at com.vaadin.copilot.Copilot.handleMessage(Copilot.java:124)
	at com.vaadin.base.devserver.DebugWindowConnection.onMessage(DebugWindowConnection.java:321)
	at com.vaadin.flow.server.communication.PushHandler.handleDebugWindowMessage(PushHandler.java:650)
	at com.vaadin.flow.server.communication.PushHandler.callWithServiceAndSession(PushHandler.java:227)
	at com.vaadin.flow.server.communication.PushHandler.onMessage(PushHandler.java:626)
	at com.vaadin.flow.server.communication.PushAtmosphereHandler.onMessage(PushAtmosphereHandler.java:90)
	at com.vaadin.flow.server.communication.PushAtmosphereHandler.onRequest(PushAtmosphereHandler.java:79)
	at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:217)
	at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:103)
	at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:67)
	at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:2284)
	at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:574)
	at org.atmosphere.websocket.DefaultWebSocketProcessor.lambda$dispatch$2(DefaultWebSocketProcessor.java:326)
	at org.atmosphere.util.VoidExecutorService.execute(VoidExecutorService.java:101)
	at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:323)
	at org.atmosphere.websocket.DefaultWebSocketProcessor.invokeWebSocketProtocol(DefaultWebSocketProcessor.java:428)
	at org.atmosphere.container.JSR356Endpoint.lambda$onOpen$2(JSR356Endpoint.java:261)
	at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:390)
	at org.apache.tomcat.websocket.server.WsFrameServer.sendMessageText(WsFrameServer.java:130)
	at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:484)
	at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:284)
	at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:130)
	at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:85)
	at org.apache.tomcat.websocket.server.WsFrameServer.doOnDataAvailable(WsFrameServer.java:184)
	at org.apache.tomcat.websocket.server.WsFrameServer.notifyDataAvailable(WsFrameServer.java:164)
	at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.upgradeDispatch(WsHttpUpgradeHandler.java:152)
	at org.apache.coyote.http11.upgrade.UpgradeProcessorInternal.dispatch(UpgradeProcessorInternal.java:60)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:57)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
	at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
	at java.base/java.lang.Thread.run(Thread.java:1583)

2024-06-16T15:14:12.014+02:00  WARN 35174 --- [nio-8080-exec-6] o.a.w.protocol.SimpleHttpProtocol        : java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because "this.commands" is null. Unable to deliver the websocket messages to installed component. Status 500 Message Server Error
2024-06-16T15:44:29.726+02:00  WARN 35174 --- [nio-8080-exec-3] o.a.websocket.DefaultWebSocketProcessor  : Failed invoking AtmosphereFramework.doCometSupport()

Make sure you have the correct versions of JNA and oshi available. You can for example use maven dependency tree to check for multiple declarations.

1 Like

Thank you Christian,

I indeed found a dependency that pulled in a different version of JNA.