Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running java 17+ byte code in devmode server #9896

Open
vegegoku opened this issue Jan 9, 2024 · 5 comments
Open

Error running java 17+ byte code in devmode server #9896

vegegoku opened this issue Jan 9, 2024 · 5 comments

Comments

@vegegoku
Copy link
Contributor

vegegoku commented Jan 9, 2024

GWT version: 2.11
Browser (with version):Any
Operating System: ubuntu

Running dev mode using the built in server with classes compiled with bytecode java 17+ will produce an error

MultiException[java.lang.RuntimeException: Error scanning file /mnt/drive2/Development/Vertispan/GWT/testing/2.11/TestProject/war/WEB-INF/classes/com/google/gwt/shared/FieldVerifier.class, java.lang.RuntimeException: Error scanning file /mnt/drive2/Development/Vertispan/GWT/testing/2.11/TestProject/war/WEB-INF/classes/com/google/gwt/server/GreetingServiceImpl.class, java.lang.RuntimeException: Error scanning file /mnt/drive2/Development/Vertispan/GWT/testing/2.11/TestProject/war/WEB-INF/classes/com/google/gwt/TestProjectSuite.class, java.lang.RuntimeException: Error scanning file /mnt/drive2/Development/Vertispan/GWT/testing/2.11/TestProject/war/WEB-INF/classes/com/google/gwt/client/TestProject$1MyHandler$1.class, java.lang.RuntimeException: Error scanning file /mnt/drive2/Development/Vertispan/GWT/testing/2.11/TestProject/war/WEB-INF/classes/com/google/gwt/client/TestProject$1.class, java.lang.RuntimeException: Error scanning file /mnt/drive2/Development/Vertispan/GWT/testing/2.11/TestProject/war/WEB-INF/classes/com/google/gwt/client/GreetingService.class, java.lang.RuntimeException: Error scanning file /mnt/drive2/Development/Vertispan/GWT/testing/2.11/TestProject/war/WEB-INF/classes/com/google/gwt/client/TestProject$1MyHandler.class, java.lang.RuntimeException: Error scanning file /mnt/drive2/Development/Vertispan/GWT/testing/2.11/TestProject/war/WEB-INF/classes/com/google/gwt/client/TestProjectTest.class, java.lang.RuntimeException: Error scanning file /mnt/drive2/Development/Vertispan/GWT/testing/2.11/TestProject/war/WEB-INF/classes/com/google/gwt/client/TestProject.class, java.lang.RuntimeException: Error scanning file /mnt/drive2/Development/Vertispan/GWT/testing/2.11/TestProject/war/WEB-INF/classes/com/google/gwt/client/GreetingServiceAsync.class, java.lang.RuntimeException: Error scanning file /mnt/drive2/Development/Vertispan/GWT/testing/2.11/TestProject/war/WEB-INF/classes/com/google/gwt/client/TestProjectTest$1.class]
	at org.eclipse.jetty.util.MultiException.ifExceptionThrow(MultiException.java:122)
	at org.eclipse.jetty.annotations.AnnotationConfiguration.scanForAnnotations(AnnotationConfiguration.java:492)
	at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:346)
	at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:498)
	at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1409)
	at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:910)
	at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:288)
	at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:524)
	at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:496)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
	at org.eclipse.jetty.server.Server.start(Server.java:423)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:110)
	at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
	at org.eclipse.jetty.server.Server.doStart(Server.java:387)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
	at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:640)
	at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:636)
	at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:898)
	at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:705)
	at com.google.gwt.dev.DevMode.main(DevMode.java:432)
	Suppressed: java.lang.RuntimeException: Error scanning file /mnt/drive2/Development/Vertispan/GWT/testing/2.11/TestProject/war/WEB-INF/classes/com/google/gwt/shared/FieldVerifier.class
		at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:741)
		at org.eclipse.jetty.annotations.AnnotationParser.parse(AnnotationParser.java:828)
		at org.eclipse.jetty.annotations.AnnotationConfiguration$ParserTask.call(AnnotationConfiguration.java:159)
		at org.eclipse.jetty.annotations.AnnotationConfiguration$1.run(AnnotationConfiguration.java:455)
		at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883)
		at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034)
		at java.base/java.lang.Thread.run(Thread.java:1583)
	Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 64
		at org.objectweb.asm.ClassReader.<init>(ClassReader.java:199)
		at org.objectweb.asm.ClassReader.<init>(ClassReader.java:180)
		at org.objectweb.asm.ClassReader.<init>(ClassReader.java:166)
		at org.objectweb.asm.ClassReader.<init>(ClassReader.java:287)
		at org.eclipse.jetty.annotations.AnnotationParser.scanClass(AnnotationParser.java:932)
		at org.eclipse.jetty.annotations.AnnotationParser.parseDir(AnnotationParser.java:734)
		... 6 more

As the tail end of the error shows, this is a problem specifically with asm, or with how Jetty is using asm.

Workarounds:

  • Stop using the deprecated built-in server, either by passing -noserver and running your own server (to correctly mirror how the application will run in production), or by serving only static resources by passing -server com.google.gwt.dev.shell.StaticResourceServer, disabling dev mode from running server-side code, but still allowing it to host static resources in the war directory.
  • Change compilation level of your project to 8 or 11.
  • For similar errors in the past, it has been possible to disable or limit Jetty's annotation scanning - that may be an option here as well, but we haven't explored it yet.
@eliasbalasis
Copy link

I faced similar issue recently.

Compile your code using Java target level compatible with the target environment.
perhaps Java 11 for DevMode Jetty or perhaps greater for -noserver and own server

I don't think any other approach is going to work.

I hope this helps you.

@jnehlmeier
Copy link
Member

Jetty 9.4.44 uses ASM 9.2 and thus supports scanning class files up to Java 18.

Disabling annotation processing is not a great option as it forces some to change their project. I think it is better to just document the fact that only Java 18 class files are supported and if someone wants to use newer Java versions they either could try to disable annotation processing for that project or bring their own server.

Given that java releases are relatively fast now, this will continue to happen in the future unless we update Jetty regularly.

@niloc132
Copy link
Contributor

niloc132 commented Jan 9, 2024

Among other reasons, this is why we're deprecating the use of the built-in app server, and encouraging external server implementations (to be passed via -server f.q.ServerClassName), and have discouraged its use for a long time.

@jnehlmeier
Copy link
Member

Should we close this issue or do we want to update Jetty again? Currently it is expected behavior and the built-in app server has been deprecated. So I tend to leave it as is and close the issue.

@niloc132
Copy link
Contributor

Yep, we filed it to make sure to have an issue that shows the error, and outlines specific workarounds that are available.

Updating Jetty while still supporting it in this way is technically an option, but is probably going to introduce more headache with all the various ways that downstream projects might want to use it - I'd lean towards removing the JettyLauncher first, then limit what parts of Jetty we use while updating to the latest build we can support (need to keep htmlunit in mind too, see HtmlUnit/htmlunit#704).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants