title: JAXB2 cannot generate classes for XSD due to '[..]ToStringStrategy cannot be converted to [..]ToStringStrategy2'
body: <p>I've found an issue with toString generation when using maven-jaxb2-plugin with org.jvnet.jaxb2_commons.jaxb2-basics at version 0.12.0. Instead of generating JAXBToStringStrategy.INSTANCE2, it uses INSTANCE which is incompatible with ToStringStrategy2 as seen below:</p>
  
  <pre><code>public String toString() {
      final ToStringStrategy2 strategy = JAXBToStringStrategy.INSTANCE;
      final StringBuilder buffer = new StringBuilder();
      append(null, buffer, strategy);
      return buffer.toString();
  }
  </code></pre>
  
  <p>Because of this, the maven build fails on compilation with example error below:</p>
  
  <pre><code>[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project test: Compilation failure
  [ERROR] /D:/test/jaxb2/target/generated-sources/xjc/xsd/file/File.java:[73,64] incompatible types: org.jvnet.jaxb2_commons.lang.ToStringStrategy cannot be converted to org.jvnet.jaxb2_commons.lang.ToStringStrategy2
  </code></pre>
  
  <p>For some reason, when I use same configuration with org.jvnet.jax-ws-commons.jaxws-maven-plugin to generate classes from WSDL, the correct INSTANCE2 is used. I also tried to explicitly give which class to use via:</p>
  
  <pre><code>-XtoString-toStringBuilder=org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy
  </code></pre>
  
  <p>or</p>
  
  <pre><code>-XtoString-toStringStrategyClass=org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy
  </code></pre>
  
  <p>but nothing changed. Anyone had similar issue? Example below:</p>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.jvnet.jaxb2_commons&lt;/groupId&gt;
          &lt;artifactId&gt;jaxb2-basics-runtime&lt;/artifactId&gt;
          &lt;version&gt;0.12.0&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.jvnet.jaxb2.maven2&lt;/groupId&gt;
              &lt;artifactId&gt;maven-jaxb2-plugin&lt;/artifactId&gt;
              &lt;version&gt;0.14.0&lt;/version&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;generate-raml&lt;/id&gt;
                      &lt;phase&gt;generate-sources&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;generate&lt;/goal&gt;
                      &lt;/goals&gt;
                      &lt;configuration&gt;
                          &lt;schemaDirectory&gt;./&lt;/schemaDirectory&gt;
                          &lt;extension&gt;true&lt;/extension&gt;
                          &lt;args&gt;
                              &lt;arg&gt;-XtoString&lt;/arg&gt;
                          &lt;/args&gt;
                      &lt;/configuration&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
              &lt;dependencies&gt;
                  &lt;dependency&gt;
                      &lt;groupId&gt;org.jvnet.jaxb2_commons&lt;/groupId&gt;
                      &lt;artifactId&gt;jaxb2-basics&lt;/artifactId&gt;
                      &lt;version&gt;0.12.0&lt;/version&gt;
                  &lt;/dependency&gt;
              &lt;/dependencies&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>XSD [should be placed next to pom]:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsd:schema 
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:file="file.xsd"
    targetNamespace="file.xsd"
      elementFormDefault="qualified"&gt;
    &lt;xsd:element name="file"&gt;
      &lt;xsd:complexType&gt;
        &lt;xsd:attribute name="id" type="xsd:string" use="optional"/&gt;
      &lt;/xsd:complexType&gt;
    &lt;/xsd:element&gt;
  &lt;/xsd:schema&gt;
  </code></pre>