gpt4 book ai didi

java - nanohttpd 演示应用程序在 15 秒后崩溃

转载 作者:行者123 更新时间:2023-12-01 10:42:30 28 4
gpt4 key购买 nike

我想为我的Java程序找到一个轻量级的http服务,经过研究,我发现nanohttpd很轻,只有一个java页面,而且安装很方便,所以我想用这个框架来包装我的Java程序。

我已经尝试过nanohttpd github页面上的教程,一切都很好,但是对于最后一步,

    mvn exec:java -Dexec.mainClass="com.example.App"

显示此信息后大约 15 秒后崩溃

[root@zhangruichang-test-dev001-shgq myHellopApp]# mvn exec:java -
Dexec.mainClass="com.example.App"
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building myHellopApp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ myHellopApp ---
ready to start

Running! Point your browers to http://localhost:8080/

[WARNING] thread Thread[NanoHttpd Main Listener,5,com.example.App] was interrupted but is still alive after waiting at least 15000msecs
[WARNING] thread Thread[NanoHttpd Main Listener,5,com.example.App] will linger despite being asked to die via interruption
[WARNING] NOTE: 1 thread(s) did not finish despite being asked to via interruption. This is not a problem with exec:java, it is a problem with the running code. Although not serious, it should be remedied.
[WARNING] Couldn't destroy threadgroup org.codehaus.mojo.exec.ExecJavaMojo$IsolatedThreadGroup[name=com.example.App,maxpri=10]
java.lang.IllegalThreadStateException
at java.lang.ThreadGroup.destroy(ThreadGroup.java:775)
at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:328)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.491s
[INFO] Finished at: Fri Dec 18 19:24:39 CST 2015
[INFO] Final Memory: 12M/144M
[INFO] ------------------------------------------------------------------------

目前我已经用谷歌搜索过它,但没有任何最相关的问题。

我用Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 21:51:28+0800) 和 OpenJDKJava版本:1.7.0_85,供应商:Oracle Corporation在操作系统名称:“linux”,版本:“2.6.32-573.1.1.el6.x86_64”,arch:“amd64”,系列:“unix”使用 CentOS 6.4。

有人可以帮助我吗?

最佳答案

也许是一个提示:您可以更改“exec-maven-plugin”以告诉它不要杀死守护线程。例如:

<configuration>
<mainClass>com.test.Startup</mainClass>
<cleanupDaemonThreads>false</cleanupDaemonThreads>
</configuration>

另请参阅:https://stackoverflow.com/a/25166013/259988

关于java - nanohttpd 演示应用程序在 15 秒后崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34369649/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com