Reputation: 1394
I Generated a project from the Maven Alfresco archetypes:
mvn archetype:generate -Dfilter=org.alfresco:
when I try to build it fails:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/Mehrdad/alfresco/alfresco-platform/src/main/java/com/mehr/alfresco/platformsample/HelloWorldWebScript.java:[20,49] cannot access org.springframework.extensions.webscripts.Cache
bad class file: C:\Users\mehrdad.s\.m2\repository\org\alfresco\surf\spring-webscripts\7.9\spring-webscripts-7.9.jar(org/springframework/extensions/webscripts/Cache.class)
class file has wrong version 55.0, should be 52.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for AIO - SDK 4.0 1.0-SNAPSHOT:
[INFO]
[INFO] AIO - SDK 4.0 ...................................... SUCCESS [ 1.063 s]
[INFO] Alfresco Platform/Repository JAR Module ............ FAILURE [01:54 min]
[INFO] Alfresco Share JAR Module .......................... SKIPPED
[INFO] Integration Tests Module ........................... SKIPPED
[INFO] Alfresco Platform/Repository Docker Module ......... SKIPPED
[INFO] Alfresco Share Docker Module ....................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:02 min
[INFO] Finished at: 2020-03-10T09:42:54+03:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project alfresco-platform: Compilation failure
[ERROR] /D:/Mehrdad/alfresco/alfresco-platform/src/main/java/com/mehr/alfresco/platformsample/HelloWorldWebScript.java:[20,49] cannot access org.springframework.extensions.webscripts.Cache
[ERROR] bad class file: C:\Users\mehrdad.s\.m2\repository\org\alfresco\surf\spring-webscripts\7.9\spring-webscripts-7.9.jar(org/springframework/extensions/webscripts/Cache.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.
D:\Mehrdad\alfresco>java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
D:\Mehrdad\alfresco>javac -version
javac 1.8.0_231
as you see the java
and javac
are 8. I have no idea how to solve this problem.
what is the problem?
Upvotes: 25
Views: 125951
Reputation: 907
Okay, I know it's late to answer the question. However it's never too late.
This issue comes when an API compiled on JDK 11 i.e. major.minor version 55, and your source code is on JDK 8.
We can solve it in many ways.
For JDK 17
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
or
<java.version>17</java.version>
when using JDK 11
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
or
<java.version>11</java.version>
Upvotes: 4
Reputation: 11984
If running from Eclipse (e.g. Maven commands), ensure the right JDK Version is used, under the JRE tab, to avoid any errors in JARs compiled from different JDKs.
Upvotes: 0
Reputation: 168
It happened for me with a pom.xml dependency which version was throwing the error. (the java and javac versions were the same). The solution was to try other versions of the same dependency, which I finally found by downgrading the versions one after the other and try. And finally it compiled fine. :)
Upvotes: 0
Reputation: 514
Well, I know its late to post answer for this, but if it helps anyone.
So the issue is because you have jar file compiled with different versions of java.
Here "Alfresco Platform/Repository JAR Module" is compiled on different version of java than the rest of the module in the project.
If you keep the version similar across the modules then the error will go away.
Upvotes: 4
Reputation: 1316
from your stacktrace spring-webscripts-7.9.jar is compiled with jdk 11. so you got this error (class file has wrong version 55.0, should be 52.0).
Solution: Change spring-webscripts-7.9 to spring-webscripts.7.2 as your system has java 8 version. No need upgrade Java 8 to Java 11.
add the below dependency in your pom.xml file
<!-- https://mvnrepository.com/artifact/org.alfresco.surf/spring-webscripts -->
<dependency>
<groupId>org.alfresco.surf</groupId>
<artifactId>spring-webscripts</artifactId>
<version>7.2</version>
</dependency>
I hope this helps.
Upvotes: 0
Reputation: 12021
It complains that some class files were compiled using Java 11 (which is Java 55.0, List of Java class file format major version numbers?) and you try to compile the rest with Java 8.
You should update your local Java version to at least Java 11 and then try to re-compile again
Upvotes: 36