我正在使用码头 2.1.6 和 sbt 0.7.7。
目前我的应用程序在 http 上运行,但我想用 https 运行
我尝试了以下方法来使用 https 运行它: http ://wiki.eclipse.org/Jetty/Howto/Configure_SSL#Configuring_Jetty_for_SSL
然后我在 build.scala 文件中设置以下代码。
override lazy val jettyInstance = new JettyRunner(customJettyConfiguration)
def customJettyConfiguration = {
val myLog = log
val myJettyClasspath = jettyClasspath
new CustomJettyConfiguration {
def war = "target/scala_2.8.0/tos.war"
def scanDirectories = Nil
def scanInterval = 0
def jettyClasspath = myJettyClasspath
def classpath = jettyRunClasspath
def classpathName = "test"
def log = myLog
override def jettyConfigurationXML =
<Configure id="Server" class="org.mortbay.jetty.Server">
<Call name="addConnector">
<Arg>
<New class="org.mortbay.jetty.security.SslSocketConnector">
<Set name="Port">443</Set>
<Set name="maxIdleTime">30000</Set>
<Set name="handshakeTimeout">2000</Set>
<Set name="keystore"><SystemProperty name="jetty.home" default=""/>/etc/xinetd.d/keystore</Set>
<Set name="password">password</Set>
<Set name="keyPassword">password</Set>
<Set name="truststore"><SystemProperty name="jetty.home" default=""/>/etc/xinetd.d/keystore</Set>
<Set name="trustPassword">password</Set>
<Set name="handshakeTimeout">2000</Set>
</New>
</Arg>
</Call>
<Call name="addConnector">
<Arg>
<New class="org.mortbay.jetty.nio.SelectChannelConnector">
<Set name="host"><SystemProperty name="jetty.host"/></Set>
<Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
<Set name="maxIdleTime">30000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">443</Set>
<Set name="lowResourcesConnections">5000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
</Configure>
}
}
但我没有完成我的工作。
如果我做错了什么,请告诉我。
编辑
I am using 6.1.26 version of jetty.
对不起,我之前说错了。
编辑
现在我已成功将我的码头服务器升级到 jetty-8.0.0.M3
现在,当我在 build.scala 文件中编写上述代码时,我遇到了以下错误:
java.lang.NoSuchMethodError: org.eclipse.jetty.xml.XmlConfiguration.configure(Ljava/lang/Object;)V
at sbt.jetty.LazyJettyRun7$$anonfun$3.apply(LazyJettyRun7.scala:96)
at sbt.jetty.LazyJettyRun7$$anonfun$3.apply(LazyJettyRun7.scala:95)
at scala.Iterator$class.foreach(Iterator.scala:414)
at scala.List$$anon$2.foreach(List.scala:598)
at scala.Iterable$class.foreach(Iterable.scala:256)
at scala.xml.NodeSeq.foreach(NodeSeq.scala:34)
at sbt.jetty.LazyJettyRun7$.apply(LazyJettyRun7.scala:95)
at sbt.JettyRunner.runJetty$1(WebApp.scala:49)
at sbt.JettyRunner.apply(WebApp.scala:58)
at sbt.WebScalaProject$$anonfun$jettyRunTask$1.apply(ScalaProject.scala:383)
at sbt.WebScalaProject$$anonfun$jettyRunTask$1.apply(ScalaProject.scala:383)
at sbt.TaskManager$Task.invoke(TaskManager.scala:62)
at sbt.impl.RunTask.doRun$1(RunTask.scala:77)
at sbt.impl.RunTask.runTask(RunTask.scala:85)
at sbt.impl.RunTask.run(RunTask.scala:32)
at sbt.impl.RunTask$.apply(RunTask.scala:17)
at sbt.impl.RunTask$.apply(RunTask.scala:16)
at sbt.Project$class.run(Project.scala:98)
at sbt.Project$class.act(Project.scala:129)
at sbt.BasicScalaProject.act(DefaultProject.scala:21)
at sbt.xMain$$anonfun$8.apply(Main.scala:530)
at sbt.xMain$$anonfun$8.apply(Main.scala:530)
at sbt.xMain.withAction(Main.scala:563)
at sbt.xMain.sbt$xMain$$handleAction(Main.scala:530)
at sbt.xMain.handleCommand(Main.scala:520)
at sbt.xMain.processAction(Main.scala:459)
at sbt.xMain.process$1(Main.scala:257)
at sbt.xMain$Continue$1.apply(Main.scala:132)
at sbt.xMain.run$1(Main.scala:136)
at sbt.xMain.processArguments(Main.scala:266)
at sbt.xMain.startProject(Main.scala:107)
at sbt.xMain.run(Main.scala:84)
at sbt.xMain.run0$1(Main.scala:35)
at sbt.xMain.run(Main.scala:42)
at xsbt.boot.Launch$.run(Launch.scala:55)
at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45)
at xsbt.boot.Launch$.launch(Launch.scala:69)
at xsbt.boot.Launch$.apply(Launch.scala:16)
at xsbt.boot.Boot$.runImpl(Boot.scala:31)
at xsbt.boot.Boot$.main(Boot.scala:20)
at xsbt.boot.Boot.main(Boot.scala)
[info] == jetty-run == [error] Error running jetty-run: Error running Jetty: java.lang.NoSuchMethodError: org.eclipse.jetty.xml.XmlConfiguration.configure(Ljava/lang/Object;)V