Java bazel远程工作者可部署jar不工作

Java bazel远程工作者可部署jar不工作,java,build,bazel,Java,Build,Bazel,我在打包到可部署jar时遇到了一个问题 我运行了以下命令: bazel-build//src/tools/remote\u-worker:remote\u-worker\u-deploy.jar 但是当我尝试运行jar时,我得到了以下错误: ➜ bazel git:(master) ✗ java -jar remote_worker_deploy.jar --work_path=/tmp/test --listen_port=3030 *** Initializing in-memory ca

我在打包到可部署jar时遇到了一个问题

我运行了以下命令:

bazel-build//src/tools/remote\u-worker:remote\u-worker\u-deploy.jar

但是当我尝试运行jar时,我得到了以下错误:

➜  bazel git:(master) ✗ java -jar remote_worker_deploy.jar --work_path=/tmp/test --listen_port=3030
*** Initializing in-memory cache server.
*** Not using remote cache. This should be used for testing only!
Exception in thread "main" java.lang.UnsatisfiedLinkError: no unix in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at com.google.devtools.build.lib.UnixJniLoader.loadJni(UnixJniLoader.java:28)
    at com.google.devtools.build.lib.unix.NativePosixFiles.<clinit>(NativePosixFiles.java:136)
    at com.google.devtools.build.lib.unix.UnixFileSystem.createDirectory(UnixFileSystem.java:309)
    at com.google.devtools.build.lib.vfs.Path.createDirectory(Path.java:829)
    at com.google.devtools.build.lib.vfs.FileSystemUtils.createDirectoryAndParentsWithCache(FileSystemUtils.java:692)
    at com.google.devtools.build.lib.vfs.FileSystemUtils.createDirectoryAndParents(FileSystemUtils.java:652)
    at com.google.devtools.build.remote.RemoteWorker.<init>(RemoteWorker.java:114)
    at com.google.devtools.build.remote.RemoteWorker.main(RemoteWorker.java:621)
➜  巴泽尔·吉特:(硕士)✗ java-jar-remote\u-worker\u-deploy.jar--work\u-path=/tmp/test--listen\u-port=3030
***正在初始化内存缓存服务器。
***不使用远程缓存。这应该只用于测试!
线程“main”java.lang.UnsatifiedLinkError中出现异常:java.library.path中没有unix
位于java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
位于java.lang.Runtime.loadLibrary0(Runtime.java:870)
位于java.lang.System.loadLibrary(System.java:1122)
位于com.google.devtools.build.lib.UnixJniLoader.loadJni(UnixJniLoader.java:28)
位于com.google.devtools.build.lib.unix.NativePosixFiles.(NativePosixFiles.java:136)
位于com.google.devtools.build.lib.unix.UnixFileSystem.createDirectory(UnixFileSystem.java:309)
位于com.google.devtools.build.lib.vfs.Path.createDirectory(Path.java:829)
位于com.google.devtools.build.lib.vfs.FileSystemUtils.createDirectoryAndParentsWithCache(FileSystemUtils.java:692)
在com.google.devtools.build.lib.vfs.FileSystemUtils.createDirectoryAndParents上(FileSystemUtils.java:652)
位于com.google.devtools.build.remote.RemoteWorker。(RemoteWorker.java:114)
位于com.google.devtools.build.remote.RemoteWorker.main(RemoteWorker.java:621)
启动它的唯一方法是从
bazel-bin
运行可执行文件:

bazel-bin/src/tools/remote\u-worker/remote\u-worker--work\u-path=/tmp/test--listen\u-port=3030

我正在mac osx sierra上运行bazel最新版本(目前为a3e26835890a543ff84cce90c879f9196ae06348)

我用
oracle-jdk-1.8.131
openjdk-1.8.91
进行了尝试,结果都是一样的


最终目标是创建一个运行这个jar的docker映像,但即使在
openjdk:8
中,这个jar的行为也是一样的…

显然,我们没有将本机代码打包到部署jar中。实际上,我更愿意重构RemoteWorker,以避免使用Bazel的大多数内部库,尽管这不太可能很快实现。您可以将libunix.so与deploy jar一起提供,并适当地设置java.library.path。或者,您可以在构建远程工作程序(bazel-bin/src/tools/remote\u-worker/remote\u-worker.runfiles/)后获取整个runfiles树。

自提出问题以来,bazel源代码树中的路径已更改。现在,获取_deploy.jar的构建命令如下所示

bazel build src/tools/remote:worker\u deploy.jar
mkdir-p/tmp/cas/tmp/cache/tmp/work
java-jar-bazel-bin/src/tools/remote/worker_deploy.jar\
--cas\u path/tmp/cas--disk\u cache/tmp/cache--work\u path/tmp/work
bazel构建——生成策略=远程\
--远程\u缓存=grpc://${IP}:8080——远程\u执行器=grpc://${IP}:8080