Created
April 19, 2021 07:34
-
-
Save niklasfi/49a5cf360e6ba9169438b3b86b56a89c to your computer and use it in GitHub Desktop.
Model Mapper fails to configure with JDK 16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example; | |
import org.modelmapper.ModelMapper; | |
import org.modelmapper.AbstractCondition; | |
import org.modelmapper.PropertyMap; | |
import org.modelmapper.convention.MatchingStrategies; | |
import org.modelmapper.spi.MappingContext; | |
public class ModelMapperJDK16Test { | |
public static class Foo { | |
private int id; | |
public int getId(){ | |
return this.id; | |
} | |
} | |
public static class Bar { | |
private int id; | |
public void setId(int id){ | |
this.id = id; | |
} | |
public int getId(){ | |
return this.id; | |
} | |
} | |
public ModelMapper configure(){ | |
ModelMapper modelMapper = new ModelMapper(); | |
modelMapper.addMappings(new PropertyMap<Foo, Bar>() { | |
@Override | |
protected void configure() { | |
skip(destination.getId()); | |
} | |
}); | |
return modelMapper; | |
} | |
public static void main(String[] args) { | |
new ModelMapperJDK16Test().configure(); | |
System.out.println("all good!"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[INFO] Scanning for projects... | |
[INFO] | |
[INFO] ------------------< com.example:modelmapperjdk16test >------------------ | |
[INFO] Building modelmapperjdk16test 0.0.1-SNAPSHOT | |
[INFO] --------------------------------[ jar ]--------------------------------- | |
[INFO] | |
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ modelmapperjdk16test --- | |
[INFO] Deleting /home/niklas/pwc-dev/modelmapper/target | |
[INFO] | |
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ modelmapperjdk16test --- | |
[INFO] Using 'UTF-8' encoding to copy filtered resources. | |
[INFO] skip non existing resourceDirectory /home/niklas/pwc-dev/modelmapper/src/main/resources | |
[INFO] | |
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ modelmapperjdk16test --- | |
[INFO] Changes detected - recompiling the module! | |
[INFO] Compiling 1 source file to /home/niklas/pwc-dev/modelmapper/target/classes | |
[INFO] | |
[INFO] --- exec-maven-plugin:3.0.0:java (default-cli) @ modelmapperjdk16test --- | |
[WARNING] | |
org.modelmapper.ConfigurationException: ModelMapper configuration errors: | |
1) Failed to configure mappings | |
1 error | |
at org.modelmapper.internal.Errors.throwConfigurationExceptionIfErrorsExist (Errors.java:241) | |
at org.modelmapper.internal.ExplicitMappingBuilder.build (ExplicitMappingBuilder.java:252) | |
at org.modelmapper.internal.ExplicitMappingBuilder.build (ExplicitMappingBuilder.java:104) | |
at org.modelmapper.internal.TypeMapImpl.addMappings (TypeMapImpl.java:92) | |
at org.modelmapper.internal.TypeMapStore.getOrCreate (TypeMapStore.java:124) | |
at org.modelmapper.ModelMapper.addMappings (ModelMapper.java:113) | |
at com.example.ModelMapperJDK16Test.configure (ModelMapperJDK16Test.java:29) | |
at com.example.ModelMapperJDK16Test.main (ModelMapperJDK16Test.java:40) | |
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254) | |
at java.lang.Thread.run (Thread.java:831) | |
Caused by: java.lang.NullPointerException: Cannot read field "methodProxies" because "x0" is null | |
at org.modelmapper.internal.ExplicitMappingBuilder$ExplicitMappingInterceptor.access$000 (ExplicitMappingBuilder.java:312) | |
at org.modelmapper.internal.ExplicitMappingBuilder.createAccessorProxies (ExplicitMappingBuilder.java:295) | |
at org.modelmapper.internal.ExplicitMappingBuilder.createProxies (ExplicitMappingBuilder.java:286) | |
at org.modelmapper.internal.ExplicitMappingBuilder.visitPropertyMap (ExplicitMappingBuilder.java:274) | |
at org.modelmapper.PropertyMap.configure (PropertyMap.java:386) | |
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method) | |
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78) | |
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) | |
at java.lang.reflect.Method.invoke (Method.java:567) | |
at org.modelmapper.internal.ExplicitMappingBuilder.build (ExplicitMappingBuilder.java:235) | |
at org.modelmapper.internal.ExplicitMappingBuilder.build (ExplicitMappingBuilder.java:104) | |
at org.modelmapper.internal.TypeMapImpl.addMappings (TypeMapImpl.java:92) | |
at org.modelmapper.internal.TypeMapStore.getOrCreate (TypeMapStore.java:124) | |
at org.modelmapper.ModelMapper.addMappings (ModelMapper.java:113) | |
at com.example.ModelMapperJDK16Test.configure (ModelMapperJDK16Test.java:29) | |
at com.example.ModelMapperJDK16Test.main (ModelMapperJDK16Test.java:40) | |
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254) | |
at java.lang.Thread.run (Thread.java:831) | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] BUILD FAILURE | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] Total time: 1.762 s | |
[INFO] Finished at: 2021-04-19T09:34:09+02:00 | |
[INFO] ------------------------------------------------------------------------ | |
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.0.0:java (default-cli) on project modelmapperjdk16test: An exception occured while executing the Java class. ModelMapper configuration errors: | |
[ERROR] | |
[ERROR] 1) Failed to configure mappings | |
[ERROR] | |
[ERROR] 1 error: Cannot read field "methodProxies" because "x0" is null | |
[ERROR] -> [Help 1] | |
[ERROR] | |
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. | |
[ERROR] Re-run Maven using the -X switch to enable full debug logging. | |
[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/MojoExecutionException |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns="http://maven.apache.org/POM/4.0.0" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.example</groupId> | |
<artifactId>modelmapperjdk16test</artifactId> | |
<version>0.0.1-SNAPSHOT</version> | |
<name>modelmapperjdk16test</name> | |
<description>modelmapperjdk16test</description> | |
<properties> | |
<java.version>16</java.version> | |
<maven.compiler.source>16</maven.compiler.source> | |
<maven.compiler.target>16</maven.compiler.target> | |
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>org.modelmapper</groupId> | |
<artifactId>modelmapper</artifactId> | |
<version>2.4.0</version> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>exec-maven-plugin</artifactId> | |
<version>3.0.0</version> | |
<configuration> | |
<mainClass>com.example.ModelMapperJDK16Test</mainClass> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment