maven-jaxb2-plugin: java.lang.NoSuchFieldError: encoding

This is the TLDR; version of this bug, so if the following solution doesn’t work for you, you might want to read it all.

When upgrading to a new version of Maven you might be faced with the following exception

[ERROR] Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate (schema-generate) on project WSModel: 
Execution schema-generate of goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate failed: 
An API incompatibility was encountered while executing org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.1:generate: 
java.lang.NoSuchFieldError: encoding


The problem is caused by a more recent version of com.sun.xml.bind:jabx-xjc being used when running the maven-jaxb2-plugin. It can be easily solved by excluding it from your plugin dependencies:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s