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

jpamodelgen fails with range out of bounds #38950

Closed
Postremus opened this issue Feb 22, 2024 · 9 comments
Closed

jpamodelgen fails with range out of bounds #38950

Postremus opened this issue Feb 22, 2024 · 9 comments
Labels
area/hibernate-orm Hibernate ORM kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.
Milestone

Comments

@Postremus
Copy link
Member

Describe the bug

I am currently in the process of preparing migration to quakus 3.8. One of my commons modules contains mappedsupperclasses like this:

@MappedSuperclass
public abstract class Access<A extends Access<A, AG>, AG extends AccessGrant<A, AG>> {

    private static final long serialVersionUID = 1L;

    public abstract Set<AG> getGrants();

    public abstract void setGrants(Set<AG> grants);
}

With quarkus 3.5, the jpamodelgen sucessfuly generated the metamodel.
Startin with quarkus 3.7.1 and up, not anymore, see log below.

Expected behavior

My metamodel is again successfully generated.

This is the excpected output for the Access class.

@Generated(value = "org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor")
@StaticMetamodel(Access.class)
public abstract class Access_ {

	public static volatile SetAttribute<Access, AccessGrant> grants;

	public static final String GRANTS = "grants";

}

Actual behavior

C:\workspaces\mpp\projects\jpa-modelgen-line>mvn clean install -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< org.acme:jpa-modelgen-line >---------------------
[INFO] Building jpa-modelgen-line 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ jpa-modelgen-line ---
[INFO] Deleting C:\workspaces\mpp\projects\jpa-modelgen-line\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jpa-modelgen-line ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.12.1:compile (default-compile) @ jpa-modelgen-line ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 2 source files with javac [debug release 17] to target\classes
[INFO] Hibernate/JPA static Metamodel Generator 6.4.2.Final
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Error generating JPA metamodel: Range [16, -1) out of bounds for length 17
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.278 s
[INFO] Finished at: 2024-02-22T07:03:47+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.12.1:compile (default-compile) on project jpa-modelgen-line: Compilation failure
[ERROR] Error generating JPA metamodel: Range [16, -1) out of bounds for length 17
[ERROR]
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.12.1:compile (default-compile) on project jpa-modelgen-line: Compilation failure
Error generating JPA metamodel: Range [16, -1) out of bounds for length 17

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
Error generating JPA metamodel: Range [16, -1) out of bounds for length 17

    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1269)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:212)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:103)
    at java.lang.reflect.Method.invoke (Method.java:580)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

How to Reproduce?

Reproducer:
jpa-modelgen-line.zip

mvn clean install

build fails

Output of uname -a or ver

MINGW64_NT-10.0-19045 NANBCHL9NG3 3.3.6-341.x86_64 2022-09-05 20:28 UTC x86_64 Msys

Output of java -version

openjdk 21.0.2 2024-01-16 LTS OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13-LTS, mixed mode, sharing)

Quarkus version or git rev

3.7.1, 3.8.0.CR1

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537) Maven home: C:\eclipse\tools\java\maven Java version: 21.0.2, vendor: Eclipse Adoptium, runtime: C:\eclipse\tools\java\21 Default locale: de_DE, platform encoding: UTF-8 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additional information

No response

@Postremus Postremus added the kind/bug Something isn't working label Feb 22, 2024
@quarkus-bot quarkus-bot bot added env/windows Impacts Windows machines triage/needs-triage labels Feb 22, 2024
@Postremus Postremus added area/hibernate-orm Hibernate ORM and removed env/windows Impacts Windows machines triage/needs-triage labels Feb 22, 2024
Copy link

quarkus-bot bot commented Feb 22, 2024

/cc @gsmet (hibernate-orm), @yrodiere (hibernate-orm)

@Postremus
Copy link
Member Author

There is already a similar issue on the hibernate tracker: https://hibernate.atlassian.net/jira/software/c/projects/HHH/issues/HHH-17514
Which has a PR hibernate/hibernate-orm#7637.

I am however not sure if it describes the same situation as mine - and wanted the issue to be tracked here as well, so it is easier to find for other quarkus users.

@yrodiere
Copy link
Member

I am however not sure if it describes the same situation as mine - and wanted the issue to be tracked here as well, so it is easier to find for other quarkus users.

Given there is little specific to Quarkus in jpamodelgen... I'd bet on this being totally unrelated to Quarkus.

There is already a similar issue on the hibernate tracker: https://hibernate.atlassian.net/jira/software/c/projects/HHH/issues/HHH-17514 Which has a PR hibernate/hibernate-orm#7637.

Thanks for linking to the upstream issue. Let's close when we upgrade to the relevant upstream version then.

@Postremus
Copy link
Member Author

FTR.
As a workaround, I declare a known good version of the jpamodelgen in my own dependencymanagement.

<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.hibernate.orm</groupId>
                <artifactId>hibernate-jpamodelgen</artifactId>
                <version>6.2.13.Final</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

Now I can already switch to declaring my annotationProcessors using the compiler plugin.

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.hibernate.orm</groupId>
                            <artifactId>hibernate-jpamodelgen</artifactId>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>

This uses my own declared version of 6.2.13.Final - and the build is succesfull. Once the bug is fixed upstream (and quarkus updated), I can simply remove the entry from my own dependency-management.

@geoand
Copy link
Contributor

geoand commented May 17, 2024

Has this since been fixed?

@geoand geoand added the triage/needs-feedback We are waiting for feedback. label May 17, 2024
@yrodiere
Copy link
Member

The fix was in Hibernate ORM 6.4.0, which we upgraded to in #36978, first released in Quarkus 3.7.0.CR1.

So yes it's been fixed, I just forgot to list it in the relevant PR, sorry.

Closing.

@yrodiere yrodiere added this to the 3.7.0.CR1 milestone May 17, 2024
@geoand
Copy link
Contributor

geoand commented May 17, 2024

Thanks!

@yrodiere
Copy link
Member

Wait... that's wrong. https://hibernate.atlassian.net/browse/HHH-17514 affects 6.4.0, it's not fixed there. The issue is still open upstream.

Reopening...

@yrodiere yrodiere reopened this May 17, 2024
@yrodiere yrodiere removed this from the 3.7.0.CR1 milestone May 17, 2024
@yrodiere
Copy link
Member

So the bug was apparently fixed somewhere between 6.4.1 and 6.4.8, see https://hibernate.atlassian.net/browse/HHH-17514. But since it was fixed by an unrelated change, I don't know which version

I don't think it matters anyway; in Quarkus, it's fixed for sure by #40102 in Quarkus 3.11.0.CR1, and should also be fixed in any version that upgrades to Hibernate ORM 6.4.8 (I'll send a PR shortly for Quarkus 3.8).

@yrodiere yrodiere added this to the 3.11.0.CR1 milestone May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/hibernate-orm Hibernate ORM kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.
Projects
None yet
Development

No branches or pull requests

3 participants