title: Java EE 6 java.lang.NoClassDefFoundError glassfish
body: <p>I am new to Java EE 6 and am following the <a href="https://www.youtube.com/watch?v=5x7SZRX8_po" rel="nofollow">Java EE 6 tutorial</a>. I have created a Java EE 6 project with contexts and DI enabled. </p>
  
  <p>I am getting the following error: </p>
  
  <p><b>java.lang.NoClassDefFoundError: Lboundaries/UsersFacade;</b></p>
  
  <p>Environment: Netbeans 7.3, JDK 1.6 and Glassfish3.1.2. Please advise me on resolving the issue.</p>
  
  <p>(a) web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt;
      &lt;context-param&gt;
          &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
          &lt;param-value&gt;Development&lt;/param-value&gt;
      &lt;/context-param&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;session-config&gt;
          &lt;session-timeout&gt;
              30
          &lt;/session-timeout&gt;
      &lt;/session-config&gt;
      &lt;welcome-file-list&gt;
          &lt;welcome-file&gt;faces/index.xhtml&lt;/welcome-file&gt;
      &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>(b) beans.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>(c) Entity Bean from Database, Users (package name : entitites in users-ejb)</p>
  
  <pre><code>    /*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package entities;
  
  import java.io.Serializable;
  import javax.persistence.Basic;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.NamedQueries;
  import javax.persistence.NamedQuery;
  import javax.persistence.Table;
  import javax.validation.constraints.Size;
  import javax.xml.bind.annotation.XmlRootElement;
  
  /**
   *
   * @author abc
   */
  @Entity
  @Table(catalog = "", schema = "USER")
  @XmlRootElement
  @NamedQueries({
      @NamedQuery(name = "Users.findAll", query = "SELECT u FROM Users u"),
      @NamedQuery(name = "Users.findByUserid", query = "SELECT u FROM Users u WHERE u.userid = :userid"),
      @NamedQuery(name = "Users.findByUseridPassword", query = "SELECT u FROM Users u WHERE u.userid = :userid AND u.password=:password"),
      @NamedQuery(name = "Users.findByUsername", query = "SELECT u FROM Users u WHERE u.username = :username"),
      @NamedQuery(name = "Users.findByPassword", query = "SELECT u FROM Users u WHERE u.password = :password"),
      @NamedQuery(name = "Users.findByEnabled", query = "SELECT u FROM Users u WHERE u.enabled = :enabled")})
  public class Users implements Serializable {
      private static final long serialVersionUID = 1L;
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Basic(optional = false)
      @Column(nullable = false)
      private Integer userid;
      @Size(max = 30)
      @Column(length = 30)
      private String username;
      @Size(max = 30)
      @Column(length = 30)
      private String password;
      @Size(max = 1)
      @Column(length = 1)
      private String enabled;
  
      public Users() {
      }
  
      public Users(Integer userid) {
          this.userid = userid;
      }
  
      public Integer getUserid() {
          return userid;
      }
  
      public void setUserid(Integer userid) {
          this.userid = userid;
      }
  
      public String getUsername() {
          return username;
      }
  
      public void setUsername(String username) {
          this.username = username;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String getEnabled() {
          return enabled;
      }
  
      public void setEnabled(String enabled) {
          this.enabled = enabled;
      }
  
      @Override
      public int hashCode() {
          int hash = 0;
          hash += (userid != null ? userid.hashCode() : 0);
          return hash;
      }
  
      @Override
      public boolean equals(Object object) {
          // TODO: Warning - this method won't work in the case the id fields are not set
          if (!(object instanceof Users)) {
              return false;
          }
          Users other = (Users) object;
          if ((this.userid == null &amp;&amp; other.userid != null) || (this.userid != null &amp;&amp; !this.userid.equals(other.userid))) {
              return false;
          }
          return true;
      }
  
      @Override
      public String toString() {
          return "entities.Users[ userid=" + userid + " ]";
      }
  
  }
  </code></pre>
  
  <p>(d) Session Bean for entity bean, UsersFacade (package name : boundaries in users-ejb)
  has method :</p>
  
  <pre><code>/*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package boundaries;
  
  import entities.Users;
  import javax.ejb.Stateless;
  import javax.persistence.EntityManager;
  import javax.persistence.PersistenceContext;
  import javax.persistence.Query;
  
  /**
   *
   * @author abc
   */
  @Stateless
  public class UsersFacade extends AbstractFacade&lt;Users&gt; {
  
      @PersistenceContext(unitName = "sbg-ejbPU")
      private EntityManager em;
  
      @Override
      protected EntityManager getEntityManager() {
          return em;
      }
  
      public UsersFacade() {
          super(Users.class);
      }
  
      public Users validUser(String username, String password) {
          Query query = getEntityManager().createNamedQuery("Users.findByUseridPassword").setParameter("username", username).setParameter("password", password);
          Users user = (Users) query.getSingleResult();
          return user;
      }
  }
  </code></pre>
  
  <p>(e) created JSF Managed Bean, LoginBean (package name : com.users in users-war)</p>
  
  <pre><code>/*
   * To change this template, choose Tools | Templates
   * and open the template in the editor.
   */
  package com.xyz;
  
  import boundaries.UsersFacade;
  import entities.Users;
  import javax.ejb.EJB;
  import javax.inject.Named;
  import javax.enterprise.context.RequestScoped;
  
  /**
   *
   * @author abc
   */
  @Named(value = "loginBean")
  @RequestScoped
  public class LoginBean {
  
      @EJB
      private UsersFacade usersFacade;
      private Users currentUser;
  
      /**
       * Creates a new instance of LoginBean
       */
      public LoginBean() {
      }
  
  
      /**
       * @param currentUser the currentUser to set
       */
      public void setCurrentUser(Users currentUser) {
          this.currentUser = currentUser;
      }
  
      /**
       * @return the currentUser
       */
      public Users getCurrentUser() {
          if(currentUser==null){
              currentUser= new Users();
          }
          return currentUser;
      }
  
      public String validUser(){
          String outcome="index?faces-redirect=true";
          Users user=usersFacade.validUser(getCurrentUser().getUsername(), getCurrentUser().getPassword());
          if(user!=null){
              outcome="/view/home?faces-redirect=true";
          }else{
              System.out.println("Unable to find User with User Id:"+getCurrentUser().getUsername()+"!");
          }
          return outcome;
      }
  }
  </code></pre>