1

I am getting compilation error when compiling a Jdk8 codebase with OpenJdk11 on Serializable class with error : The type java.io.Serializable cannot be resolved. It is indirectly referenced from required .class files

[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.4:compile (default) on project test-proj: Compiler errors:
[ERROR] error at public abstract class HiberTypeMapper implements UserType, Serializable {
[ERROR]                                                               ^^^^^^^^^^^
[ERROR] /dev_loc/test-proj/src/main/java/com/hiber/HiberTypeMapper.java:13:0::0 The type java.io.Serializable cannot be resolved. It is indirectly referenced from required .class files
[ERROR]
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.4:compile (default) on project il-commons: Compiler errors:
error at public abstract class HiberTypeMapper implements UserType, Serializable {
                                                              ^^^^^^^^^^^
/dev_loc/test-proj/src/main/java/com/hiber/HiberTypeMapper.java:13:0::0 The type java.io.Serializable cannot be resolved. It is indirectly referenced from required .class files

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)

The class which it is complaining on

package com.hiber;

import java.io.Serializable;

import org.hibernate.usertype.UserType;


public abstract class HiberTypeMapper implements UserType, Serializable {
...
}

My versions are :

Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T15:39:06-04:00)
Maven home: /Users/jogi/Apps/apache-maven-3.5.0
Java version: 11.0.7, vendor: AdoptOpenJDK
Java home: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.13.6", arch: "x86_64", family: "mac"

Please suggest the solution, Serializable interface is part of java.base module, so why the compiler is giving error.

YS_NE
  • 194
  • 2
  • 21
  • Can we see your `pom.xml`? – Jacob G. Jun 01 '20 at 02:46
  • @JacobG - The pom.xml is pretty much what I was using with Jdk8. But I have updated few things, like maven-compiler-plugin version to 3.8.0. from 3.0. And aspect-maven-plugin to version 1.11 from 1.4. The pom.xml is pretty big and it has reference of all our internal libraries and third party libraries. Is it possible, if I can send a certain section of it? – YS_NE Jun 01 '20 at 03:09
  • "And aspect-maven-plugin to version 1.11 from 1.4" - It shows `1.4` in the compiler error that you posted. – Jacob G. Jun 01 '20 at 03:10
  • 1
    @JacobG Thats a good point. Since the aspectj-maven-plugin version was defined in dependency-management, so it had to be refreshed. The error which I raised on Serializable, is no longer happening. Thanks a lot. – YS_NE Jun 01 '20 at 16:57

1 Answers1

1

Jacob G. helped resolving it that it could be due to aspectj-maven-plugin version. For OpenJdk11, version 1.4 will not work. After upgrading it to 1.11, this error is no longer occurring.

YS_NE
  • 194
  • 2
  • 21