启动jetty作为服务时,权限被拒绝错误和服务不可用

时间:2014-09-25 21:16:05

标签: scala plugins playframework jetty sbt

我正在尝试使用jetty部署我的播放应用。我已成功使用play2-war plugin,从我的播放应用程序中制作战争文件。我还将它命名为ROOT.war并将所述文件放在我的码头安装的webapps文件夹中。为了安装jetty,我使用了this post。我对码头很陌生,所以我安装完毕后我还没有碰过码头

sudo service jetty start 

部署我的应用。当我检查x.x.x.x:8080时,我看到了503和这个

Problem accessing /. Reason:

Service Unavailable

这是我在/ opt / jetty / logs

中的最新日志文件
20:42:05,521 |-ERROR in ch.qos.logback.core.FileAppender[FILE] - openFile(/home/jetty/logs/application.log,true) call failed. java.io.FileNotFoundException: /home/jetty/logs/application.log (Permission denied)
    at java.io.FileNotFoundException: /home/jetty/logs/application.log (Permission denied)
    at      at java.io.FileOutputStream.open(Native Method)
    at      at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
    at      at ch.qos.logback.core.recovery.ResilientFileOutputStream.<init>(ResilientFileOutputStream.java:28)
    at      at ch.qos.logback.core.FileAppender.openFile(FileAppender.java:149)
    at      at ch.qos.logback.core.FileAppender.start(FileAppender.java:108)
    at      at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:96)
    at      at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317)
    at      at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196)
    at      at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182)
    at      at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
    at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149)
    at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135)
    at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99)
    at      at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:49)
    at      at play.api.Logger$$anonfun$configure$3.apply(Logger.scala:256)
    at      at play.api.Logger$$anonfun$configure$3.apply(Logger.scala:256)
    at      at scala.Option.foreach(Option.scala:245)
    at      at play.api.Logger$.configure(Logger.scala:256)
    at      at play.api.Application$class.$init$(Application.scala:272)
    at      at play.core.server.servlet.DefaultWarApplication.<init>(Play2Server.scala:122)
    at      at play.core.server.servlet.WarApplication.<init>(Play2Server.scala:105)
    at      at play.core.server.servlet.Play2WarServer$.apply(Play2Server.scala:43)
    at      at play.core.server.servlet.GenericPlay2Servlet.contextInitialized(GenericPlay2Servlet.scala:45)
    at      at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:798)
    at      at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:444)
    at      at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:789)
    at      at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:294)
    at      at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1341)
    at      at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1334)
    at      at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
    at      at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:497)
    at      at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
    at      at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:497)
    at      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at      at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:41)
    at      at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
    at      at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
    at      at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
    at      at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180)
    at      at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
    at      at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:609)
    at      at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:528)
    at      at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
    at      at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)
    at      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at      at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:150)
    at      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at      at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:560)
    at      at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:235)
    at      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at      at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
    at      at org.eclipse.jetty.server.Server.start(Server.java:387)
    at      at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
    at      at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
    at      at org.eclipse.jetty.server.Server.doStart(Server.java:354)
    at      at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at      at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1255)
    at      at java.security.AccessController.doPrivileged(Native Method)
    at      at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)
    at      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at      at java.lang.reflect.Method.invoke(Method.java:606)
    at      at org.eclipse.jetty.start.Main.invokeMain(Main.java:310)
    at      at org.eclipse.jetty.start.Main.start(Main.java:786)
    at      at org.eclipse.jetty.start.Main.main(Main.java:111)

这个

20:42:05,542 |-ERROR in ch.qos.logback.core.FileAppender[FILE] - openFile(/home/jetty/logs/application.log,true) call failed. java.io.FileNotFoundException: /home/jetty/logs/application.log (Permission denied)
    at java.io.FileNotFoundException: /home/jetty/logs/application.log (Permission denied)
    at      at java.io.FileOutputStream.open(Native Method)
    at      at java.io.FileOutputStream.<init>(FileOutputStream.java:221)
    at      at ch.qos.logback.core.recovery.ResilientFileOutputStream.<init>(ResilientFileOutputStream.java:28)
    at      at ch.qos.logback.core.FileAppender.openFile(FileAppender.java:149)
    at      at ch.qos.logback.core.FileAppender.start(FileAppender.java:108)
    at      at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:96)
    at      at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317)
    at      at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196)
    at      at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182)

最后这个

