flow icon indicating copy to clipboard operation
flow copied to clipboard

Reflection error attempting to run Vaadin 23 with Java 17 on Wildfly

Open amagnolo opened this issue 2 years ago • 8 comments

Description of the bug

The method com.vaadin.base.devserver.startup.DevModeInitializer.generateJarFromJBossVfsFolder(Object jarVirtualFile, Path tempJar) fails with NoSuchMethodException when it attempts to use reflection on virtualFileClass.getMethod("getChildrenRecursively").

This is caused by the method com.vaadin.base.devserver.startup.DevModeInitializer.getPhysicalFileOfJBossVfsJar(URL url) on line Object jarVirtualFile = url.openConnection().getContent(); because it returns an instance of org.jboss.vfs.VirtualJarInputStream when run in Java 17, instead of the expected org.jboss.vfs.VirtualFile as when run in Java 15.

Expected behavior

Vaadin should run on Wildfly both with Java 17 and Java 15

Minimal reproducible example

Start any Vaadin project on Wildfly using Java 17

Versions

  • Vaadin / Flow version: 23.0.8
  • Java version: 17.0.3
  • OS version: Pop!_OS 22.04
  • Browser version (if applicable): N/A
  • Application Server (if applicable): Wildfly 26.1.0 (and also Wildfly 21.0.1)
  • IDE (if applicable): N/A

amagnolo avatar May 02 '22 15:05 amagnolo

I encountered the same problem Vaadin 14.x and found that the culprit was the java version. When i downgraded to 17.0.2, it started to work again. Maybe you should try that as a temporary workaround until the Vaadin team fixes this one.

rokkolesa avatar May 04 '22 00:05 rokkolesa

Can confirm the problem is with Java 17.0.3, and also using 17.0.2 as workaround

mcollovati avatar May 04 '22 08:05 mcollovati

The problem is https://issues.redhat.com/browse/WFLY-16322 which has apparently been solved in https://github.com/jbossas/jboss-vfs/pull/40 a month ago and released in jboss-vfs 3.2.17

Artur- avatar Jun 08 '22 10:06 Artur-

I encountered the same problem Vaadin 14.x and found that the culprit was the java version. When i downgraded to 17.0.2, it started to work again. Maybe you should try that as a temporary workaround until the Vaadin team fixes this one.

17.0.2 has quite a serious security flaw failing to properly validate certificates. I would not suggest falling back to 17.0.2, but rather to patch the module jboss-vfs to use the updated jboss-vfs version. Which is not too difficult to perform: you need to modify the module.xml in the <wildfly>/modules/system/layers/base/org/jboss/vfs/main folder to match the 3.2.17.Final version number, and copy the jboss-vfs-3.2.17.Final.jar into that folder, and (re)start your wildfly.

dashorst avatar Jun 20 '22 14:06 dashorst

I get the same problem with Java 11.0.16 (OpenJDK) and JBoss EAP 7.3. I still need to check if there is an official update for JBoss EAP 7.3. Patching jboss-vfs fixes the problem.

Still, a more helpful error message would be appreciated as I have investigated all other possible issues before.

cdir avatar Aug 09 '22 06:08 cdir

I've updated that reflection method during work on jakarta ee 9 (servlet 5) https://github.com/vaadin/flow/commit/c2430cc7fc8c492e51daef85416b7cc68a44da11 - CP to master? I've tested on 17.0.3 with Wildfly 26.1.1.Final (preview)

MarcinVaadin avatar Sep 08 '22 08:09 MarcinVaadin

Note: This problem is fixed with Wildfly 26.1.2.Final

Related issues:

  • https://issues.redhat.com/browse/WFCORE-5916 (Updates JBoss vfs to 3.2.17.Final in Wildfly Core 18.1.2.Final)
  • https://issues.redhat.com/browse/WFLY-16859 (Updates Wildfly Core to 18.1.2.Final in Wildfly 26.1.2.Final)

AB-xdev avatar Sep 09 '22 09:09 AB-xdev

Can confirm that it works on WildFly 26.1.2.Final using OpenJDK 17.0.4

rokkolesa avatar Sep 27 '22 14:09 rokkolesa

I confirm that problem is solved with WildFly 26.1.2.Final (tested with Vaadin 23.2.8, OpenJDK 17.0.5). This issue can be closed.

amagnolo avatar Nov 11 '22 16:11 amagnolo