arton / rjb

Ruby Java Bridge
https://www.artonx.org/collabo/backyard/?RubyJavaBridge
GNU Lesser General Public License v2.1
117 stars 34 forks source link

Error: Could not find class file for 'jp.co.infoseek.hp.arton.rjb.RBridge'. #78

Closed JasonBarnabe closed 3 years ago

JasonBarnabe commented 3 years ago

I have a CircleCI build that's failing to build rjb about half the time. The other half, it works fine.

bundle install fails with:

current directory:
/home/circleci/project/vendor/bundle/ruby/2.6.0/gems/rjb-1.6.2/ext
make "DESTDIR="
mkdir -p ../data/rjb/jp/co/infoseek/hp/arton/rjb
javac -d ../data/rjb RBridge.java
javah -classpath ../data/rjb jp.co.infoseek.hp.arton.rjb.RBridge
Error: Could not find class file for 'jp.co.infoseek.hp.arton.rjb.RBridge'.
Makefile:274: recipe for target 'jp_co_infoseek_hp_arton_rjb_RBridge.h' failed
make: *** [jp_co_infoseek_hp_arton_rjb_RBridge.h] Error 1

Environment:

Build-agent version 1.0.49998-c125bdf9 (2021-01-07T17:22:48+0000)
Docker Engine Version: 19.03.13
Kernel Version: Linux 82023c953af0 4.15.0-1077-aws #81-Ubuntu SMP Wed Jun 24 16:48:15 UTC 2020 x86_64 Linux
Starting container circleci/ruby:2.6.6-stretch-node-browsers

Installing Java:

#!/bin/bash -eo pipefail
sudo apt install -y default-jdk

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  default-jdk-headless default-jre default-jre-headless libasyncns0 libflac8
  libogg0 libpulse0 libsndfile1 libvorbis0a libvorbisenc2 openjdk-8-jdk
  openjdk-8-jdk-headless openjdk-8-jre openjdk-8-jre-headless
Suggested packages:
  pulseaudio openjdk-8-demo openjdk-8-source visualvm icedtea-8-plugin
  libnss-mdns fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei
  fonts-wqy-zenhei fonts-indic
The following NEW packages will be installed:
  default-jdk default-jdk-headless default-jre default-jre-headless
  libasyncns0 libflac8 libogg0 libpulse0 libsndfile1 libvorbis0a libvorbisenc2
  openjdk-8-jdk openjdk-8-jdk-headless openjdk-8-jre openjdk-8-jre-headless
