【问题标题】:nanohttpd demo App crashed after 15secondsnanohttpd 演示应用程序在 15 秒后崩溃
【发布时间】:2016-06-10 22:31:52
【问题描述】:

我想为我的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 Java 版本:1.7.0_85,供应商:甲骨文公司 上 操作系统名称:“linux”,版本:“2.6.32-573.1.1.el6.x86_64”,arch:“amd64”,家族:“unix” 使用 CentOS 6.4。

谁能帮帮我?

【问题讨论】:

    标签: java maven nanohttpd


    【解决方案1】:

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

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

    参见此处:https://stackoverflow.com/a/25166013/259988

    【讨论】:

      猜你喜欢
      • 2013-03-30
      • 1970-01-01
      • 1970-01-01
      • 2019-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-22
      • 1970-01-01
      相关资源
      最近更新 更多