Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 在SBT下运行的应用程序不';无法从Classpath jar中找到类_Scala_Sbt_Jnr - Fatal编程技术网

Scala 在SBT下运行的应用程序不';无法从Classpath jar中找到类

Scala 在SBT下运行的应用程序不';无法从Classpath jar中找到类,scala,sbt,jnr,Scala,Sbt,Jnr,我有一个使用sbt的Scala项目。它在Eclipse下运行得非常好,但是,尝试在sbt下运行它(sbt'run mount 1440'-包括我需要的参数)会导致ClassNotFoundException-它找不到jnr.ffi.provider.jffi.NativeClosureProxy类。但是,运行sbt'last run'会显示jnr-ffi-2.0.3.jar文件(包括所述类)实际上包含在类路径中。对发生的事情有什么建议吗 github上可用的源代码:您的构建sbt无效 首先,您需

我有一个使用sbt的Scala项目。它在Eclipse下运行得非常好,但是,尝试在sbt下运行它(
sbt'run mount 1440'
-包括我需要的参数)会导致
ClassNotFoundException
-它找不到
jnr.ffi.provider.jffi.NativeClosureProxy
类。但是,运行
sbt'last run'
会显示
jnr-ffi-2.0.3.jar
文件(包括所述类)实际上包含在类路径中。对发生的事情有什么建议吗


github上可用的源代码:

您的构建sbt无效

首先,您需要在
librarydependency
s之间有空行

lazy val root = (project in file(".")).
  settings(
    name := "vkfs",
    version := "1.0",
    scalaVersion := "2.11.7"
  )

libraryDependencies += "org.scalaj" %% "scalaj-http" % "1.1.6"

libraryDependencies += "org.json4s" %% "json4s-jackson" % "3.2.11"

libraryDependencies += "com.github.serceman" % "jnr-fuse" % "0.1"
第二个,无法解析依赖项“com.github.serceman”。这意味着

  • 您已将依赖项手动安装到位于
    .Ivy
    的常春藤存储库中
  • 您尚未指定正确的解析程序(请参阅)
总之,似乎Eclipse会自动执行某些操作,因此您的程序会运行。当涉及到您的
build.sbt
时,它是无效的(缺少空行),并且不能正确解析依赖项。我想知道,你怎么能通过
sbt'运行mount 1440'
开始呢

纠正空行并运行sbt“运行mount 1440”后,我获得

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0
[info] Set current project to vkfs (in build file:/home/.../IdeaProjects/vkfs/)
[info] Updating {file:/home/.../IdeaProjects/vkfs/}root...
[info] Resolving com.github.serceman#jnr-fuse;0.1 ...
[warn]  module not found: com.github.serceman#jnr-fuse;0.1
[warn] ==== local: tried
[warn]   /home/.../.ivy2/local/com.github.serceman/jnr-fuse/0.1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/com/github/serceman/jnr-fuse/0.1/jnr-fuse-0.1.pom
[info] Resolving jline#jline;2.12.1 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.github.serceman#jnr-fuse;0.1: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
sbt.ResolveException: unresolved dependency: com.github.serceman#jnr-fuse;0.1: not found
at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:213)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:122)
at sbt.IvyActions$$anonfun$update$1.apply(IvyActions.scala:121)
[ ... truncated ... ]
编辑(关于来自jcenter的依赖关系) 将以下行添加到build.sbt(记住额外的空行)

将jcenter添加到您的冲突解决程序列表中

编辑2 Resolver.jCenter Repo在SBT 0.13.5中不可用,因此

resolvers += "jcenter" at "https://jcenter.bintray.com/"
是必需的

成功编译后并运行,相关错误为

java.lang.RuntimeException: java.lang.NoClassDefFoundError: jnr/ffi/provider/jffi/NativeClosureProxy
at jnr.ffi.provider.jffi.NativeClosureProxy.newProxyFactory(NativeClosureProxy.java:220)
最终结果 V0.1中的库“com.github.serceman”似乎有问题,因为它无法通过反射正确地实例化某个类

解决方案
通过将
fork in run:=true
添加到
build.sbt

中解决的问题您应该在此处包含相关的代码位,因此对于在未来可能会遇到类似问题的其他访问者来说,这是很有用的,因为他们会注意到
库依赖关系
行之间缺少空行,但这并没有改变任何内容。至于
jnr fuse
,它可以从jcenter存储库中获得(在您发布的手册中,链接称此repo默认可用),我的sbt在清理缓存后成功地解决了此依赖关系。我提到的
ClassNotFoundException
只能在运行时访问,因此由于jnr fuse在您的机器上无法解析,因此您无法到达我遇到此异常的位置。不,不是真的。默认情况下不添加回购jcenter。相反,它是一个预定义变量,如doc states
Resolver.jcentrepo
。将编辑我的帖子…嗯。我想知道为什么我的sbt解决了这个依赖关系。但是,将
resolvers+=Resolver.jcenterepo
添加到
build.sbt
,对我来说再次没有任何改变。您是如何启动sbt的?只需从bash/shell通过
sbt
启动sbt,然后在交互式sbt控制台中调用
run mount 1440
。运行
sbt'run mount 1440'
并使用您描述的方法得到相同的结果-没有依赖性问题,所有必要的文件都在类路径中(使用
上次运行
命令进行检查),包括
jnr-ffi-2.0.3.jar
,这正是包含在sbt下找不到的类的文件。
java.lang.RuntimeException: java.lang.NoClassDefFoundError: jnr/ffi/provider/jffi/NativeClosureProxy
at jnr.ffi.provider.jffi.NativeClosureProxy.newProxyFactory(NativeClosureProxy.java:220)