title: Why can't I instantiate a managedbean in jpa?
body: <p>I am trying to develop a small web application as training for my upcoming finals and I can't figure out what I'm doing wrong.</p>
  
  <p>These are my *<em>Entities</em>*L <code>Kunde</code> and <code>Konto</code> (many2many-relationship), the auto-created table <code>Kunde_Konto</code> has only the two primary keys of my entities.</p>
  
  <pre><code>@Entity
  @NamedQueries({
      @NamedQuery(name="findKundeById", query="select k from Kunde k where k.svnr = :svnr"),
  })
  public class Kunde implements Serializable {
      private static final long serialVersionUID = 1L;
      @Id
      @Column(precision=4, scale=0)
      private Long svnr;
  
      @ManyToMany
      private List&lt;Konto&gt; konten;
  }
  
  @Entity
  @NamedQueries({
      @NamedQuery(name="findKontoByBesitzer", query="select k from Konto k join k.besitzer b where b.svnr = :svnr")
  })
  public class Konto implements Serializable {
      private static final long serialVersionUID = 1L;
      @Id
      @Column(precision=4, scale=0)
      private Long knr;
  
      @ManyToMany(mappedBy="konten")
      private List&lt;Kunde&gt; besitzer;
  }
  </code></pre>
  
  <p>And this is my <strong>Managed Bean</strong>:</p>
  
  <pre><code>@ManagedBean
  @SessionScoped
  public class KundenKontoList implements Serializable {
      private FacesContext fc = null;
      private HttpServletRequest hsr = null;
      private HttpSession hs = null;
  
      @EJB
      private KontoFacadeLocal kontoFacade;
  
      @EJB
      private KundeFacadeLocal kundeFacade;
  
      private Kunde k;
      private List&lt;Konto&gt; konten;
  
      /**
       * Creates a new instance of KundenKontoList
       */
      public KundenKontoList() {
          fc = FacesContext.getCurrentInstance();
          hsr = (HttpServletRequest) fc.getExternalContext().getRequest();
          hs = hsr.getSession();
  
          k = (Kunde) hs.getAttribute("kunde");
          konten = kontoFacade.findKontoByBesitzer(k);
      }
  }
  </code></pre>
  
  <p>The exception</p>
  
  <pre><code>com.sun.faces.mgbean.ManagedBeanCreationException: Klasse at.pf.controller.KundenKontoList kann nicht instanziiert werden.
  </code></pre>
  
  <p>which translated means that <code>KundenKontoList</code> can't be instatiated, is thrown at the line:</p>
  
  <pre><code>konten = kontoFacade.findKontoByBesitzer(k);
  
  //method in the facade:
  @Override
  public List&lt;Konto&gt; findKontoByBesitzer(Kunde k) {
      Query q = em.createNamedQuery("findKontoByBesitzer");
      q.setParameter("svnr", k.getSvnr());
      return q.getResultList();
  }
  </code></pre>
  
  <p>I think that it has something to do with the <code>kontoFacade</code>, but I don't know what the exact problem is.</p>