0

I've below error :

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project camelActiveMqReceiver: Compilation failure
[ERROR] /Users/pranscha/Projects/REPRODUCIBLES/camelActiveMqReceiver/src/main/java/com/camelmicroservices/camelActiveMqReceiver/routes/CamelReceiverRouter.java:[3,24] cannot access org.apache.camel.Exchange
[ERROR]   bad class file: /Users/pranscha/.m2/repository/org/apache/camel/camel-api/3.20.4/camel-api-3.20.4.jar(org/apache/camel/Exchange.class)
[ERROR]     class file has wrong version 55.0, should be 52.0
[ERROR]     Please remove or make sure it appears in the correct subdirectory of the classpath.

Even after adding :

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

The failing dependency is :

        <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-spring-boot-starter</artifactId>
            <version>${camel.version}</version>
        </dependency>

I was expecting org/apache/camel/Exchange.class Java class to work properly in my project with 1.8 version compilation, but even after adding maven.compiler.source & maven.compiler.target, it isn't working.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • 4
    The error message tells you that the Camel API classes have been compiled to target Java 11 (i.e. they require at least Java 11 to run), but you are trying to run your compilation on Java 8 ([see here](https://stackoverflow.com/questions/9170832/list-of-java-class-file-format-major-version-numbers) for the version mapping). Your best bet is to find a version of that dependency that still works on Java 8 if it exists. Recompiling is unlikely to work, as libraries tend to not switch to higher Java versions without good reasons. – Joachim Sauer May 17 '23 at 11:44
  • 3
    [According to this](https://camel.apache.org/manual/what-are-the-dependencies.html) Camel started requiring Java 11 with 3.15.0, so any earlier version should work in Java 8. – Joachim Sauer May 17 '23 at 11:45
  • In addition to previous comments Maven doesn't recompile dependencies. – aled May 17 '23 at 14:56

0 Answers0