title: How to generate XSDs from java beans having java.time.LocalDate?
body: <p>I'm trying to use <code>jaxb2-maven-plugin</code> to generate <code>xsd</code> from java beans.</p>
  
  <p>But I constantly get the following error:</p>
  
  <pre><code>java.time.LocalDate is a non-static inner class, and JAXB can't handle those.
      this problem is related to the following location:
          at java.time.LocalDate (Unknown Source)
  </code></pre>
  
  <p>The bean is like:</p>
  
  <pre><code>public class MyBean {
      private LocalDate date;
  }
  </code></pre>
  
  <p>I therefore created a <code>jaxb</code> mapping file and an adapter converting between <code>java.time.LocalDate</code> and <code>xs:date</code>. But the error just remains the same.</p>
  
  <pre><code> public class LocalDateAdapter {
      private static DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyyMMdd");
  
      public static LocalDate unmarshal(String v) throws Exception {
          return fmt.parseLocalDate(v);
      }
  
      public static String marshal(LocalDate v) throws Exception {
          return v.toString("yyyyMMdd");
      }
   }
  </code></pre>
  
  <p>src/main/resources/xsdbindings.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;bindings xmlns="http://java.sun.com/xml/ns/jaxb"
            xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
            xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
            xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
            version="2.1"&gt;
      &lt;globalBindings&gt;
          &lt;javaType name="java.time.LocalDate" xmlType="xs:date"
                    parseMethod="my.path.LocalDateAdapter.unmarshal"
                    printMethod="my.path.LocalDateAdapter.marshal"
          /&gt;
      &lt;/globalBindings&gt;
  &lt;/bindings&gt;
  </code></pre>
  
  <p>maven pom.xml</p>
  
  <pre><code>...
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;jaxb2-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;2.3.1&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;schemagen&lt;/id&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;schemagen&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
  
                  &lt;configuration&gt;
                      &lt;bindingFiles&gt;xsdbindings.jaxb&lt;/bindingFiles&gt;
                      &lt;verbose&gt;true&lt;/verbose&gt;
                  &lt;/configuration&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>