0 upgraded, 15 newly installed, 0 to remove and 8 not upgraded.
Need to get 39.2 MB of archives.
After this operation, 148 MB of additional disk space will be used.
0% [Working]Get:1 http://deb.debian.org/debian stretch/main amd64 libogg0 amd64 1.3.2-1 [19.9 kB]
0% [1 libogg0 19.9 kB/19.9 kB 100%] [Waiting for headers]Get:2 http://security.debian.org/debian-security stretch/updates/main amd64 openjdk-8-jre-headless amd64 8u275-b01-1~deb9u1 [28.1 MB]
0% [1 libogg0 19.9 kB/19.9 kB 100%] [2 openjdk-8-jre-headless 41.0 kB/28.1 MB 01% [2 openjdk-8-jre-headless 55.5 kB/28.1 MB 0%]                               Get:3 http://deb.debian.org/debian stretch/main amd64 default-jre-headless amd64 2:1.8-58+deb9u1 [10.1 kB]
2% [3 default-jre-headless 10.1 kB/10.1 kB 100%] [2 openjdk-8-jre-headless 119 3% [2 openjdk-8-jre-headless 137 kB/28.1 MB 0%]                                Get:4 http://deb.debian.org/debian stretch/main amd64 libasyncns0 amd64 0.8-6 [12.5 kB]
3% [4 libasyncns0 12.5 kB/12.5 kB 100%] [2 openjdk-8-jre-headless 168 kB/28.1 M4% [2 openjdk-8-jre-headless 196 kB/28.1 MB 1%]                                Get:5 http://deb.debian.org/debian stretch/main amd64 libvorbis0a amd64 1.3.5-4+deb9u2 [91.7 kB]
5% [5 libvorbis0a 20.4 kB/91.7 kB 22%] [2 openjdk-8-jre-headless 196 kB/28.1 MB6% [2 openjdk-8-jre-headless 261 kB/28.1 MB 1%]                                Get:6 http://deb.debian.org/debian stretch/main amd64 libvorbisenc2 amd64 1.3.5-4+deb9u2 [79.4 kB]
6% [6 libvorbisenc2 43.2 kB/79.4 kB 54%] [2 openjdk-8-jre-headless 278 kB/28.1 8% [2 openjdk-8-jre-headless 348 kB/28.1 MB 1%]                                Get:7 http://deb.debian.org/debian stretch/main amd64 libpulse0 amd64 10.0-1+deb9u1 [283 kB]
8% [7 libpulse0 0 B/283 kB 0%] [2 openjdk-8-jre-headless 348 kB/28.1 MB 1%]10% [2 openjdk-8-jre-headless 655 kB/28.1 MB 2%]                           Get:8 http://deb.debian.org/debian stretch/main amd64 default-jre amd64 2:1.8-58+deb9u1 [930 B]
10% [8 default-jre 930 B/930 B 100%] [2 openjdk-8-jre-headless 655 kB/28.1 MB 212% [Waiting for headers] [2 openjdk-8-jre-headless 714 kB/28.1 MB 3%]         Get:9 http://deb.debian.org/debian stretch/main amd64 default-jdk-headless amd64 2:1.8-58+deb9u1 [1002 B]
13% [Waiting for headers] [2 openjdk-8-jre-headless 714 kB/28.1 MB 3%]Get:10 http://deb.debian.org/debian stretch/main amd64 default-jdk amd64 2:1.8-58+deb9u1 [936 B]
14% [2 openjdk-8-jre-headless 720 kB/28.1 MB 3%]                      72% [Working]                                   Get:11 http://security.debian.org/debian-security stretch/updates/main amd64 libflac8 amd64 1.3.2-2+deb9u1 [221 kB]
72% [11 libflac8 0 B/221 kB 0%]73% [Working]                  Get:12 http://security.debian.org/debian-security stretch/updates/main amd64 libsndfile1 amd64 1.0.27-3+deb9u1 [248 kB]
73% [12 libsndfile1 5958 B/248 kB 2%]75% [Working]                        Get:13 http://security.debian.org/debian-security stretch/updates/main amd64 openjdk-8-jre amd64 8u275-b01-1~deb9u1 [69.5 kB]
75% [13 openjdk-8-jre 19.4 kB/69.5 kB 28%]77% [Working]                             Get:14 http://security.debian.org/debian-security stretch/updates/main amd64 openjdk-8-jdk-headless amd64 8u275-b01-1~deb9u1 [8184 kB]
77% [14 openjdk-8-jdk-headless 14.8 kB/8184 kB 0%]95% [Working]                                     Get:15 http://security.debian.org/debian-security stretch/updates/main amd64 openjdk-8-jdk amd64 8u275-b01-1~deb9u1 [1873 kB]
95% [15 openjdk-8-jdk 21.7 kB/1873 kB 1%]100% [Working]                           Fetched 39.2 MB in 0s (88.2 MB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libogg0:amd64.
(Reading database ... 44694 files and directories currently installed.)
Preparing to unpack .../00-libogg0_1.3.2-1_amd64.deb ...
Unpacking libogg0:amd64 (1.3.2-1) ...
Selecting previously unselected package openjdk-8-jre-headless:amd64.
Preparing to unpack .../01-openjdk-8-jre-headless_8u275-b01-1~deb9u1_amd64.deb ...
Unpacking openjdk-8-jre-headless:amd64 (8u275-b01-1~deb9u1) ...
Selecting previously unselected package default-jre-headless.
Preparing to unpack .../02-default-jre-headless_2%3a1.8-58+deb9u1_amd64.deb ...
Unpacking default-jre-headless (2:1.8-58+deb9u1) ...
Selecting previously unselected package libasyncns0:amd64.
Preparing to unpack .../03-libasyncns0_0.8-6_amd64.deb ...
Unpacking libasyncns0:amd64 (0.8-6) ...
Selecting previously unselected package libflac8:amd64.
Preparing to unpack .../04-libflac8_1.3.2-2+deb9u1_amd64.deb ...
Unpacking libflac8:amd64 (1.3.2-2+deb9u1) ...
Selecting previously unselected package libvorbis0a:amd64.
Preparing to unpack .../05-libvorbis0a_1.3.5-4+deb9u2_amd64.deb ...
Unpacking libvorbis0a:amd64 (1.3.5-4+deb9u2) ...
Selecting previously unselected package libvorbisenc2:amd64.
Preparing to unpack .../06-libvorbisenc2_1.3.5-4+deb9u2_amd64.deb ...
Unpacking libvorbisenc2:amd64 (1.3.5-4+deb9u2) ...
Selecting previously unselected package libsndfile1:amd64.
Preparing to unpack .../07-libsndfile1_1.0.27-3+deb9u1_amd64.deb ...
Unpacking libsndfile1:amd64 (1.0.27-3+deb9u1) ...
Selecting previously unselected package libpulse0:amd64.
Preparing to unpack .../08-libpulse0_10.0-1+deb9u1_amd64.deb ...
Unpacking libpulse0:amd64 (10.0-1+deb9u1) ...
Selecting previously unselected package openjdk-8-jre:amd64.
Preparing to unpack .../09-openjdk-8-jre_8u275-b01-1~deb9u1_amd64.deb ...
Unpacking openjdk-8-jre:amd64 (8u275-b01-1~deb9u1) ...
Selecting previously unselected package default-jre.
Preparing to unpack .../10-default-jre_2%3a1.8-58+deb9u1_amd64.deb ...
Unpacking default-jre (2:1.8-58+deb9u1) ...
Selecting previously unselected package openjdk-8-jdk-headless:amd64.
Preparing to unpack .../11-openjdk-8-jdk-headless_8u275-b01-1~deb9u1_amd64.deb ...
Unpacking openjdk-8-jdk-headless:amd64 (8u275-b01-1~deb9u1) ...
Selecting previously unselected package default-jdk-headless.
Preparing to unpack .../12-default-jdk-headless_2%3a1.8-58+deb9u1_amd64.deb ...
Unpacking default-jdk-headless (2:1.8-58+deb9u1) ...
Selecting previously unselected package openjdk-8-jdk:amd64.
Preparing to unpack .../13-openjdk-8-jdk_8u275-b01-1~deb9u1_amd64.deb ...
Unpacking openjdk-8-jdk:amd64 (8u275-b01-1~deb9u1) ...
Selecting previously unselected package default-jdk.
Preparing to unpack .../14-default-jdk_2%3a1.8-58+deb9u1_amd64.deb ...
Unpacking default-jdk (2:1.8-58+deb9u1) ...
Setting up libasyncns0:amd64 (0.8-6) ...
Processing triggers for mime-support (3.60) ...
Setting up libogg0:amd64 (1.3.2-1) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Setting up libvorbis0a:amd64 (1.3.5-4+deb9u2) ...
Processing triggers for hicolor-icon-theme (0.15-1) ...
Setting up openjdk-8-jre-headless:amd64 (8u275-b01-1~deb9u1) ...
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/orbd to provide /usr/bin/orbd (orbd) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/servertool to provide /usr/bin/servertool (servertool) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/tnameserv to provide /usr/bin/tnameserv (tnameserv) in auto mode
mount: permission denied
update-binfmts: warning: Couldn't mount the binfmt_misc filesystem on /proc/sys/fs/binfmt_misc.
Setting up openjdk-8-jdk-headless:amd64 (8u275-b01-1~deb9u1) ...
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/idlj to provide /usr/bin/idlj (idlj) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/wsimport to provide /usr/bin/wsimport (wsimport) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jsadebugd to provide /usr/bin/jsadebugd (jsadebugd) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/native2ascii to provide /usr/bin/native2ascii (native2ascii) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/javah to provide /usr/bin/javah (javah) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/hsdb to provide /usr/bin/hsdb (hsdb) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/clhsdb to provide /usr/bin/clhsdb (clhsdb) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jhat to provide /usr/bin/jhat (jhat) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/xjc to provide /usr/bin/xjc (xjc) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/schemagen to provide /usr/bin/schemagen (schemagen) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/extcheck to provide /usr/bin/extcheck (extcheck) in auto mode
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/wsgen to provide /usr/bin/wsgen (wsgen) in auto mode
Setting up libflac8:amd64 (1.3.2-2+deb9u1) ...
Setting up libvorbisenc2:amd64 (1.3.5-4+deb9u2) ...
Setting up default-jre-headless (2:1.8-58+deb9u1) ...
Setting up default-jdk-headless (2:1.8-58+deb9u1) ...
Setting up libsndfile1:amd64 (1.0.27-3+deb9u1) ...
Setting up libpulse0:amd64 (10.0-1+deb9u1) ...
Setting up openjdk-8-jre:amd64 (8u275-b01-1~deb9u1) ...
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/policytool to provide /usr/bin/policytool (policytool) in auto mode
Setting up openjdk-8-jdk:amd64 (8u275-b01-1~deb9u1) ...
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/appletviewer to provide /usr/bin/appletviewer (appletviewer) in auto mode
Setting up default-jre (2:1.8-58+deb9u1) ...
Setting up default-jdk (2:1.8-58+deb9u1) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...

CircleCI received exit code 0

Full log of rjb install:

Fetching rjb 1.6.2
Installing rjb 1.6.2 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/circleci/project/vendor/bundle/ruby/2.6.0/gems/rjb-1.6.2/ext
/usr/local/bin/ruby -I /usr/local/lib/ruby/2.6.0 -r
./siteconf20210109-1147-17hj2f.rb extconf.rb
checking for javah... yes
checking for jni.h... yes
checking for locale_charset() in iconv.h... no
checking for nl_langinfo() in langinfo.h... yes
checking for setlocale() in locale.h... yes
checking for getenv()... yes
creating extconf.h
creating Makefile

current directory:
/home/circleci/project/vendor/bundle/ruby/2.6.0/gems/rjb-1.6.2/ext
make "DESTDIR=" clean

current directory:
/home/circleci/project/vendor/bundle/ruby/2.6.0/gems/rjb-1.6.2/ext
make "DESTDIR="
mkdir -p ../data/rjb/jp/co/infoseek/hp/arton/rjb
javac -d ../data/rjb RBridge.java
javah -classpath ../data/rjb jp.co.infoseek.hp.arton.rjb.RBridge
Error: Could not find class file for 'jp.co.infoseek.hp.arton.rjb.RBridge'.
Makefile:274: recipe for target 'jp_co_infoseek_hp_arton_rjb_RBridge.h' failed
make: *** [jp_co_infoseek_hp_arton_rjb_RBridge.h] Error 1

make failed, exit code 2

Gem files will remain installed in
/home/circleci/project/vendor/bundle/ruby/2.6.0/gems/rjb-1.6.2 for inspection.
Results logged to
/home/circleci/project/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/rjb-1.6.2/gem_make.out

An error occurred while installing rjb (1.6.2), and Bundler cannot continue.
Make sure that `gem install rjb -v '1.6.2' --source 'https://rubygems.org/'`
succeeds before bundling.

In Gemfile:
  rjb

Exited with code exit status 5

CircleCI received exit code 5
arton commented 3 years ago

Hi Jason

I think it causes javah and javac version confiction. For my environment,

arton@nomad:~$ javah -version
javahバージョン"1.8.0_265"                    # don't worry バージョン is 'version' in Japanese letters
arton@nomad:~$ javac --version
javac 11.0.6

And I got same error. If your case is above, if you could remove javah in your path. Rjb's extconf.rb detects it and uses javac -h instead of javah.

Regards

JasonBarnabe commented 3 years ago

Thanks for the response. Based on your suggestion, I found that Java openjdk-11 was already included in the image. Removing this first, before installing my preferred version, has made the rjb install consistently succeed.

- run:
    name: Remove pre-installed Java (avoid conflicts)
    command: sudo apt remove openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre openjdk-11-jre-headless
arton commented 3 years ago

Rjb 1.6.3 build process now checks javac and javah version. It uses javac -h if both versions were different.

In this issue, Jason liked to build with elder version of Java. However it builds with newer version of Java according to the below specification. You should check the warning message output by extconf.rb. For example)

warning: javac and javah version unmatch => javah: 1.8.0, javac: 11.0.6