Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build Java targets in Google Cloud Shell #5766

Closed
vmax opened this issue Aug 4, 2018 · 7 comments
Closed

Unable to build Java targets in Google Cloud Shell #5766

vmax opened this issue Aug 4, 2018 · 7 comments

Comments

@vmax
Copy link
Contributor

vmax commented Aug 4, 2018

Description of the problem / feature request:

Cannot build Java targets on Google Cloud Shell

Feature requests: what underlying problem are you trying to solve with this feature?

Trying to make a tutorial that utilizes bazel

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

$ cat > BUILD << EOF
java_binary(
name="main",
srcs=["Main.java"],
main_class='com.example.Main'
)
EOF

$ cat > Main.java << EOF
package com.example;

public class Main {
	public static void main(String[] args) {
		System.out.println("Hello world!");
	}
}
EOF

$ touch WORKSPACE
$ bazel build //:main
INFO: Analysed target //:main (0 packages loaded).
INFO: Found 1 target...
ERROR: missing input file '@local_jdk//:jre/lib/resources.jar'
ERROR: /home/vmax0770/example/BUILD:1:1: //:main: missing input file '@local_jdk//:jre/lib/resources.jar'
Target //:main failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /home/vmax0770/example/BUILD:1:1 1 input file(s) do not exist
INFO: Elapsed time: 0.372s, Critical Path: 0.01s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

What operating system are you running Bazel on?

$ uname -a
Linux cs-6000-devshell-vm-e30028a8-d952-44be-bf5f-f01806facc02 4.14.33+ #1 SMP Sat Jul 28 01:03:28 PDT 2018 x86_64 GNU/Linux

What's the output of bazel info release?

release 0.16.0

Have you found anything relevant by searching the web?

Found a similar issue that was closed with no solution by the author: #2533

Any other information, logs, or outputs that you want to share?

The error I get here is flaky. For example, after running bazel clean --expunge; bazel build //:main I was able to get (notice charsets.jar instead of resources.jar:

INFO: Analysed target //:main (15 packages loaded).
INFO: Found 1 target...
ERROR: missing input file '@local_jdk//:jre/lib/charsets.jar'
ERROR: /home/vmax0770/example/BUILD:1:1: //:main: missing input file '@local_jdk//:jre/lib/charsets.jar'
Target //:main failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /home/vmax0770/example/BUILD:1:1 1 input file(s) do not exist
$ update-java-alternatives --list
java-1.8.0-openjdk-amd64       1081       /usr/lib/jvm/java-1.8.0-openjdk-amd64
$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64/jre
@jyksnw
Copy link

jyksnw commented Aug 6, 2018

I am having the same or similar problem.

Description of the problem/feature request:
Cannot build Java targets on Ubuntu 18.04

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Same setup posted by @vmax

What operating system are you running Bazel on?
Ubuntu 18.04

$ uname -a
Linux goofy 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

What's the output of bazel info release?

$ bazel info release
release 0.16.0

Have you found anything relevant by searching the web?
This bug along with #2533

Any other information, logs, or outputs that you want to share?

INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes.
Starting local Bazel server and connecting to it...
INFO: Analysed target //:solarnet_deploy.jar (15 packages loaded).
INFO: Found 1 target...
ERROR: missing input file '@local_jdk//:jre/lib/rt.jar'
ERROR: /home/jsnow/workspace/solartech/devstack/BUILD:1:1: //:solarnet: missing input file '@local_jdk//:jre/lib/rt.jar'
Target //:solarnet_deploy.jar failed to build
ERROR: /home/jsnow/workspace/solartech/devstack/BUILD:1:1 1 input file(s) do not exist
INFO: Elapsed time: 2.232s, Critical Path: 0.02s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

@buchgr
Copy link
Contributor

buchgr commented Aug 6, 2018

@cushon any ideas?

@cushon
Copy link
Contributor

cushon commented Aug 6, 2018

missing input file '@local_jdk//:jre/lib/rt.jar'

This sounds related to #5744

@jyksnw
Copy link

jyksnw commented Aug 6, 2018

Even though java and javac are Java 8, JAVA_HOME appears to be set to Java 10. I had to update /etc/environment to point to the correct JAVA_HOME which corrected my problem. I was able to figure this out by reading through #5744

@cushon
Copy link
Contributor

cushon commented Aug 7, 2018

The --javabase discovery uses JAVA_HOME and which javac, in that order (I don't know what the rationale for the order was):

string javahome = GetEnv("JAVA_HOME");

The issue with Bazel not supporting JDK > 8 --javabases, and defaulting to using the embedded JDK 10 as the --javabase if JAVA_HOME is unset, will be tracked by /issues/5744.

@buchgr
Copy link
Contributor

buchgr commented Aug 10, 2018

We have created a 0.16.1 release candidate and are planning on releasing this as 0.16.1 on Monday. Please give it a spin https://releases.bazel.build/0.16.1/rc2/index.html

@vmax
Copy link
Contributor Author

vmax commented Aug 11, 2018

@buchgr thanks for the tip, seems upgrading actually resolved the issue 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants