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

时间:2015-12-19 10:23:40

标签: java maven nanohttpd

我想为我的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)和OpenJDK with Java版本:1.7.0_85,供应商:Oracle Corporation 上 操作系统名称:“linux”,版本:“2.6.32-573.1.1.el6.x86_64”,arch:“amd64”,系列:“unix” 使用CentOS 6.4。

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

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

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

另见:https://stackoverflow.com/a/25166013/259988