title: java.lang.NoClassDefFoundError JPA example
body: <p>So I'm trying to work through some JPA things and I'm getting this error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: org.apache.commons.collections.set.MapBackedSet
  Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.set.MapBackedSet
  </code></pre>
  
  <p>I've largely taken this code from online to get a project working first, so then I can play around with it and understand the workings. From doing some research, I think part of the problem is I'm missing the com.ibm.ws.jpa.thinclient.jar file. However I don't know where I can find that.</p>
  
  <p>My persistance.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"&gt;
    &lt;persistence-unit name="user" transaction-type="RESOURCE_LOCAL"&gt;
      &lt;class&gt;jpa.Main&lt;/class&gt;
      &lt;properties&gt;
        &lt;property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" /&gt;
        &lt;property name="javax.persistence.jdbc.url"
          value=****Derby URL**** /&gt;
        &lt;property name="javax.persistence.jdbc.user" value="test" /&gt;
        &lt;property name="javax.persistence.jdbc.password" value="test" /&gt;
      &lt;/properties&gt;
  
    &lt;/persistence-unit&gt;
  &lt;/persistence&gt; 
  </code></pre>
  
  <p>My User.Java</p>
  
  <pre><code>package jpa;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  
      @Entity
      public class User {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private int userID;
      private String login;
      private String password;
      public int getUserID() {
          return userID;
      }
      public void setUserID(int userID) {
          this.userID = userID;
      }
      public String getLogin() {
          return login;
      }
      public void setLogin(String login) {
          this.login = login;
      }
      public String getPassword() {
          return password;
      }
      public void setPassword(String password) {
          this.password = password;
      }
  
      @Override public String toString() {
              return "Todo [summary=" + login + ", description=" + password + "]";
  
      }
      }
  </code></pre>
  
  <p>My main.java</p>
  
  <pre><code>package jpa;
  
  import java.util.List;
  import javax.persistence.EntityManager;
  import javax.persistence.EntityManagerFactory;
  import javax.persistence.Persistence;
  import javax.persistence.Query;
  
  public class Main {
  
            private static final String PERSISTENCE_UNIT_NAME = "user";
            private static EntityManagerFactory factory;
            public static void main(String[] args) {
              factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
              EntityManager em = factory.createEntityManager();
              // Read the existing entries and write to console
              Query q = em.createQuery("select u from User u");
              List&lt;User&gt; userList = q.getResultList();
              for (User user : userList) {
                System.out.println(user);
              }
              System.out.println("Size: " + userList.size());
              em.getTransaction().begin();
              User user = new User();
              user.setUserID(12);
              user.setPassword("This is a test");
              em.persist(user);
              em.getTransaction().commit();
              em.close();
            }
          } 
  </code></pre>