newtmitch / docker-sonar-scanner

Quick sonar scanner docker image
MIT License
129 stars 88 forks source link

FROM java:8 on MacOS Sierra #3

Closed ned-horvath closed 7 years ago

ned-horvath commented 7 years ago

Scanner failed to build for me on MacOS X Sierra (10.12.5). Changing Dockerfile line 1 to FROM: java:8 allowed a successful build.

newtmitch commented 7 years ago

Trying this now with the existing Java 7 base to see how it goes. I'm also on Sierra.

Not sure why building this on Mac makes a difference, though, as Java 7 is the foundation for the Docker container itself and has nothing to do with the host. What exactly are you seeing as a failed build?

newtmitch commented 7 years ago

Just tested on my local system with Java 7 as the foundation and didn't see anything strange. I did have to add the following to sonar-runner.properties just to have it not fail to run, but apparently this isn't unusual (but I likely should have more reasonable, usable defaults, at least):

sonar.projectKey=myprojectkey
sonar.projectName=My Project Name
sonar.projectVersion=1
sonar.sources=.
ned-horvath commented 7 years ago

Hey Ryan,

The build of both containers goes fine, but when I run a scan, I get the output below. I using that minimal sonar-project.properties (different values, but same keys). Using 'FROM java:8' cures the problem, as noted. (I'm operating pretty much fire-and-pray here, this is a smoke test and I haven't dug into the sonar project at all.) FWIW, I'm running latest Docker for Mac (Edge/community edition), although I'm guessing that's irrelevant.

And while on the subject -- thanks for doing this work, I'm a software engineer at the IT Services department at UT here in Austin, and being able to run Sonar on a developer's workstation using Docker is probably all my customers will need for the foreseeable future. I'm hoping to use it to launch a conversation / community of practice about code quality and software craftsmanship, and budgets being what they are, the price is right. If you find yourself in Austin, shoot me a text, I'll buy you a beer (maybe even some BBQ!).

Best regards, Ned

INFO: Scanner configuration file: /root/sonar-scanner-2.5.1/conf/sonar-runner.properties

INFO: Project configuration file: /root/./src/sonar-project.properties

INFO: SonarQube Scanner 2.5.1

INFO: Java 1.7.0_111 Oracle Corporation (64-bit)

INFO: Linux 4.9.31-moby amd64

INFO: User cache: /root/.sonar/cache

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/sonar/batch/bootstrapper/EnvironmentInformation : Unsupported major.minor version 52.0

at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(ClassLoader.java:803)

at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)

at java.net.URLClassLoader.access$100(URLClassLoader.java:71)

at java.net.URLClassLoader$1.run(URLClassLoader.java:361)

at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

at java.security.AccessController.doPrivileged(Native Method)

at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

at org.sonar.runner.impl.IsolatedClassloader.loadClass(IsolatedClassloader.java:82)

at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

at org.sonar.runner.batch.DefaultBatchFactory.createBatch(DefaultBatchFactory.java:33)

at org.sonar.runner.batch.BatchIsolatedLauncher.start(BatchIsolatedLauncher.java:56)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.sonar.runner.impl.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:61)

at com.sun.proxy.$Proxy0.start(Unknown Source)

at org.sonar.runner.api.EmbeddedRunner.doStart(EmbeddedRunner.java:251)

at org.sonar.runner.api.EmbeddedRunner.start(EmbeddedRunner.java:187)

at org.sonar.runner.api.EmbeddedRunner.start(EmbeddedRunner.java:182)

at org.sonarsource.scanner.cli.Main.execute(Main.java:76)

at org.sonarsource.scanner.cli.Main.main(Main.java:66)

On Mon, Jun 26, 2017 at 6:32 PM, Ryan Mitchell notifications@github.com wrote:

Just tested on my local system with Java 7 as the foundation and didn't see anything strange. I did have to add the following to sonar-runner.properties just to have it not fail to run, but apparently this isn't unusual (but I likely should have more reasonable, usable defaults, at least):

sonar.projectKey=myprojectkey sonar.projectName=My Project Name sonar.projectVersion=1 sonar.sources=.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/newtmitch/docker-sonar-scanner/issues/3#issuecomment-311210421, or mute the thread https://github.com/notifications/unsubscribe-auth/AS2ou4GEISAJReIp81Sz4ikp-Brkuko7ks5sID-CgaJpZM4OFTrO .

-- Edward C Horvath, PhD Skype/Twitter/LinkedIn: NedHorvath Mobile +1 512 743 2022

"I'm confused." "It's a big club. We should get T-shirts." - The Doctor

vyo commented 7 years ago

@ned-horvath looks like you're analysing a Java8 project (major.minor 52.0) with a Java7 SDK as per Docker image.

As such requiring Java 8 looks sensible, as does the whole thing working when basing it off of the java:8 image.

edit: Looks like Sonar switching to Java 8 is the culprit here https://blog.sonarsource.com/sonar-ecosystem-upgrades-to-java-8/

newtmitch commented 7 years ago

@vyo Good catch. Regardless of what my repo uses now, it makes sense it should probably update to Java 8. Let me make that change, test it, and commit. The blog entry is right - no reason to stick on 7 if there's no specific reason to.

newtmitch commented 7 years ago

@ned-horvath Thanks for the detail. I'm guessing based on your statement that you built both containers that the Dockerfile.server build is the problem - it's pulling sonarqube:latest, I noticed, while the README for the project actually gives you the command line for starting sonarqube:5.2. I did the latter when I tested, which didn't show an error. Per @vyo's comment, my guess is that using the latest version of Sonar Qube would exhibit the problem you're seeing. I think that's confusion between my README and the server Dockerfile that I have in the project. I'll fix the README accordingly, as well as update the scanner's Dockerfile for Java 8 after doing a quick test on my side.

Glad you're getting use out of this container - I built it just to fiddle around with it and see how it worked - obviously I don't use it very often myself. That said, I'm also Austin-based, software dev / product / fullstack type guy. Perhaps we should meet up sometime, I can never turn down a beer, but I'll require I buy you one as well for troubleshooting my crap-code. :)

newtmitch commented 7 years ago

Just confirmed that when I run from the included Dockerfile.server as a base, it shows the "unsupported major/minor" version thing you're seeing. I believe my suspicion as to the problem is correct. If you use Sonarqube:5.2 per the README, it should work fine. I'm going to update to Java 8 to see if the problem is corrected as you both have seen. I'm sure it will, but I like to see for myself. :)

newtmitch commented 7 years ago

Updated and confirmed working. Thanks for the help, guys.

ned-horvath commented 7 years ago

Thanks again for doing this in the first place, Ryan!

On Wed, Jun 28, 2017 at 3:06 PM, Ryan Mitchell notifications@github.com wrote:

Updated, ran and confirmed working. Thanks for the help, guys.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/newtmitch/docker-sonar-scanner/issues/3#issuecomment-311772903, or mute the thread https://github.com/notifications/unsubscribe-auth/AS2ou3k5jIZEqp21lmprrIl4l4J88yppks5sIrI5gaJpZM4OFTrO .

-- Edward C Horvath, PhD Skype/Twitter/LinkedIn: NedHorvath Mobile +1 512 743 2022

"I'm confused." "It's a big club. We should get T-shirts." - The Doctor

newtmitch commented 7 years ago

For sure - figured I needed to get something out in the community somewhere to give back a bit... :) Drop me a note if you're interested in getting together for a beer. I'm around.