Maven jetty插件 - 在后台模式下启动时延迟

时间:2009-07-20 09:58:41

标签: java unix maven-2 background jetty

我使用

在linux上启动一个jetty服务器

nohup mvn jetty:run &

在后台运行它并在我从控制台退出时停留。通常(mvn jetty:run)它会在几秒钟内启动,但在这种情况下,它需要大约几分钟才能启动。造成这种延误的原因是什么?

堆栈跟踪

Full thread dump Java HotSpot(TM) 64-Bit Server VM (11.0-b16 mixed mode):

"Attach Listener" daemon prio=10 tid=0x000000004bba8c00 nid=0x560a waiting on condition [0x0000000000000000..0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Timer-1" daemon prio=10 tid=0x00002aaac053d800 nid=0x55fb in Object.wait() [0x0000000042392000..0x0000000042392b90]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaae554f40> (a java.util.TaskQueue)
        at java.util.TimerThread.mainLoop(Timer.java:509)
        - locked <0x00002aaaae554f40> (a java.util.TaskQueue)
        at java.util.TimerThread.run(Timer.java:462)

"StopJettyPluginMonitor" daemon prio=10 tid=0x00002aaac04b4c00 nid=0x55fa runnable [0x0000000042291000..0x0000000042291b10]
   java.lang.Thread.State: RUNNABLE
        at java.net.PlainSocketImpl.socketAccept(Native Method)
        at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:384)
        - locked <0x00002aaaae453860> (a java.net.SocksSocketImpl)
        at java.net.ServerSocket.implAccept(ServerSocket.java:453)
        at java.net.ServerSocket.accept(ServerSocket.java:421)
        at org.mortbay.jetty.plugin.util.Monitor.run(Monitor.java:74)

"Timer-0" daemon prio=10 tid=0x000000004b5cf800 nid=0x55f9 in Object.wait() [0x0000000040c78000..0x0000000040c78a90]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaaeea00b8> (a java.util.TaskQueue)
        at java.util.TimerThread.mainLoop(Timer.java:509)
        - locked <0x00002aaaaeea00b8> (a java.util.TaskQueue)
        at java.util.TimerThread.run(Timer.java:462)

"1455093129@qtp-422797318-1 - Acceptor0 SelectChannelConnector@0.0.0.0:8080" prio=10 tid=0x000000004b6d9800 nid=0x55f7 runnable [0x000000004130c000..0x000000004130ca10]
   java.lang.Thread.State: RUNNABLE
        at sun.nio.ch.EPollArrayWrapper.epollWait(Native Method)
        at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:215)
        at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:65)
        at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)
        - locked <0x00002aaaae44ac10> (a sun.nio.ch.Util$1)
        - locked <0x00002aaaae44abf8> (a java.util.Collections$UnmodifiableSet)
        - locked <0x00002aaaae44a588> (a sun.nio.ch.EPollSelectorImpl)
        at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80)
        at org.mortbay.io.nio.SelectorManager$SelectSet.doSelect(SelectorManager.java:459)
        at org.mortbay.io.nio.SelectorManager.doSelect(SelectorManager.java:192)
        at org.mortbay.jetty.nio.SelectChannelConnector.accept(SelectChannelConnector.java:124)
        at org.mortbay.jetty.AbstractConnector$Acceptor.run(AbstractConnector.java:706)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)

"91446054@qtp-422797318-0" prio=10 tid=0x000000004b621400 nid=0x55f6 in Object.wait() [0x000000004120b000..0x000000004120bd90]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaab1171890> (a org.mortbay.thread.QueuedThreadPool$PoolThread)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:563)
        - locked <0x00002aaab1171890> (a org.mortbay.thread.QueuedThreadPool$PoolThread)

"pool-1-thread-5" prio=10 tid=0x00002aaac15d4c00 nid=0x55f5 in Object.wait() [0x0000000041a4f000..0x0000000041a4fd10]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at java.lang.Object.wait(Object.java:485)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:316)
        - locked <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:994)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1054)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
        at java.lang.Thread.run(Thread.java:619)

"pool-1-thread-4" prio=10 tid=0x00002aaac0134000 nid=0x55f4 in Object.wait() [0x000000004194e000..0x000000004194ec90]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at java.lang.Object.wait(Object.java:485)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:316)
        - locked <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:994)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1054)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
        at java.lang.Thread.run(Thread.java:619)

"pool-1-thread-3" prio=10 tid=0x000000004ba72800 nid=0x55f3 in Object.wait() [0x0000000042190000..0x0000000042190c10]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at java.lang.Object.wait(Object.java:485)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:316)
        - locked <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:994)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1054)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
        at java.lang.Thread.run(Thread.java:619)