[^[[31merror^[[0m] c.j.b.h.AbstractConnectionHook - Failed to obtain initial connection Sleeping for 0ms and trying again. Attempts left: 0. Exception: null.Message:path to './dbChard/chard.db': '/opt/jetty/./dbChard' does not exist
2014-09-25 20:42:05.784:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.w.WebAppContext@4362f992{/,file:/tmp/jetty-0.0.0.0-8080-ROOT.war-_-any-9217408542040048607.dir/webapp/,STARTING}{/ROOT.war}
Configuration error: Configuration error[Cannot connect to database [default]]
    at      play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:94)
    at play.api.Configuration.reportError(Configuration.scala:743)
    at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:247)
    at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:238)
    at scala.collection.immutable.List.map(List.scala:272)
    at play.api.db.BoneCPPlugin.onStart(DB.scala:238)
    at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
    at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:91)
    at play.api.Play$$anonfun$start$1.apply(Play.scala:91)
    at play.api.Play$$anonfun$start$1.apply(Play.scala:91)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.api.Play$.start(Play.scala:90)
    at play.core.server.servlet.WarApplication.<init>(Play2Server.scala:112)
    at play.core.server.servlet.Play2WarServer$.apply(Play2Server.scala:43)
    at play.core.server.servlet.GenericPlay2Servlet.contextInitialized(GenericPlay2Servlet.scala:45)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:798)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:444)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:789)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:294)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1341)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1334)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:497)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:41)
    at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
    at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
    at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
    at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:609)
    at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:528)
    at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
    at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:150)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:560)
    at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:235)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
    at org.eclipse.jetty.server.Server.start(Server.java:387)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
    at org.eclipse.jetty.server.Server.doStart(Server.java:354)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1255)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)
    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.eclipse.jetty.start.Main.invokeMain(Main.java:310)
    at org.eclipse.jetty.start.Main.start(Main.java:786)
    at org.eclipse.jetty.start.Main.main(Main.java:111)

Caused by:
java.sql.SQLException: path to './dbChard/chard.db': '/opt/jetty/./dbChard' does not exist
at org.sqlite.Conn.open(Conn.java:103)
    at org.sqlite.Conn.<init>(Conn.java:57)
    at org.sqlite.JDBC.createConnection(JDBC.java:77)
    at org.sqlite.JDBC.connect(JDBC.java:64)
    at java.sql.DriverManager.getConnection(DriverManager.java:571)
    at java.sql.DriverManager.getConnection(DriverManager.java:215)
    at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:363)
    at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:416)
    at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:120)
    at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:240)
    at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:238)
    at scala.collection.immutable.List.map(List.scala:272)
    at play.api.db.BoneCPPlugin.onStart(DB.scala:238)
    at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
    at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:91)
    at play.api.Play$$anonfun$start$1.apply(Play.scala:91)
    at play.api.Play$$anonfun$start$1.apply(Play.scala:91)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
    at play.api.Play$.start(Play.scala:90)
    at play.core.server.servlet.WarApplication.<init>(Play2Server.scala:112)
    at play.core.server.servlet.Play2WarServer$.apply(Play2Server.scala:43)
    at play.core.server.servlet.GenericPlay2Servlet.contextInitialized(GenericPlay2Servlet.scala:45)
    at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:798)
    at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:444)
    at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:789)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:294)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp(WebAppContext.java:1341)
    at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1334)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
    at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:497)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:41)
    at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
    at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:498)
    at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:180)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
    at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:609)
    at org.eclipse.jetty.util.Scanner.reportDifferences(Scanner.java:528)
    at org.eclipse.jetty.util.Scanner.scan(Scanner.java:391)
    at org.eclipse.jetty.util.Scanner.doStart(Scanner.java:313)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.deploy.providers.ScanningAppProvider.doStart(ScanningAppProvider.java:150)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.deploy.DeploymentManager.startAppProvider(DeploymentManager.java:560)
    at org.eclipse.jetty.deploy.DeploymentManager.doStart(DeploymentManager.java:235)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
    at org.eclipse.jetty.server.Server.start(Server.java:387)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
    at org.eclipse.jetty.server.Server.doStart(Server.java:354)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.xml.XmlConfiguration$1.run(XmlConfiguration.java:1255)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:1174)
    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.eclipse.jetty.start.Main.invokeMain(Main.java:310)
    at org.eclipse.jetty.start.Main.start(Main.java:786)

这是我第一次使用jetty,所以我对许多约定,命令和调试方法都不是很熟悉,这就是为什么我在这里问我的问题,希望得到答案。任何和所有的帮助将不胜感激。谢谢大家。

1 个答案:

答案 0 :(得分:0)

首先,http://techtraits.com/jetty9install/

上的说明存在一些问题
  • NPN无法配置简单的复制/粘贴。如果您有更新版本的Java,那么您还必须升级您的Jetty版本以获取特定于您的Java版本的npn。 (如果您使用Java 8,那么您需要使用alpn,而不是npn
  • ${jetty.home} vs ${jetty.base}概念的说明中没有任何内容。 (虽然不是必需的,但它确实可以配置Jetty,并且更容易升级Jetty)
  • 请勿使用Jetty 9.1.1,请使用最新版本9.2.3.v20140905
  • 这些说明是系统特定的,但不用担心,因为您的特定环境似乎支持它(特别是因为您已经足够触发这些错误)
  • 如果您正在使用JSP,那么不使用 openjdk,它已知无法解决的错误。使用官方Oracle JDK。 (因为您使用的是Play框架,这可能与您无关)。

至于错误/警告,你有......

java.io.FileNotFoundException: /home/jetty/logs/application.log (Permission denied)

这是您的文件系统问题的权限。

您需要验证jetty用户是否有权创建该文件或其上方的目录。

path to './dbChard/chard.db': '/opt/jetty/./dbChard' does not exist

此错误非常简单,您的数据库配置正在对您启动jetty实例的位置不存在的文件进行相对路径引用。只需将该配置更改为绝对路径即可。