I am trying to upgrade Java version from 1.7
to 1.8
.
Didn't change any code apart from upgrading target version to 1.8 in Maven plugin.
Error: cannot access Versioned
.
Source:
private ObjectMapper mapper = new ObjectMapper();
return mapper.writeValueAsString(data);
Couldn't find any documentation anywhere in the internet. I thought 1.8
should be completely backward compatible.
Edit: Without even changing pom, if I set my local maven to Java 8, it's still breaking. So compiling with Java 8 is having issue :(
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.2.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.1.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.2.2:compile
[INFO] +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] | +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.2.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.1.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.2.2:compile
[INFO] +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] | +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.2.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.1.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.2.2:compile
[INFO] +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] | +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.2.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.1.0:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.2.2:compile
[INFO] +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] | +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.2:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.2.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.1.0:compile
[INFO] | +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.11:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.11:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.2.2:compile
[INFO] +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] | +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.2:compile
[INFO] +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] | | +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.11:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.0-rc2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.2.2:compile
[INFO] +- com.fasterxml:jackson-xml-databind:jar:0.6.2:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] | +- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.2.2:compile
-X output:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project my-module: Compilation failure
[ERROR] /Users/xxxxxx/MyApp.java:[52,15] error: cannot access Versioned
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project myntra-orch-lms: Compilation failure
/Users/xxxxxx/MyApp.java:[52,15] error: cannot access Versioned
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
/Users/xxxxxx/MyApp.java:[52,15] error: cannot access Versioned
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:656)
at org.apache.maven.plugin.CompilerMojo.execute(CompilerMojo.java:128)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
[ERROR]
[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
It looks like you are using a mix of very old Jackson versions. I suspect that in Java 8 the order of the .jar files used by the Maven compiler plugin can be different then in Java 7 so the Versioned
interface may not be found. It can be an issue since in Java 8 the java compiler requires the interface to be present in the classpath when compiling the implementation (JDK-8055048).
The Versioned
interface was introduced in 1.6.0 while you have the org.codehaus.jackson:jackson-core-asl
version 1.1.0. That is probably the root cause of the the problem.
A low risk fix could be to bump the org.codehaus.jackson:jackson-core-asl
version to 1.9.2 to correspond the other libraries by adding the following dependency in the .pom file:
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.2</version>
</dependency>
As a long term solution I suggest to consider bumping the Jackson version to the latest 2.X (packaged in com.fastxml.jackson
) in all your projects and stop using version 1.X (packaged in org.codehaus.jackson
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With