"pool-1-thread-2" prio=10 tid=0x000000004b8b6c00 nid=0x55f2 in Object.wait() [0x000000004208f000..0x000000004208fb90]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at java.lang.Object.wait(Object.java:485)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:316)
        - locked <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:994)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1054)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
        at java.lang.Thread.run(Thread.java:619)

"pool-1-thread-1" prio=10 tid=0x000000004b8b6400 nid=0x55f1 in Object.wait() [0x0000000040415000..0x0000000040415b10]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at java.lang.Object.wait(Object.java:485)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:316)
        - locked <0x00002aaaafff4580> (a hidden.edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue$SerializableLock)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:994)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1054)
        at hidden.edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
        at java.lang.Thread.run(Thread.java:619)

"Low Memory Detector" daemon prio=10 tid=0x000000004affd800 nid=0x55eb runnable [0x0000000000000000..0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"CompilerThread1" daemon prio=10 tid=0x000000004affb800 nid=0x55ea waiting on condition [0x0000000000000000..0x0000000041d8b4d0]
   java.lang.Thread.State: RUNNABLE

"CompilerThread0" daemon prio=10 tid=0x000000004aff7800 nid=0x55e9 waiting on condition [0x0000000000000000..0x0000000041c8a450]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x000000004aff5c00 nid=0x55e8 runnable [0x0000000000000000..0x0000000041b8a820]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=10 tid=0x000000004afd2400 nid=0x55e7 in Object.wait() [0x000000004184d000..0x000000004184db10]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafdf0450> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
        - locked <0x00002aaaafdf0450> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x000000004afd0800 nid=0x55e6 in Object.wait() [0x000000004174c000..0x000000004174ca90]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaaafdf0530> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:485)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
        - locked <0x00002aaaafdf0530> (a java.lang.ref.Reference$Lock)

"main" prio=10 tid=0x000000004af6e000 nid=0x55e4 in Object.wait() [0x000000004072f000..0x0000000040730ed0]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002aaab1196b60> (a org.mortbay.thread.QueuedThreadPool$Lock)
        at java.lang.Object.wait(Object.java:485)
        at org.mortbay.thread.QueuedThreadPool.join(QueuedThreadPool.java:298)
        - locked <0x00002aaab1196b60> (a org.mortbay.thread.QueuedThreadPool$Lock)
        at org.mortbay.jetty.plugin.Jetty6PluginServer.join(Jetty6PluginServer.java:206)
        at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:461)
        at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
        at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
        at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:553)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:523)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
        at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

"VM Thread" prio=10 tid=0x000000004afcb000 nid=0x55e5 runnable

"VM Periodic Task Thread" prio=10 tid=0x000000004b000000 nid=0x55ec waiting on condition

JNI global references: 861

4 个答案:

答案 0 :(得分:5)

我厌倦了看到人们滥用nohup。以下是真正的守护程序例程的工作方式:

  1. 创建子流程。
  2. 启动守护程序作为该子进程的子进程。
  3. 退出第一个流程。
  4. 使用sh模拟此内容的简单方法如下:

    sh -c "mvn jetty:run &"

    ...观察

    scott@optimusprime:~/code/leapfrog/lasso> sh -c "mvn jetty:run &"
    scott@optimusprime:~/code/leapfrog/lasso> ps aux | grep jetty:run
    scott    26165 45.5  5.8 813556 235764 pts/9   Sl   15:23   0:06 /usr/lib/jvm/java-6-sun//bin/java -Xmx512M -classpath /home/scott/opt/apache-maven-2.2.1//boot/classworlds-1.1.jar -Dclassworlds.conf=/home/scott/opt/apache-maven-2.2.1//bin/m2.conf -Dmaven.home=/home/scott/opt/apache-maven-2.2.1/ org.codehaus.classworlds.Launcher "jetty:run"
    scott@optimusprime:~/code/leapfrog/lasso> exit
    

    如果我从单独的终端或稍后检查我的进程列表,程序仍在运行。

    但是我不得不问,为什么这样做而不是仅仅在本地应用程序服务器中安装您的Web应用程序,并启动它?希望您不使用apache maven管理真正的环境。

答案 1 :(得分:0)

我会在前台运行它,并触发一个线程转储(Ctrl + Break),并通过检查每个线程堆栈跟踪来查看它正在做什么。没有任何进一步的信息,我不能再提供任何建议。

答案 2 :(得分:0)

我建议您尝试使用screen。对于这样一个简单的任务可能有些过分,但你可以将它包装在shell脚本中。

答案 3 :(得分:0)

使用maven下载,安装和启动应用程序非常方便。除了许多其他好处之外,maven还为开发人员提供了管理Jetty版本的能力。使用这里提供的建议,我认为maven符合法案作为生产启动机制。