我想在Play Framework应用程序中使用Scala项目。
我在SBT中使用publishLocal将项目发布到本地Ivy存储库,如此处所述http://www.scala-sbt.org/release/docs/Detailed-Topics/Publishing#publishing-locally
然后我创建了一个新的Play应用程序,并按照描述添加了库依赖项。我还添加了一个解析器,因为Play无法找到常春藤的正确位置
resolvers += Resolver.file("Local repo", file(System.getProperty("user.home") + "/.ivy2/local"))(Resolver.ivyStylePatterns)
当我启动应用程序时,我得到一个可怕的长堆栈跟踪。我没有修改应用程序中的任何内容,除了build.sbt文件。
这是堆栈跟踪。
scalax.io.ScalaIOException: MainException: class java.lang.NullPointerException(null)
---
class java.lang.NullPointerException(null)
java.io.FilterInputStream.read(FilterInputStream.java:133)
java.nio.channels.Channels$ReadableByteChannelImpl.read(Channels.java:385)
scalax.io.ResourceAdapting$ReadableChannelAdapter.read(ResourceAdapting.scala:75)
scalax.io.support.FileUtils$.copy(FileUtils.scala:130)
scalax.io.traversable.Sliceable.toArray(Sliceable.scala:76)
scalax.io.traversable.ByteResourceTraversable$$anonfun$toArray$2.apply(ByteResourceTraversable.scala:48)
scalax.io.traversable.ByteResourceTraversable$$anonfun$toArray$2.apply(ByteResourceTraversable.scala:48)
scalax.io.CloseableIterator$.liftedTree1$1(CloseableIterator.scala:122)
scalax.io.CloseableIterator$.withIterator(CloseableIterator.scala:122)
scalax.io.traversable.ByteResourceTraversable.toArray(ByteResourceTraversable.scala:48)
scalax.io.Input$class.byteArray(Input.scala:81)
scalax.io.managed.InputStreamResource.byteArray(InputStreamResource.scala:14)
scalax.io.Input$class.string(Input.scala:136)
scalax.io.managed.InputStreamResource.string(InputStreamResource.scala:14)
play.api.i18n.Messages$MessagesParser.parse(Messages.scala:216)
play.api.i18n.MessagesPlugin$$anonfun$play$api$i18n$MessagesPlugin$$loadMessages$1.apply(Messages.scala:286)
play.api.i18n.MessagesPlugin$$anonfun$play$api$i18n$MessagesPlugin$$loadMessages$1.apply(Messages.scala:285)
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
scala.collection.immutable.List.foreach(List.scala:318)
scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
scala.collection.AbstractTraversable.map(Traversable.scala:105)
play.api.i18n.MessagesPlugin.play$api$i18n$MessagesPlugin$$loadMessages(Messages.scala:285)
play.api.i18n.MessagesPlugin.messages$lzycompute(Messages.scala:296)
play.api.i18n.MessagesPlugin.messages(Messages.scala:292)
play.api.i18n.MessagesPlugin.onStart(Messages.scala:309)
play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:88)
play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:88)
scala.collection.immutable.List.foreach(List.scala:318)
play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:88)
play.api.Play$$anonfun$start$1.apply(Play.scala:88)
play.api.Play$$anonfun$start$1.apply(Play.scala:88)
play.utils.Threads$.withContextClassLoader(Threads.scala:18)
play.api.Play$.start(Play.scala:87)
play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:139)
play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:112)
scala.Option.map(Option.scala:145)
play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112)
play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:110)
scala.util.Success.flatMap(Try.scala:200)
play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:110)
play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:102)
scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1361)
scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
java.io.FilterInputStream.close(FilterInputStream.java:181)
sun.net.www.protocol.jar.JarURLConnection$JarURLInputStream.close(JarURLConnection.java:108)
java.nio.channels.Channels$ReadableByteChannelImpl.implCloseChannel(Channels.java:403)
java.nio.channels.spi.AbstractInterruptibleChannel.close(AbstractInterruptibleChannel.java:115)
scalax.io.ResourceAdapting$ReadableChannelAdapter.close(ResourceAdapting.scala:72)
scalax.io.CloseableOpenedResource$$anonfun$closeAction$1.apply(Resource.scala:46)
scalax.io.CloseableOpenedResource$$anonfun$closeAction$1.apply(Resource.scala:46)
scalax.io.CloseAction$$anon$1.closeImpl(CloseAction.scala:20)
scalax.io.CloseAction$$anon$1.closeImpl(CloseAction.scala:18)
scalax.io.CloseAction$class.apply(CloseAction.scala:108)
scalax.io.CloseAction$$anon$1.apply(CloseAction.scala:18)
scalax.io.OpenedResource$class.close(Resource.scala:33)
scalax.io.CloseableOpenedResource.close(Resource.scala:45)
scalax.io.traversable.ReadableByteChannelIterator.doClose(ReadableByteChannelResourceTraversable.scala:64)
scalax.io.CloseableIterator$class.close(CloseableIterator.scala:20)
scalax.io.traversable.Sliceable.close(Sliceable.scala:17)
scalax.io.CloseableIterator$.close$1(CloseableIterator.scala:106)
scalax.io.CloseableIterator$.liftedTree1$1(CloseableIterator.scala:124)
scalax.io.CloseableIterator$.withIterator(CloseableIterator.scala:122)
scalax.io.traversable.ByteResourceTraversable.toArray(ByteResourceTraversable.scala:48)
scalax.io.Input$class.byteArray(Input.scala:81)
scalax.io.managed.InputStreamResource.byteArray(InputStreamResource.scala:14)
scalax.io.Input$class.string(Input.scala:136)
scalax.io.managed.InputStreamResource.string(InputStreamResource.scala:14)
play.api.i18n.Messages$MessagesParser.parse(Messages.scala:216)
play.api.i18n.MessagesPlugin$$anonfun$play$api$i18n$MessagesPlugin$$loadMessages$1.apply(Messages.scala:286)
play.api.i18n.MessagesPlugin$$anonfun$play$api$i18n$MessagesPlugin$$loadMessages$1.apply(Messages.scala:285)
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
scala.collection.immutable.List.foreach(List.scala:318)
scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
scala.collection.AbstractTraversable.map(Traversable.scala:105)
play.api.i18n.MessagesPlugin.play$api$i18n$MessagesPlugin$$loadMessages(Messages.scala:285)
play.api.i18n.MessagesPlugin.messages$lzycompute(Messages.scala:296)
play.api.i18n.MessagesPlugin.messages(Messages.scala:292)
play.api.i18n.MessagesPlugin.onStart(Messages.scala:309)
play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:88)
play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:88)
scala.collection.immutable.List.foreach(List.scala:318)
play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:88)
play.api.Play$$anonfun$start$1.apply(Play.scala:88)
play.api.Play$$anonfun$start$1.apply(Play.scala:88)
play.utils.Threads$.withContextClassLoader(Threads.scala:18)
play.api.Play$.start(Play.scala:87)
play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:139)
play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:112)
scala.Option.map(Option.scala:145)
play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:112)
play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1.apply(ApplicationProvider.scala:110)
scala.util.Success.flatMap(Try.scala:200)
play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:110)
play.core.ReloadableApplication$$anonfun$get$1.apply(ApplicationProvider.scala:102)
scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
scala.concurrent.forkjoin.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1361)
scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
我发布到Local的Scala项目正在使用Akka 2.2.4,而我正在使用Play Framework 2.2.2
Scala项目本身可以自行编译和测试。
答案 0 :(得分:0)
好的,我想我解决了这个问题。
我愚蠢地命名了我的Scala项目中的一个软件包" messages",这导致名称与Play Framework内部的内容冲突。我更改了包名,现在可以使用。
现在将使用正确的包命名约定。