Jetty – Stop a Jetty Server by Command

本文介绍了如何通过命令行启动Jetty服务器,并提供了一种在另一个shell提示符中使用特定命令停止正在运行的Jetty服务器的方法。为了实现这一功能,需要在启动命令中指定STOP.PORT和STOP.KEY。

Jetty – Stop a Jetty Server by Command

To start a Jetty Server, you can type the following command.

java -jar start.jar

 

The only way to stop the Jetty Server is by pressing Ctrl + C in the shell prompt.

Actually, there is a way to issue a stop command to the Jetty Server on another shell prompt. But you have to specify the STOP.PORT and STOP.KEY in the start command as follow.

java -DSTOP.PORT=8080 -DSTOP.KEY=stop_jetty -jar start.jar

 

After the Jetty Server is started, you can open another shell prompt and stop the Jetty by

java -DSTOP.PORT=8080 -DSTOP.KEY=stop_jetty -jar start.jar --stop
HTTP ERROR 500 java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because "oldAlg" is null URI: /setup/setup-host-settings.jsp STATUS: 500 MESSAGE: java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because "oldAlg" is null SERVLET: org.jivesoftware.openfire.admin.setup.setup_002dhost_002dsettings_jsp CAUSED BY: java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because "oldAlg" is null Caused by: java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because "oldAlg" is null at org.jivesoftware.util.JiveGlobals.setupPropertyEncryptionAlgorithm(JiveGlobals.java:1088) at org.jivesoftware.openfire.admin.setup.setup_002dhost_002dsettings_jsp._jspService(setup_002dhost_002dsettings_jsp.java:265) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:64) at javax.servlet.http.HttpServlet.service(HttpServlet.java:590) at org.eclipse.jetty.ee8.servlet.ServletHolder$NotAsync.service(ServletHolder.java:1160) at org.eclipse.jetty.ee8.servlet.ServletHolder.handle(ServletHolder.java:649) at org.eclipse.jetty.ee8.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1374) at com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:182) at com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:85) at org.eclipse.jetty.ee8.servlet.FilterHolder.doFilter(FilterHolder.java:171) at org.eclipse.jetty.ee8.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1348) at org.jivesoftware.util.LocaleFilter.doFilter(LocaleFilter.java:73) at org.eclipse.jetty.ee8.servlet.FilterHolder.doFilter(FilterHolder.java:171) at org.eclipse.jetty.ee8.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1348) at org.jivesoftware.util.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:38) at org.eclipse.jetty.ee8.servlet.FilterHolder.doFilter(FilterHolder.java:171) at org.eclipse.jetty.ee8.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1348) at org.jivesoftware.admin.PluginFilter.doFilter(PluginFilter.java:170) at org.eclipse.jetty.ee8.servlet.FilterHolder.doFilter(FilterHolder.java:171) at org.eclipse.jetty.ee8.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1348) at org.jivesoftware.admin.AuthCheckFilter.doFilter(AuthCheckFilter.java:290) at org.eclipse.jetty.ee8.servlet.FilterHolder.doFilter(FilterHolder.java:177) at org.eclipse.jetty.ee8.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1348) at org.jivesoftware.admin.ContentSecurityPolicyFilter.doFilter(ContentSecurityPolicyFilter.java:53) at org.eclipse.jetty.ee8.servlet.FilterHolder.doFilter(FilterHolder.java:171) at org.eclipse.jetty.ee8.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1348) at org.eclipse.jetty.ee8.servlet.ServletHandler.doHandle(ServletHandler.java:454) at org.eclipse.jetty.ee8.nested.ScopedHandler.handle(ScopedHandler.java:119) at org.eclipse.jetty.ee8.security.SecurityHandler.handle(SecurityHandler.java:497) at org.eclipse.jetty.ee8.nested.HandlerWrapper.handle(HandlerWrapper.java:108) at org.eclipse.jetty.ee8.nested.ScopedHandler.nextHandle(ScopedHandler.java:183) at org.eclipse.jetty.ee8.nested.SessionHandler.doHandle(SessionHandler.java:519) at org.eclipse.jetty.ee8.nested.ScopedHandler.nextHandle(ScopedHandler.java:181) at org.eclipse.jetty.ee8.nested.ContextHandler.doHandle(ContextHandler.java:885) at org.eclipse.jetty.ee8.nested.ScopedHandler.nextScope(ScopedHandler.java:152) at org.eclipse.jetty.ee8.servlet.ServletHandler.doScope(ServletHandler.java:423) at org.eclipse.jetty.ee8.nested.ScopedHandler.nextScope(ScopedHandler.java:150) at org.eclipse.jetty.ee8.nested.SessionHandler.doScope(SessionHandler.java:503) at org.eclipse.jetty.ee8.nested.ScopedHandler.nextScope(ScopedHandler.java:150) at org.eclipse.jetty.ee8.nested.ContextHandler.doScope(ContextHandler.java:830) at org.eclipse.jetty.ee8.nested.ScopedHandler.handle(ScopedHandler.java:117) at org.eclipse.jetty.ee8.nested.ContextHandler.handle(ContextHandler.java:1443) at org.eclipse.jetty.ee8.nested.HttpChannel$RequestDispatchable.dispatch(HttpChannel.java:1290) at org.eclipse.jetty.ee8.nested.HttpChannel.dispatch(HttpChannel.java:617) at org.eclipse.jetty.ee8.nested.HttpChannel.handle(HttpChannel.java:460) at org.eclipse.jetty.ee8.nested.ContextHandler$CoreContextHandler$CoreToNestedHandler.handle(ContextHandler.java:2512) at org.eclipse.jetty.server.handler.ContextHandler.handle(ContextHandler.java:1071) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:151) at org.eclipse.jetty.server.Handler$Sequence.handle(Handler.java:805) at org.eclipse.jetty.server.Server.handle(Server.java:182) at org.eclipse.jetty.server.internal.HttpChannelState$HandlerInvoker.run(HttpChannelState.java:677) at org.eclipse.jetty.server.internal.HttpConnection.onFillable(HttpConnection.java:416) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:322) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:99) at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53) at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:480) at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:443) at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:293) at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:201) at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:311) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:981) at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1211) at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1166) at java.base/java.lang.Thread.run(Thread.java:833) [root@yfw ~]# cd /opt/openfire/bin [root@yfw bin]# kill -9 1183108 [root@yfw bin]# lsof -i :9090 || echo "Port 9090 is now free" COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java 1185283 openfire 151u IPv6 18970472 0t0 TCP *:websm (LISTEN) [root@yfw bin]# systemctl status openfire ● openfire.service - OpenFire XMPP Server Loaded: loaded (/etc/systemd/system/openfire.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2025-11-15 15:23:53 CST; 1min 39s ago Process: 1158688 ExecStop=/opt/openfire/bin/stop.sh (code=exited, status=0/SUCCESS) Main PID: 1185283 (java) Tasks: 34 (limit: 23712) Memory: 180.5M CGroup: /system.slice/openfire.service └─1185283 /usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64/bin/java -server -Xms64m -Xm> Nov 15 15:23:53 yfw.szrengjing.com systemd[1]: Started OpenFire XMPP Server. Nov 15 15:23:53 yfw.szrengjing.com start.sh[1185282]: Starting OpenFire server using Java: /usr/lib/jvm/j> Nov 15 15:23:53 yfw.szrengjing.com start.sh[1185282]: OpenFire started successfully (PID 1185283) Nov 15 15:23:53 yfw.szrengjing.com start.sh[1185282]: Log output: tail -f /opt/openfire/logs/nohup.out Nov 15 15:23:53 yfw.szrengjing.com start.sh[1185282]: Web Console: http://192.168.0.142 172.18.0.1 172.23> [root@yfw bin]# sudo systemctl stop openfire [root@yfw bin]# lsof -i :9090 || echo "Port 9090 is now free" Port 9090 is now free [root@yfw bin]# rm -f /opt/openfire/logs/openfire.pid [root@yfw bin]# > /opt/openfire/logs/nohup.out [root@yfw bin]# sudo systemctl start openfire [root@yfw bin]# systemctl status openfire ● openfire.service - OpenFire XMPP Server Loaded: loaded (/etc/systemd/system/openfire.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2025-11-15 15:28:48 CST; 11s ago Process: 1186273 ExecStop=/opt/openfire/bin/stop.sh (code=exited, status=0/SUCCESS) Main PID: 1186448 (java) Tasks: 37 (limit: 23712) Memory: 163.4M CGroup: /system.slice/openfire.service └─1186448 /usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64/bin/java -server -Xms64m -Xm> Nov 15 15:28:48 yfw.szrengjing.com systemd[1]: Started OpenFire XMPP Server. Nov 15 15:28:48 yfw.szrengjing.com start.sh[1186447]: Starting OpenFire server using Java: /usr/lib/jvm/j> Nov 15 15:28:48 yfw.szrengjing.com start.sh[1186447]: OpenFire started successfully (PID 1186448) Nov 15 15:28:48 yfw.szrengjing.com start.sh[1186447]: Log output: tail -f /opt/openfire/logs/nohup.out Nov 15 15:28:48 yfw.szrengjing.com start.sh[1186447]: Web Console: http://192.168.0.142 172.18.0.1 172.23> [root@yfw bin]# journalctl -u openfire.service -f -- Logs begin at Fri 2025-11-14 14:13:59 CST. -- Nov 15 15:28:06 yfw.szrengjing.com stop.sh[1186273]: Stopping OpenFire (PID 1185283)... Nov 15 15:28:06 yfw.szrengjing.com systemd[1]: openfire.service: Main process exited, code=exited, status=143/n/a Nov 15 15:28:07 yfw.szrengjing.com stop.sh[1186273]: Stopped. Nov 15 15:28:07 yfw.szrengjing.com systemd[1]: openfire.service: Failed with result 'exit-code'. Nov 15 15:28:07 yfw.szrengjing.com systemd[1]: Stopped OpenFire XMPP Server. Nov 15 15:28:48 yfw.szrengjing.com systemd[1]: Started OpenFire XMPP Server. Nov 15 15:28:48 yfw.szrengjing.com start.sh[1186447]: Starting OpenFire server using Java: /usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64/bin/java Nov 15 15:28:48 yfw.szrengjing.com start.sh[1186447]: OpenFire started successfully (PID 1186448) Nov 15 15:28:48 yfw.szrengjing.com start.sh[1186447]: Log output: tail -f /opt/openfire/logs/nohup.out Nov 15 15:28:48 yfw.szrengjing.com start.sh[1186447]: Web Console: http://192.168.0.142 172.18.0.1 172.23.0.1 172.17.0.1 172.19.0.1 172.20.0.1:9090 ^C [root@yfw bin]# ls -l /opt/openfire/conf/security.xml ls: cannot access '/opt/openfire/conf/security.xml': No such file or directory [root@yfw bin]# sudo su - openfire -s /bin/bash -c ' > cat > /opt/openfire/conf/security.xml << EOF > <?xml version="1.0" encoding="UTF-8"?> > <!-- > security.xml - 默认安全配置文件 > 用于 OpenFire 首次启动时加载管理员控制台和 SASL 设置 > --> > <jive> > <adminConsole> > <!-- Web 管理控制台端口 --> > <port>9090</port> > <!-- HTTPS 安全端口(可选) --> > <securePort>9091</securePort> > <!-- 是否启用安全连接 --> > <secure>false</secure> > </adminConsole> > <sasl> > <!-- 启用 SASL 认证机制 --> > <active>true</active> > </sasl> > </jive> > EOF > ' ✅ Environment loaded for openfire PATH = /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/lib/jvm/java-11-openjdk/bin:/opt/maven/bin:/usr/local/ffmpeg/bin:/opt/spark/bin JAVA_HOME = /usr/lib/jvm/java-11-openjdk [root@yfw bin]# chown -R openfire:openfire /opt/openfire/conf [root@yfw bin]# chmod 644 /opt/openfire/conf/security.xml [root@yfw bin]# ls -l /opt/openfire/conf/security.xml -rw-r--r-- 1 openfire openfire 544 Nov 15 15:33 /opt/openfire/conf/security.xml [root@yfw bin]# sudo systemctl restart openfire [root@yfw bin]# journalctl -u openfire.service -f --since "30 seconds ago" -- Logs begin at Fri 2025-11-14 14:13:59 CST. -- Nov 15 15:34:33 yfw.szrengjing.com systemd[1]: Stopping OpenFire XMPP Server... Nov 15 15:34:33 yfw.szrengjing.com stop.sh[1187749]: Stopping OpenFire (PID 1186448)... Nov 15 15:34:33 yfw.szrengjing.com systemd[1]: openfire.service: Main process exited, code=exited, status=143/n/a Nov 15 15:34:34 yfw.szrengjing.com stop.sh[1187749]: Stopped. Nov 15 15:34:34 yfw.szrengjing.com systemd[1]: openfire.service: Failed with result 'exit-code'. Nov 15 15:34:34 yfw.szrengjing.com systemd[1]: Stopped OpenFire XMPP Server. Nov 15 15:34:34 yfw.szrengjing.com systemd[1]: Started OpenFire XMPP Server. Nov 15 15:34:34 yfw.szrengjing.com start.sh[1187757]: Starting OpenFire server using Java: /usr/lib/jvm/java-17-openjdk-17.0.1.0.12-2.el8_5.x86_64/bin/java Nov 15 15:34:34 yfw.szrengjing.com start.sh[1187757]: OpenFire started successfully (PID 1187759) Nov 15 15:34:34 yfw.szrengjing.com start.sh[1187757]: Log output: tail -f /opt/openfire/logs/nohup.out Nov 15 15:34:34 yfw.szrengjing.com start.sh[1187757]: Web Console: http://192.168.0.142 172.18.0.1 172.23.0.1 172.17.0.1 172.19.0.1 172.20.0.1:9090
11-16
[root@yfw system]# cat /opt/openfire/logs/openfire.log 2025.11.15 10:58:06.420 INFO [main]: org.jivesoftware.openfire.XMPPServer - Registering shutdown hook (standalone mode) 2025.11.15 10:58:06.989 INFO [main]: org.jivesoftware.util.cache.ConsistencyMonitor - Applying configuration for cache consistency check. Enabled: false 2025.11.15 10:58:07.021 INFO [main]: org.jivesoftware.openfire.XMPPServer - Openfire 5.0.2 [Nov 15, 2025, 10:58:07 AM] 2025.11.15 10:58:07.316 WARN [PluginMonitorTask-2]: org.jivesoftware.openfire.container.AdminConsolePlugin - Admin console: CertificateStoreManager has not been initialized yet. HTTPS will be unavailable. 2025.11.15 10:58:07.441 ERROR [PluginMonitorTask-2]: org.jivesoftware.openfire.container.AdminConsolePlugin - Could not start admin console server java.io.IOException: Failed to bind to ::/[0:0:0:0:0:0:0:0]:9090 at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:349) ~[jetty-server-12.0.24.jar:12.0.24] at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:313) ~[jetty-server-12.0.24.jar:12.0.24] at org.eclipse.jetty.server.Server.lambda$doStart$0(Server.java:571) ~[jetty-server-12.0.24.jar:12.0.24] at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[?:?] at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?] at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[?:?] at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) ~[?:?] at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?] at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?] at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[?:?] at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[?:?] at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?] at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?] at org.eclipse.jetty.server.Server.doStart(Server.java:567) ~[jetty-server-12.0.24.jar:12.0.24] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:93) ~[jetty-util-12.0.24.jar:12.0.24] at org.jivesoftware.openfire.container.AdminConsolePlugin.startup(AdminConsolePlugin.java:269) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.container.AdminConsolePlugin.initializePlugin(AdminConsolePlugin.java:373) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.container.PluginManager.loadPlugin(PluginManager.java:637) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.container.PluginMonitor$MonitorTask.run(PluginMonitor.java:338) [xmppserver-5.0.2.jar:5.0.2] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?] at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) [?:?] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) [?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?] at java.lang.Thread.run(Thread.java:833) [?:?] Caused by: java.net.BindException: Address already in use at sun.nio.ch.Net.bind0(Native Method) ~[?:?] at sun.nio.ch.Net.bind(Net.java:555) ~[?:?] at sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337) ~[?:?] at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294) ~[?:?] at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:344) ~[jetty-server-12.0.24.jar:12.0.24] ... 24 more 2025.11.15 10:58:07.450 INFO [PluginMonitorTask-2]: org.jivesoftware.openfire.container.PluginManager - Successfully loaded plugin 'admin'. 2025.11.15 11:26:32.129 ERROR [main]: org.jivesoftware.openfire.XMPPServer - null java.io.FileNotFoundException: null at org.jivesoftware.openfire.XMPPServer.locateOpenfire(XMPPServer.java:1126) ~[xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.initialize(XMPPServer.java:365) ~[xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:658) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:221) [xmppserver-5.0.2.jar:5.0.2] at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?] at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) [?:?] at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [?:?] at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) [?:?] at java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) [?:?] at jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347) [?:?] at java.lang.Class.newInstance(Class.java:645) [?:?] at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:92) [startup.jar:5.0.2] at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56) [startup.jar:5.0.2] 2025.11.15 11:26:32.178 WARN [main]: org.jivesoftware.util.JiveGlobals - Default properties have not been loaded from file. Using a non-persisting dummy properties object. [root@yfw system]#
最新发布
11-16
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值