Skip to content

Unable to build Java targets in Google Cloud Shell #5766

Closed

Description

@vmax

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

Activity

  1. jyksnw commented on Aug 6, 2018

    @jyksnw

    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
    
  2. buchgr commented on Aug 6, 2018

    @buchgr
    Contributor

    @cushon any ideas?

  3. cushon commented on Aug 6, 2018

    @cushon
    Contributor

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

    This sounds related to #5744

  4. jyksnw commented on Aug 6, 2018

    @jyksnw

    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

  5. cushon commented on Aug 7, 2018

    @cushon
    Contributor

    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.

  6. buchgr commented on Aug 10, 2018

    @buchgr
    Contributor

    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

  7. vmax commented on Aug 11, 2018

    @vmax
    ContributorAuthor

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions