Git Product home page Git Product logo

Comments (10)

alvarosanchez avatar alvarosanchez commented on August 16, 2024 1

I'm glad you finally found out why you were running with Java 8 👍

I still believe that the plugin is buggy since it's behavior is erratic: you can make it to call a different Java version than the one is used by the project (like 8 in my case)

This has nothing to do with the plugin. Maven (and Gradle, and pretty much all Java applications) will run with the java version that you have configured on your system, and not having any java in the search PATH is the root of your problems. Properly setting your development environment is out of scope here.

The JDK version in your POM is only meaningful for the Maven Compiler Plugin. This plugin does nothing with it. It allows you to do things like compile with JDK 21 but produce 17 bytecode.

Switching JAVA_HOME and PATH to the desired JDK version is what everybody do (and the reason why things like SDKMAN exist), but even if you are unable/unwilling to set them properly, you can still configure Maven Toolchains

from micronaut-maven-plugin.

nedelva avatar nedelva commented on August 16, 2024

I added the project to my GitHub account for your convenience: aotdemo.

Funny thing is, the error does not reproduce on a MacBook Pro machine 😟

from micronaut-maven-plugin.

alvarosanchez avatar alvarosanchez commented on August 16, 2024

You are running with Java 8 which is not supported by Micronaut 4.

from micronaut-maven-plugin.

nedelva avatar nedelva commented on August 16, 2024

@alvarosanchez I am sorry but you were too quick to dismiss it. I am NOT using Java 8 , I am using Java 17.

Tagging with "cannot reproduce" is just lazy, since you can reproduce it easily on a Windows machine if you bother to clone the aotdemo project and try to build it on a Windows machine.

Very dissapointed with the way you handled it.

from micronaut-maven-plugin.

alvarosanchez avatar alvarosanchez commented on August 16, 2024

@nedelva no need to be so disrespectful.

If you care enough to read your own details, you will find that:

io/micronaut/maven/testresources/TestResourcesLifecycleExtension has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0

So even if you think you are running with Java 17 (class file version 61.0), you are not. You are running with Java 8 (version 52.0).

Besides, mn:aot-sample-config is tested on CI with Java 17 and Java 21 and even on Windows.

But if this weren't enough, I did take the time to try to reproduce it locally (look at the timestamps):

image

Nevertheless, you always have the chance to provide more context and/or request for this issue to be reopened. I didn't lock this conversation.

Next time, I would appreciate it if you could show more respect for an OSS contributor.

from micronaut-maven-plugin.

nedelva avatar nedelva commented on August 16, 2024

@alvarosanchez I think my objections still stand. What you are showing me is

  1. a demo project build on Mac (NOT on a Windows machine) -- I also mentioned that the issue does not reproduce on a Mac
  2. a few builds of the plugin itself on Docker instances (NOT the same thing as using the plugin to build!)

None of the above disproves my claims. I urge you to actually try to build the sample project on a Windows machine and you will see that the issue does occur indeed.

from micronaut-maven-plugin.

alvarosanchez avatar alvarosanchez commented on August 16, 2024

Why you keep ignoring this?

this version of the Java Runtime only recognizes class file versions up to 52.0

You are running with Java 8. But if you insist on making this more embarrassing, here's a screenshot of your project running on a Windows machine:

image-2

from micronaut-maven-plugin.

nedelva avatar nedelva commented on August 16, 2024

My submissions for the image gallery contest 🥇

The project settings, where you can see I use JDK 21 in fact:

intellij-aotdemo-project-settings

Also don't forget that is not possible to execute the build with java 8 since the POM specifies the properties

    <jdk.version>17</jdk.version>
    <release.version>17</release.version>

See here what running from command prompt gives me. First, I set the JAVA_HOME environment variable:

intellij-cmd-set-java-home

The exact command you ran:
aotdemo-cmdline-part1

But I think the clue to the puzzle can be seen in the second image of the run (see my red underline)
aotdemo-cmdline-part2

@alvarosanchez Here's the trick question for you: If on a Windows machine there are several Java JDK versions installed, which one is picked when the plugin invokes the command java? 😈

(I admit, I unintentionally threw you on a wrong path by forgetting to mention that I have SEVERAL JDKs installed on my machine)

from micronaut-maven-plugin.

alvarosanchez avatar alvarosanchez commented on August 16, 2024

JAVA_HOME is not enough. Your PATH is pointing to a Java 8 installation.

Running mvn --version (or even java -version) will tell you this info.

from micronaut-maven-plugin.

nedelva avatar nedelva commented on August 16, 2024

Ok, I will save you the trouble to find out yourself what's going on exactly. See, on my machine there was also Java 8 installed via the MSI installer. This thing modifies the Windows registry so I did not need to use JAVA_HOME nor the PATH variables to invoke java on the command prompt.

Because of this, when the 'java' was invoked by the plugin, it was picking Java 8 because there was NOTHING on the PATH variable to point to a different version.

I remedied the situation by

  1. Uninstalling the Java 8 JDK using the Control Panel and
  2. I added several full paths to the bin directory for each of the JDKs into the user's PATH variable. Now invoking java picks up whichever version is found first (here 21):
    windows-userenv-path-variable

I am happy that I have gotten past the issue and found a workaround. I still believe that the plugin is buggy since it's behavior is erratic: you can make it to call a different Java version than the one is used by the project (like 8 in my case). But I am certain you could easily spot now the trouble with current arrangement.

from micronaut-maven-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.