【发布时间】:2020-06-16 17:18:59
【问题描述】:
我正在尝试运行一个使用 Apache Spark 和 Java 的 Java 项目。该项目是从 git 克隆的:https://github.com/ONSdigital/address-index-data。我是 Spark 和 Java 的新手,这对我没有帮助。我无法使用类似问题的答案找到解决方案,例如here
如果我按原样从 IntelliJ 运行代码(在 application.conf 中使用正确的本地 Elasticsearch 设置),那么一切正常 - IntelliJ 似乎会下载所需的 jar 文件并在运行时链接它们。但是,我需要配置项目以便我可以从命令行运行它。这似乎是 github 项目中列出的已知问题,没有提供解决方案。
如果我跑了
sbt clean assembly
按照说明,它成功地制作了一个完整的 JAR 文件。但是,然后使用
java -Dconfig.file=application.conf -jar batch/target/scala-2.11/ons-ai-batch-assembly-version.jar
发生这种情况:
20/06/16 17:06:41 WARN Utils: Your hostname, MacBook-Pro.local resolves to a loopback address: 127.0.0.1; using 192.168.1.163 instead (on interface en0)
20/06/16 17:06:41 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address
20/06/16 17:06:43 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
20/06/16 17:06:44 WARN Persistence: Error creating validator of type org.datanucleus.properties.CorePropertyValidator
ClassLoaderResolver for class "" gave error on creation : {1}
org.datanucleus.exceptions.NucleusUserException: ClassLoaderResolver for class "" gave error on creation : {1}
at org.datanucleus.NucleusContext.getClassLoaderResolver(NucleusContext.java:1087)
at org.datanucleus.PersistenceConfiguration.validatePropertyValue(PersistenceConfiguration.java:797)
at org.datanucleus.PersistenceConfiguration.setProperty(PersistenceConfiguration.java:714)
来自以前的帖子,例如,我认为这是因为 sbt 正在合并 jar 文件并且信息丢失了。但是,我看不到如何
- 正确合并,或
- 使用构建脚本来整理所有必要的 JAR 文件(包括 Scala 库),该脚本构建类路径并使用 java 命令执行 JAR 文件。
我该如何继续?请保持明确的说明,因为我真的不确定 xml 配置等。谢谢!
【问题讨论】:
标签: java scala apache-spark datanucleus