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

Ctrl-C after jetty:run produces NoClassDefFoundError #5832

Closed
sbordet opened this issue Dec 21, 2020 · 10 comments
Closed

Ctrl-C after jetty:run produces NoClassDefFoundError #5832

sbordet opened this issue Dec 21, 2020 · 10 comments
Assignees

Comments

@sbordet
Copy link
Contributor

@sbordet sbordet commented Dec 21, 2020

Jetty version
10.0.x

Description
Starting Jetty 10 in a terminal window with the Jetty Maven Plugin via jetty:run, and then hitting ctrl-c produces:

Exception in thread "JettyShutdownThread" java.lang.NoClassDefFoundError: org/eclipse/jetty/util/BlockingArrayQueue$Itr
	at org.eclipse.jetty.util.BlockingArrayQueue.listIterator(BlockingArrayQueue.java:749)
	at java.base/java.util.AbstractList.listIterator(AbstractList.java:311)
	at org.eclipse.jetty.util.BlockingArrayQueue.iterator(BlockingArrayQueue.java:173)
	at java.base/java.util.AbstractCollection.toArray(AbstractCollection.java:142)
	at java.base/java.util.ArrayList.<init>(ArrayList.java:181)
	at org.eclipse.jetty.client.HttpDestination.abort(HttpDestination.java:482)
	at org.eclipse.jetty.client.HttpDestination.close(HttpDestination.java:412)
	at org.eclipse.jetty.client.HttpClient.doStop(HttpClient.java:242)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:137)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:185)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:208)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:137)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:185)
	at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:208)
	at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:137)
	at org.eclipse.jetty.util.thread.ShutdownThread.run(ShutdownThread.java:141)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.util.BlockingArrayQueue$Itr
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
	... 16 more
@janbartel janbartel self-assigned this Dec 21, 2020
@janbartel
Copy link
Contributor

@janbartel janbartel commented Dec 21, 2020

What webapp?

@sbordet
Copy link
Contributor Author

@sbordet sbordet commented Dec 21, 2020

@janbartel with the CometD Demo WebApp. Not sure where that HttpClient being stopped comes from, I don't think it's CometD, especially not registered in ShutdownThread.

Could be the HttpClient used by WebSocket? @lachlan-roberts?

@lachlan-roberts
Copy link
Member

@lachlan-roberts lachlan-roberts commented Dec 21, 2020

@sbordet If you call ContainerProvider.getWebSocketContainer() it will register the JavaxWebSocketClientContainer with the shutdown thread and this contains an HttpClient so it could be the websocket one. But it is strange because the NoClassDefFoundError is for the jetty-util BlockingArrayQueue and not the HttpClient.

@olamy
Copy link
Contributor

@olamy olamy commented Dec 21, 2020

@lachlan-roberts
Copy link
Member

@lachlan-roberts lachlan-roberts commented Dec 21, 2020

I think I've seen this before. See issue #4410.

In short, on Jetty stop/shutdown the maven process yanks the classloader out from underneath the Jetty threads (and Spring threads) leaving random errors in its wake.
This can happen with any version of Jetty and the Jetty Maven Plugin.
It's random, and can happen at any time, with no work around that we are aware of.

@olamy
Copy link
Contributor

@olamy olamy commented Dec 21, 2020

yes it's documented on maven core side (I don't remember the link). Maven core is very aggressive to close classloader. So when a registered shutdown hook try to run the context classloader has been closed and so classnotfound.

@olamy
Copy link
Contributor

@olamy olamy commented Dec 21, 2020

@lachlan-roberts
Copy link
Member

@lachlan-roberts lachlan-roberts commented Dec 22, 2020

@sbordet when you do Ctrl-C, this will end up in the ShutdownThread for the server. So even if you have the JavaxWebSocketClientContainer attached to some LifeCycle in cometd you will still end up in the shutdown thread and may still encounter this maven bug.

Also the ContainerProvider.getWebSocketContainer() instance will be using the servers version of the jetty-util classes and not the version in the webapp for cometd. So calling addBean(container) in the ClientTransport.Factory will just be a NOOP as it is not an instance of the same LifeCycle class.

@sbordet
Copy link
Contributor Author

@sbordet sbordet commented Dec 22, 2020

So even if you have the JavaxWebSocketClientContainer attached to some LifeCycle in cometd you will still end up in the shutdown thread and may still encounter this maven bug.

I don't see how? If the component is already stopped, it will have removed itself from the ShutdownThread registration and should not end up trying to stop again.

lachlan-roberts added a commit that referenced this issue Dec 23, 2020
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Dec 23, 2020
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Dec 24, 2020
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Jan 12, 2021
…utility

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Jan 13, 2021
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Jan 18, 2021
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Jan 18, 2021
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Feb 22, 2021
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Mar 1, 2021
…downThread

Issue #5832 - shutdown Javax WSClientContainer with webapp if possible.
@lachlan-roberts
Copy link
Member

@lachlan-roberts lachlan-roberts commented Mar 1, 2021

Fixed with PR #5840.

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

Successfully merging a pull request may close this issue.

None yet
4 participants