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

java.lang.NoClassDefFoundError: when having port conflict #1356

Closed
nano-bot opened this issue Feb 25, 2017 · 8 comments
Closed

java.lang.NoClassDefFoundError: when having port conflict #1356

nano-bot opened this issue Feb 25, 2017 · 8 comments
Assignees
Labels
Bug For general bugs on Jetty side Low Priority

Comments

@nano-bot
Copy link

Starting with 9.3.15.v20161220 jetty-maven-plugin throws NoClassDefError when running jetty:run twice and therefore port conflict occurs. It looks like when there's port conflict some sort of exception is thrown, but it can't be find in plugin binary.

Steps to reproduce:

  • Create simple web app with maven using jetty-maven-plugin
  • Invoke mvn jetty:run - normal app startup is done
  • Invoke mvn jetty:run after previous step is completed

Expected:
Simple error message about port conflict:
[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.3.2.v20150730:run (default-cli) on project registration: Failure: Address already in use -> [Help 1]

Actual:

[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.3.15.v20161220:run (default-cli) on project registration: Failure: Address already in use -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Exception in thread "Thread-1" java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: org/eclipse/jetty/http/pathmap/MappedResource
        at org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration.doStop(NativeWebSocketConfiguration.java:63)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.stop(ContainerLifeCycle.java:142)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStop(ContainerLifeCycle.java:160)
        at org.eclipse.jetty.websocket.jsr356.ClientContainer.doStop(ClientContainer.java:205)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.stop(AbstractLifeCycle.java:89)
        at org.eclipse.jetty.util.thread.ShutdownThread.run(ShutdownThread.java:138)
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jetty/http/pathmap/MappedResource
        ... 7 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.http.pathmap.MappedResource
        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)
        ... 7 more
@joakime joakime self-assigned this Feb 27, 2017
@joakime
Copy link
Contributor

joakime commented Feb 27, 2017

Confirmed. Can be easily replicated with the following barebones project.

issue1356.tar.gz

Note: this is an error during shutdown/stop.

@joakime joakime assigned janbartel and unassigned joakime Feb 27, 2017
@joakime joakime added the Bug For general bugs on Jetty side label Feb 27, 2017
@janbartel
Copy link
Contributor

@nano-bot the tricky thing here is that jetty relies on a Shutdown thread to shut down properly. However, because the maven plugin is throwing an error, maven is taking away the classloader before the Shutdown thread can execute.

@pauldaustin
Copy link

In my case it's happening in a multi module process. See #1409 for comments.

For jetty:start are you forking an external process to run jetty. To me that would be the best approach as you want it to continue to run after maven has finished.

@joakime
Copy link
Contributor

joakime commented Mar 21, 2017

"continue to run after maven has finished" is worrisome.

the jetty-maven-plugin is designed for development time only.
Its not designed for production use.

In fact, its downright dangerous to run that way, as there's far too many artifacts in the classloader for a secure system (think all of maven + your build + its plugins for the entire reactor).

@janbartel
Copy link
Contributor

@pauldaustin neither the "start" goal nor the "run" goal fork another process - they both execute in-process in maven. "start" is designed to be bound into a lifecycle execution in your pom, and work alongside the "stop" goal also bound to a lifecycle phase. The "run" goal is instead designed to be executed on the command line. The "stop" goal can also be run on the command line. If you wanted to start a forked jetty instance, then you need to use the "run-forked" command line goal instead.

So let's rewind back to your original post. I assumed that you were running "mvn jetty:run" twice in 2 different windows for some undisclosed purpose. However, after your other post on #1409 it occurs to me that you might not be using the plugin correctly. Perhaps you should have the "start" goal bound to a lifecycle execution phase in each of your war module poms.

@pauldaustin
Copy link

I thought my client was intending to run jetty using the maven jetty plugin (they are on a development server using jetty:run). I have now confirmed that is not the case for production so this is now not an issue.

@janbartel
Copy link
Contributor

Closing issue.

@surveshoeb
Copy link

After upgrading jetty to version 9.4, I'm getting the following issue while the initializing server class

E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
Process: com.abacus.ijettyexample, PID: 20597
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:353)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.BootstrapMethodError: Exception from call site #79 bootstrap method
at org.eclipse.jetty.util.thread.TryExecutor.(TryExecutor.java:78)
at org.eclipse.jetty.server.Server.(Server.java:135)
at org.eclipse.jetty.server.Server.(Server.java:110)
at com.abacus.ijettyexample.MainActivity$startServer.doInBackground(MainActivity.java:188)
at com.abacus.ijettyexample.MainActivity$startServer.doInBackground(MainActivity.java:181)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 
at java.lang.Thread.run(Thread.java:764) 
Caused by: java.lang.NoClassDefFoundError: Invalid descriptor: val$result.
at org.eclipse.jetty.util.thread.TryExecutor.(TryExecutor.java:78) 
at org.eclipse.jetty.server.Server.(Server.java:135) 
at org.eclipse.jetty.server.Server.(Server.java:110) 
at com.abacus.ijettyexample.MainActivity$startServer.doInBackground(MainActivity.java:188) 
at com.abacus.ijettyexample.MainActivity$startServer.doInBackground(MainActivity.java:181) 
at android.os.AsyncTask$2.call(AsyncTask.java:333) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 
at java.lang.Thread.run(Thread.java:764) 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side Low Priority
Projects
None yet
Development

No branches or pull requests

5 participants