title: Marshal DefaultListModel into xml
body: <p>I've looked at a few posts on this topic, but none of the solutions have worked for me.  I have a <code>DefaultListModel</code> called <code>partsListRight</code> that is a member of my window class, and I have an inner class called configuration that contains an <code>ArrayList</code> which I want to populate with the items in <code>partsListRight</code>:</p>
  
  <pre><code>@XmlRootElement
  class Configuration{
      @XmlElement
      private ArrayList&lt;String&gt; Component;
  
  
      public Configuration(){
          Component = new ArrayList&lt;String&gt;();
          Object[] partsList = partsListRight.toArray();
          for (Object object : partsList){
              Component.add((String)object);
          }
      }
  }
  </code></pre>
  
  <p>In my window class I have a <code>save()</code> method that does the marshalling for the <code>ArrayList</code> Component:</p>
  
  <pre><code>public void save() {
  
  
      Configuration configuration = new Configuration();
  
      try{
      File file = new File("C:\\configuration.xml");
      JAXBContext jaxbContext = JAXBContext.newInstance(Configuration.class);
      Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
  
      jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
  
      jaxbMarshaller.marshal(configuration, file);
      jaxbMarshaller.marshal(configuration, System.out);
      } catch(JAXBException e){
          e.printStackTrace();
      }       
  }
  </code></pre>
  
  <p>However when I try to run this method I get the error that Configuration is a non-static inner class, and JAXB can't handle those.  I'm not sure how to get around this.  Would greatly appreciate any help!</p>