1

I'm trying to compile my project with SBT, but I get this error and can not figure out why:

YoBre$ sbt compile
[info] Loading project definition from /opt/virtualenvs/venv1/scala/name/project
[info] Set current project to name (in build file:/opt/virtualenvs/venv1/scala/name/)
[info] Compiling 4 Scala sources and 5 Java sources to /opt/virtualenvs/venv1/scala/name/target/scala-2.10/classes...
[error] error while loading CTP, class file '/opt/virtualenvs/venv1/scala/name/lib_managed/jars/org.apache.poi/poi-ooxml-schemas/poi-ooxml-schemas-3.9.jar(org/openxmlformats/schemas/wordprocessingml/x2006/main/CTP.class)' is broken
[error] (class java.lang.NullPointerException/null)
[error] error while loading CTTbl, class file '/opt/virtualenvs/venv1/scala/name/lib_managed/jars/org.apache.poi/poi-ooxml-schemas/poi-ooxml-schemas-3.9.jar(org/openxmlformats/schemas/wordprocessingml/x2006/main/CTTbl.class)' is broken
[error] (class java.lang.NullPointerException/null)
[error] error while loading CTTc, class file '/opt/virtualenvs/venv1/scala/name/lib_managed/jars/org.apache.poi/poi-ooxml-schemas/poi-ooxml-schemas-3.9.jar(org/openxmlformats/schemas/wordprocessingml/x2006/main/CTTc.class)' is broken
[error] (class java.lang.NullPointerException/null)
[error] three errors found
[error] (compile:compile) Compilation failed
[error] Total time: 6 s, completed 18-set-2013 12.31.36

This project contains code Java and Scala. The error occurred when I translated into Scala a feature related to the splitting of the word documents that was previously written in java. The error is in fact tied to a jar file library org.apache.poi.

I tried to document but I have not found similar cases.

Any idea?

thanks

4

3 回答 3

3

您是否尝试过将 jar 文件添加为外部依赖项?在你的 build.sbt 中:

libraryDependencies += "org.apache.poi" % "poi-ooxml-schemas" % "3.9"
于 2013-09-18T15:13:00.437 回答
1

我已将 POI 的版本更新为 3.10-beta2。但是,没有依赖"org.apache.poi"% "-OOXML schemas"% "1.0"

添加后一切正常

谢谢大家的回答!

  lazy val poiVersion = "3.10-beta2"
  lazy val libPoi ="org.apache.poi" % "poi" % poiVersion
  lazy val libPoiScratchpad ="org.apache.poi" % "poi-scratchpad" % poiVersion
  lazy val libPoiOOXML ="org.apache.poi" % "poi-ooxml" % poiVersion
  lazy val libPoiOOXMLSchema= "org.apache.poi" % "ooxml-schemas" % "1.0"
  lazy val libPoiComponents = Seq(libPoi, libPoiScratchpad, libPoiOOXML, libPoiOOXMLSchema)
于 2013-09-19T08:17:34.920 回答
0

我发现了一个类似的问题,我怀疑你可能有同样的问题。Scala 无法加载缺少注释的类,因此可能存在缺少的依赖项,而这对 Java 来说是可选的。

通过在 sbt中执行检查您的依赖项列表,show compile:dependency-classpath并确保您具有Apache POI 项目站点中列出的所有先决条件。

于 2013-09-18T13:58:49.357 回答