java.lang.unsupportedclassversionerror in gradle build
Asked Answered
S

2

0

Am getting java.lang.unsupportedclassversionerror in gradle build, it is a multiproject gradle build. Am using Java-8 and it was working so far but, all of a sudden it stopped working and started throwing the below exception.

com.google.common.util.concurrent.ExecutionError: com.google.common.util.concurrent.ExecutionError: com.google.common.util.concurrent.ExecutionError: com.google.common.util.concurrent.ExecutionError: com.google.common.util.concurrent.ExecutionError: java.lang .UnsupportedClassVersionError: org/eclipse/core/runtime/OperationCanceledException has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

below is the seeting.gradle

rootProject.name = 'ecommerce'

include ':ecommerce:commandLine'
include ':ecommerce:commandExecution'

include ':ecommerce:model'
include ':ecommerce:model-validation'
include ':ecommerce:modelframework'
include ':ecommerce:model-graphql'
include ':ecommerce:server'
include ':ecommerce:utilityhandler'

As I already mentioned, this was working till these days and started throwing the above exception. Any help here is appreciated. Thanks in advance

Silesia answered 18/6, 2021 at 20:32 Comment(0)
S
1

One of your dependencies was compiled to target Java 11 and can't be loaded into a older JRE. Given the package of the class that failed to load you should look for org.eclipse.core dependencies. You will either need to downgrade your dependency or look into updating your codebase to use Java 11.

Secor answered 18/6, 2021 at 20:41 Comment(2)
is there any way to instruct in gradle to use only the dependency which is compatible with java 8.Silesia
Gradle doesn't contain information about what version of java was used to build a dependency. You have to go figure out if there is a release version that is compatible. It may be that the latest version is incompatible with java 8.Secor
E
1

I'm also having this problem today. The problem seems to be the Xtend plugin which is now pulling in a version of equinox that was built for java 11 and can't run on the java 8 in our VM. I don't know if our contract will allowed us to update that.

Exceedingly answered 18/6, 2021 at 22:2 Comment(3)
any fix you found for this, i tried using all the versions everything is failing. The only one that fixed is removing the dependency, adding xtend to classpath from eclipse plugin folder, then copying that jar to lib folder and giving that path in gradle. but, this has issue in loading main class from jar.Silesia
OK, I managed to find a workaround that seems to work (see github.com/eclipse/xtext/issues/1976). Adding a resolution strategy for some problematic components allows me to run under Java 8. See github.com/eclipse/xtext/issues/1976#issuecomment-864946993Exceedingly
Carl, thanks for the support. Am using gradle so what actually worked for me is this github.com/itemis/xtext-reference-projects/commit/… workaround should work (same as in the link above)Silesia

© 2022 - 2024 — McMap. All rights reserved.