Troubleshooting
To troubleshoot Jetty when used as a production server, there are two main tools: the Jetty Server Dump and enabling DEBUG level logging.
Jetty is based on components organized as a tree, with the Server
instance at the root of the tree.
As explained in the JMX section, these components can be exported as JMX MBeans and therefore be accessible from JMX Consoles such as Java Missions Control (JMC).
Being able to take a snapshot of the state of Jetty while it is running is the most useful information that can be attached when reporting an issue. Such state includes:
-
The thread pool configuration and its current state, including how many threads are in use, and their stack trace.
-
The TLS configuration.
-
The I/O configuration and its current state, including the ports Jetty listens to, how many connections are currently open, and he state of each connection, and the state of the request/response handling for each connection.
-
The
Handler
structure and its configuration. -
The web applications deployed and their configurations, including the class loader information.
The prerequisite for troubleshooting is to enable JMX, so that Jetty — possibly a production server — can be accessed from a remote location to obtain the information exported via JMX, and possibly be able to reconfigure Jetty to solve the issue.
Make sure you read about how to secure the access to Jetty when using remote JMX. |
Server Dump
The Jetty Server Dump is obtained by invoking, via JMX, the Server.dump()
operation, as shown below.
Find the Server
MBean in the MBean Tree, under org.eclipse.jetty.server:type=server,id=0
.
Then click on the "Operations" tab, select the dump()
operation, and then click the Execute
button.
In the bottom panel you will see the result of the invocation, that you can copy into a text editor and save to your file system.
Taking a Jetty Server Dump is a relatively expensive operation, as it dumps the state of all connections (which can be thousands), and the state of all threads. The result of the invocation may produce a large string, possibly few MiB, that may impact the server memory usage. Furthermore, dumping the state of the I/O Jetty components takes a little CPU time off the handling of the actual I/O, possibly slowing it down temporarily. While the slow-down caused by taking the Jetty Server Dump may be noticeable on highly loaded systems, it is typically a very small price to pay to obtain the information about the Jetty state that may be critical to the resolution of an issue. |
The format of the Jetty Server Dump output is subject to change at any time, as Jetty developers modify the Jetty code and decide to include more state, or remove state that is no longer relevant. The Jetty Server Dump is organized in a tree whose structure is similar to the runtime Jetty component tree. At the end of the dump output there is a legend that explains the type of tree node: whether it is a node that represent a managed component, or an array node (or a map node) that represent some component state, etc. |
Dump at Server Start/Stop
The Server.dump()
operation may also be invoked just after the Server
starts (to log the state of the freshly started server), and just before the Server
stops (which may be useful to log the state of server that is not working properly).
You can temporarily enable the Jetty Server Dump at start time by overriding the jetty.server.dumpAfterStart
property on the command line:
$ java -jar $JETTY_HOME/start.jar jetty.server.dumpAfterStart=true
To make this change persistent across server restarts, see the server
module configuration for more information about how to configure the server to dump at start/stop time.
Detailed ThreadPool Information
By default, the dump of the thread pool will only dump the topmost stack frame of each thread. It is possible to configure the thread pool to dump the whole stack trace for each thread; while this may be a little more expensive, it provides complete information about the state of each thread, which may be important to diagnose the issue.
See the threadpool
module configuration for more information about how to configure the thread pool to dump detailed thread information.
Detailed thread pool information can also be turned on/off on-the-fly via JMX, by finding the ThreadPool
MBean under org.eclipse.jetty.util.thread:type=queuedthreadpool,id=0
, then selecting the detailedDump
attribute and setting it to true
. You can now perform the Server.dump()
operation as explained above, and then set detailedDump
back to false
.
Dump Example
Below you can find a simple example of a Jetty Server Dump, with annotations for the principal components:
Server@6aba2b86{STARTING}[11.0.25-SNAPSHOT,sto=5000] - STARTING (1) += QueuedThreadPool[qtp640363654]@262b2c86{STARTED,4<=4<=200,i=2,r=-1,t=59951ms,q=0}[ReservedThreadExecutor@61322f9d{reserved=0/1,pending=0}] - STARTED (2) | +- org.eclipse.jetty.util.thread.ThreadPoolBudget@6ad82709 | += ReservedThreadExecutor@61322f9d{reserved=0/1,pending=0} - STARTED | | +> threads size=0 | +> threads size=4 | +> qtp640363654-16 TIMED_WAITING tid=16 prio=5 IDLE | +> qtp640363654-14 RUNNABLE tid=14 prio=5 SELECTING | +> qtp640363654-15-acceptor-0@2eea1863-ServerConnector@202df3ce{HTTP/1.1, (http/1.1)}{0.0.0.0:8080} RUNNABLE tid=15 prio=3 ACCEPTING | +> qtp640363654-17 TIMED_WAITING tid=17 prio=5 IDLE += AttributeContainerMap@41a2befb{size=0} - STARTED +- ArrayByteBufferPool@131ef10{minBufferCapacity=0, maxBufferCapacity=65536, maxQueueLength=-1, factor=4096} | +> java.util.ArrayList@82d52862(size=5) | +: HeapMemory: 0/236175360 | +: DirectMemory: 0/236175360 | +: Indirect Buckets size=0 | +: Direct Buckets size=0 | +: org.eclipse.jetty.io.ArrayByteBufferPool$Retained@55b0dcab{min=0,max=65536,buckets=16,heap=0/236175360,direct=0/236175360} | +> direct size=16 | | +> RetainedBucket@38afe297[inUse=0,size=0,max=-1,closed=false]{capacity=4096,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@7c9d8e2[inUse=0,size=0,max=-1,closed=false]{capacity=8192,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@20d525[inUse=0,size=0,max=-1,closed=false]{capacity=12288,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@6200f9cb[inUse=0,size=0,max=-1,closed=false]{capacity=16384,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@2002fc1d[inUse=0,size=0,max=-1,closed=false]{capacity=20480,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@69453e37[inUse=0,size=0,max=-1,closed=false]{capacity=24576,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@6f4a47c7[inUse=0,size=0,max=-1,closed=false]{capacity=28672,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@ae13544[inUse=0,size=0,max=-1,closed=false]{capacity=32768,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@3d34d211[inUse=0,size=0,max=-1,closed=false]{capacity=36864,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@7dc0f706[inUse=0,size=0,max=-1,closed=false]{capacity=40960,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@4009e306[inUse=0,size=0,max=-1,closed=false]{capacity=45056,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@43c1b556[inUse=0,size=0,max=-1,closed=false]{capacity=49152,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@587e5365[inUse=0,size=0,max=-1,closed=false]{capacity=53248,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@22fcf7ab[inUse=0,size=0,max=-1,closed=false]{capacity=57344,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@2de23121[inUse=0,size=0,max=-1,closed=false]{capacity=61440,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@63475ace[inUse=0,size=0,max=-1,closed=false]{capacity=65536,inuse=0(0%)} | | +> entries size=0 | +> indirect size=16 | +> RetainedBucket@4988d8b8[inUse=0,size=0,max=-1,closed=false]{capacity=4096,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@c0c2f8d[inUse=0,size=0,max=-1,closed=false]{capacity=8192,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@305b7c14[inUse=0,size=0,max=-1,closed=false]{capacity=12288,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@6913c1fb[inUse=0,size=0,max=-1,closed=false]{capacity=16384,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@66d18979[inUse=0,size=0,max=-1,closed=false]{capacity=20480,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@bccb269[inUse=0,size=0,max=-1,closed=false]{capacity=24576,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@609cd4d8[inUse=0,size=0,max=-1,closed=false]{capacity=28672,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@17f7cd29[inUse=0,size=0,max=-1,closed=false]{capacity=32768,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@7d8704ef[inUse=0,size=0,max=-1,closed=false]{capacity=36864,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@13b6aecc[inUse=0,size=0,max=-1,closed=false]{capacity=40960,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@158a8276[inUse=0,size=0,max=-1,closed=false]{capacity=45056,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@3c3d9b6b[inUse=0,size=0,max=-1,closed=false]{capacity=49152,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@79d8407f[inUse=0,size=0,max=-1,closed=false]{capacity=53248,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@5fbe4146[inUse=0,size=0,max=-1,closed=false]{capacity=57344,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@1e66f1f5[inUse=0,size=0,max=-1,closed=false]{capacity=61440,inuse=0(0%)} | | +> entries size=0 | +> RetainedBucket@4e50c791[inUse=0,size=0,max=-1,closed=false]{capacity=65536,inuse=0(0%)} | +> entries size=0 += ScheduledExecutorScheduler@17c1bced{STARTED} - STARTED += HandlerList@7530ad9c{STARTED} - STARTED (3) | += ContextHandlerCollection@58a9760d{STARTED} - STARTED | += DefaultHandler@71e9ddb4{STARTED} - STARTED += ServerConnector@202df3ce{HTTP/1.1, (http/1.1)}{0.0.0.0:8080} - STARTED (4) | +~ QueuedThreadPool[qtp640363654]@262b2c86{STARTED,4<=4<=200,i=2,r=-1,t=59912ms,q=0}[ReservedThreadExecutor@61322f9d{reserved=0/1,pending=0}] - STARTED | +~ ScheduledExecutorScheduler@17c1bced{STARTED} - STARTED | +~ ArrayByteBufferPool@131ef10{minBufferCapacity=0, maxBufferCapacity=65536, maxQueueLength=-1, factor=4096} | +- org.eclipse.jetty.io.ArrayByteBufferPool$Retained@55b0dcab{min=0,max=65536,buckets=16,heap=0/236175360,direct=0/236175360} | | +> direct size=16 | | | +> RetainedBucket@38afe297[inUse=0,size=0,max=-1,closed=false]{capacity=4096,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@7c9d8e2[inUse=0,size=0,max=-1,closed=false]{capacity=8192,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@20d525[inUse=0,size=0,max=-1,closed=false]{capacity=12288,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@6200f9cb[inUse=0,size=0,max=-1,closed=false]{capacity=16384,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@2002fc1d[inUse=0,size=0,max=-1,closed=false]{capacity=20480,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@69453e37[inUse=0,size=0,max=-1,closed=false]{capacity=24576,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@6f4a47c7[inUse=0,size=0,max=-1,closed=false]{capacity=28672,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@ae13544[inUse=0,size=0,max=-1,closed=false]{capacity=32768,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@3d34d211[inUse=0,size=0,max=-1,closed=false]{capacity=36864,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@7dc0f706[inUse=0,size=0,max=-1,closed=false]{capacity=40960,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@4009e306[inUse=0,size=0,max=-1,closed=false]{capacity=45056,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@43c1b556[inUse=0,size=0,max=-1,closed=false]{capacity=49152,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@587e5365[inUse=0,size=0,max=-1,closed=false]{capacity=53248,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@22fcf7ab[inUse=0,size=0,max=-1,closed=false]{capacity=57344,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@2de23121[inUse=0,size=0,max=-1,closed=false]{capacity=61440,inuse=0(0%)} | | | | +> entries size=0 | | | +> RetainedBucket@63475ace[inUse=0,size=0,max=-1,closed=false]{capacity=65536,inuse=0(0%)} | | | +> entries size=0 | | +> indirect size=16 | | +> RetainedBucket@4988d8b8[inUse=0,size=0,max=-1,closed=false]{capacity=4096,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@c0c2f8d[inUse=0,size=0,max=-1,closed=false]{capacity=8192,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@305b7c14[inUse=0,size=0,max=-1,closed=false]{capacity=12288,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@6913c1fb[inUse=0,size=0,max=-1,closed=false]{capacity=16384,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@66d18979[inUse=0,size=0,max=-1,closed=false]{capacity=20480,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@bccb269[inUse=0,size=0,max=-1,closed=false]{capacity=24576,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@609cd4d8[inUse=0,size=0,max=-1,closed=false]{capacity=28672,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@17f7cd29[inUse=0,size=0,max=-1,closed=false]{capacity=32768,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@7d8704ef[inUse=0,size=0,max=-1,closed=false]{capacity=36864,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@13b6aecc[inUse=0,size=0,max=-1,closed=false]{capacity=40960,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@158a8276[inUse=0,size=0,max=-1,closed=false]{capacity=45056,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@3c3d9b6b[inUse=0,size=0,max=-1,closed=false]{capacity=49152,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@79d8407f[inUse=0,size=0,max=-1,closed=false]{capacity=53248,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@5fbe4146[inUse=0,size=0,max=-1,closed=false]{capacity=57344,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@1e66f1f5[inUse=0,size=0,max=-1,closed=false]{capacity=61440,inuse=0(0%)} | | | +> entries size=0 | | +> RetainedBucket@4e50c791[inUse=0,size=0,max=-1,closed=false]{capacity=65536,inuse=0(0%)} | | +> entries size=0 | +- org.eclipse.jetty.server.AbstractConnector$1@394df057 | += HttpConnectionFactory@7e0b85f9[HTTP/1.1] - STARTED | | +- HttpConfiguration@1190200a{32768/8192,8192/8192,https://:0,[]} | | +> customizers size=0 | | +> formEncodedMethods size=2 | | | +> POST | | | +> PUT | | +> outputBufferSize=32768 | | +> outputAggregationSize=8192 | | +> requestHeaderSize=8192 | | +> responseHeaderSize=8192 | | +> headerCacheSize=1024 | | +> secureScheme=https | | +> securePort=0 | | +> idleTimeout=-1 | | +> sendDateHeader=false | | +> sendServerVersion=true | | +> sendXPoweredBy=false | | +> delayDispatchUntilContent=true | | +> persistentConnectionsEnabled=true | | +> maxErrorDispatches=10 | | +> minRequestDataRate=0 | | +> minResponseDataRate=0 | | +> requestCookieCompliance=RFC6265@707194ba[INVALID_COOKIES, OPTIONAL_WHITE_SPACE, SPACE_IN_VALUES] | | +> responseCookieCompliance=RFC6265@707194ba[INVALID_COOKIES, OPTIONAL_WHITE_SPACE, SPACE_IN_VALUES] | | +> notifyRemoteAsyncErrors=true | | +> relativeRedirectAllowed=false | += SelectorManager@ServerConnector@202df3ce{HTTP/1.1, (http/1.1)}{0.0.0.0:8080} - STARTED | | += ManagedSelector@291caca8{STARTED} id=0 keys=0 selected=0 updates=0 - STARTED (5) | | += AdaptiveExecutionStrategy@385e9564/SelectorProducer@5b94b04d/PRODUCING/p=false/QueuedThreadPool[qtp640363654]@262b2c86{STARTED,4<=4<=200,i=2,r=-1,t=59876ms,q=0}[ReservedThreadExecutor@61322f9d{reserved=0/1,pending=0}][pc=0,pic=0,pec=0,epc=0]@2024-12-11T16:10:02.72054948Z - STARTED | | | +- SelectorProducer@5b94b04d | | | +~ QueuedThreadPool[qtp640363654]@262b2c86{STARTED,4<=4<=200,i=2,r=-1,t=59875ms,q=0}[ReservedThreadExecutor@61322f9d{reserved=0/1,pending=0}] - STARTED | | +> updates @ 2024-12-11T16:10:02.7139238Z size=0 | | +> keys @ 2024-12-11T16:10:02.716102696Z size=0 (6) | +- sun.nio.ch.ServerSocketChannelImpl[/[0:0:0:0:0:0:0:0]:8080] | +- qtp640363654-15-acceptor-0@2eea1863-ServerConnector@202df3ce{HTTP/1.1, (http/1.1)}{0.0.0.0:8080} +- org.eclipse.jetty.util.component.HaltLifeCycleListener@8c3b9d += ErrorHandler@4c39bec8{STARTED} - STARTED +> startJarLoader@606d8acf (7) +> URLs size=9 | +> file:/path/to/jetty.home-base/resources/ | +> file:/path/to/jetty.home/lib/logging/slf4j-api-2.0.13.jar | +> file:/path/to/jetty.home/lib/logging/jetty-slf4j-impl-11.0.25-SNAPSHOT.jar | +> file:/path/to/jetty.home/lib/jetty-jakarta-servlet-api-5.0.2.jar | +> file:/path/to/jetty.home/lib/jetty-http-11.0.25-SNAPSHOT.jar | +> file:/path/to/jetty.home/lib/jetty-server-11.0.25-SNAPSHOT.jar | +> file:/path/to/jetty.home/lib/jetty-xml-11.0.25-SNAPSHOT.jar | +> file:/path/to/jetty.home/lib/jetty-util-11.0.25-SNAPSHOT.jar | +> file:/path/to/jetty.home/lib/jetty-io-11.0.25-SNAPSHOT.jar +> jdk.internal.loader.ClassLoaders$AppClassLoader@694355ec +> packages size=4 | +> package org.eclipse.jetty.start.config | +> package org.eclipse.jetty.start.builders | +> package org.eclipse.jetty.start.shaded.util | +> package org.eclipse.jetty.start +> jdk.internal.loader.ClassLoaders$PlatformClassLoader@561b6512 +> packages size=2 +> package sun.util.resources.provider +> package sun.util.resources.cldr.provider key: +- bean, += managed, +~ unmanaged, +? auto, +: iterable, +] array, +@ map, +> undefined (8)
1 | The Server instance at the root of the tree |
2 | The thread pool component |
3 | The root of the Handler structure |
4 | The connector listening on port 8080 for the HTTP/1.1 protocol |
5 | A selector component that manages connections |
6 | The connections currently managed by the selector component |
7 | The server ClassLoader and its classpath |
8 | The legend for the dump nodes |
Enabling DEBUG Logging
Enabling DEBUG level logging for the org.eclipse.jetty
logger name provides the maximum amount of information to troubleshoot Jetty issues.
Refer to the logging section for more information about how to configure logging in Jetty.
Enabling DEBUG level logging for Your server could be slowed down to almost a halt, especially if it is under heavy load. Furthermore, the log file could quickly fill up the entire filesystem (unless configured to roll over), so you want to be really careful using DEBUG logging. For production servers, consider using the Jetty Server Dump first, and enable DEBUG logging only as a last resort. |
However, sometimes issues are such that only DEBUG logging can really tell what’s going on in the system, and enabling DEBUG logging is your best chance to figure the issue out. Below you can find few suggestions that can help you reduce the impact when you have to enable DEBUG logging.
Jetty Behind a Load Balancer
If Jetty instances are behind a load balancer, you may configure the load balancer to send less load to a particular Jetty instance, and enable DEBUG logging in that instance only.
Enabling DEBUG Logging for a Short Time
In certain cases the issue can be reproduced reliably, but only in the production environment.
You can use JMX to temporarily enable DEBUG logging, reproduce the issue, and then disable DEBUG logging.
Alternatively, if you cannot reliably reproduce the issue, but you know it is happening, you can temporarily enable DEBUG logging for a small period of time, let’s say 10-60 seconds, and then disable DEBUG logging.
Changing the log level at runtime is a feature of the logging implementation that you are using.
The Jetty SLF4J implementation, used by default, exposes via JMX method boolean JettyLoggerFactoryMBean.setLoggerLevel(String loggerName, String levelName)
that you can invoke via a JMX console to change the level for the specified logger name.
The method returns true
if the logger level was successfully changed.
For example, you can pass the string org.eclipse.jetty
as the first parameter, and the string DEBUG
(upper case) as the second parameter.
You can then use the string INFO
or WARN
(upper case) to restore the logging level to its previous value.
Enabling DEBUG Logging for SubPackages
Enabling DEBUG logging for the org.eclipse.jetty
logger name implies that all children logger names, recursively, inherit the DEBUG level.
Processing a single HTTP request involves many Jetty components: the I/O subsystem (under org.eclipse.jetty.io
), the thread pool (under org.eclipse.jetty.util
), the HTTP/1.1 parsing (under org.eclipse.jetty.http
), etc.
If you can cut the amount of DEBUG logging to just what you need to troubleshoot the issue, the impact of enabling DEBUG logging will be much less than enabling it for all Jetty components.
For example, if you need to troubleshoot a client that sends bad HTTP/1.1 requests, it may be enough to enable only the org.eclipse.jetty.http
logger name, therefore saving the large amount of DEBUG logging produced by the I/O subsystem and by the thread pool.
In another case, you may need to troubleshoot only HTTP/2 requests, and therefore enabling only the org.eclipse.jetty.http2
logger name could be enough.
Remote Debugging
The Java Virtual Machines allows remote processes on different hosts to connect for debugging purposes, by using specific command line options.
While it is possible to enable remote debugging on a Jetty server, it is typically not recommended for security and performance reasons. Only enable remote debugging on a Jetty server as a last resort to troubleshoot issues that could not be troubleshot otherwise. |
You can easily create a custom Jetty module (see this section) with the following content:
[description] Enables remote debugging [exec] -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
The [exec]
directive (documented here) is necessary to pass the -agentlib:jdwp
JVM option to the forked JVM that runs Jetty, so that you can attach with a debugger.
The Please refer to the Java Debug Wire Protocol documentation for additional information about the |
You can now enable the remote-debug
Jetty module with the following command issued from the $JETTY_BASE
directory:
$ java -jar $JETTY_HOME/start.jar --add-modules=server,remote-debug
The command above minimally adds a Jetty server without connectors (via the server
Jetty module) and the remote-debug
Jetty module, and produces the following $JETTY_BASE
directory structure:
$JETTY_BASE
├── modules
│ └── remote-debug.mod
├── resources
│ └── jetty-logging.properties
└── start.d
├── remote-debug.ini
└── server.ini
You can easily disable the remote-debug
Jetty module as explained in this section.
Alternatively, you can enable the remote-debug
module on the command line, as explained in this section.
Starting the Jetty server with the remote-debug
module enabled yields:
WARN : Forking second JVM due to forking module(s): [remote-debug]. Use --dry-run to generate the command line to avoid forking. Listening for transport dt_socket at address: 5005 2024-12-11 16:10:05.849:INFO :oejs.Server:main: jetty-11.0.25-SNAPSHOT; built: 2024-12-11T15:58:48.158Z; git: c9200a52f227cfa7710e6c901e52067e34fc3388; jvm 23.0.1+11 2024-12-11 16:10:05.926:INFO :oejs.Server:main: Started Server@6236eb5f{STARTING}[11.0.25-SNAPSHOT,sto=5000] @813ms
Note how the JVM is listening on port 5005
to allow remote debuggers to connect.
If you want to avoid to fork a second JVM to pass the -agentlib:jdwp
JVM option, please read this section.