Класс сущности не найден
Я новичок в Java EJB, я получаю эту ошибку. Я думаю, что в отношении класса сущностей. Может кто-нибудь помочь мне решить эту проблему, большое спасибо.
Warning: StandardWrapperValve[registrationsServlet]: Servlet.service() for servlet registrationsServlet threw exception
java.lang.NoClassDefFoundError: Entity/Userdetailcb006116
at com.themePark.servlets.registrationsServlet.processRequest(registrationsServlet.java:66)
at com.themePark.servlets.registrationsServlet.doGet(registrationsServlet.java:88)
... more
вот мои коды сервлетов, для меня это выглядит нормально, но компилятор не определяет Userdetailcb006116
как класс сущности. Есть ли способ сделать объект из этого или?
import Entity.Userdetailcb006116;
import Sessions.Userdetailcb006116FacadeLocal;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.ejb.EJB;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class registrationsServlet extends HttpServlet {
@EJB
private Userdetailcb006116FacadeLocal userdetailcb006116Facade;
protected void processRequest(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = resp.getWriter()) {
String fname = req.getParameter("fName");
String lname = req.getParameter("lName");
// here im getting error, although this entity class, compiler doesnt recognize as this a entity class i think
Userdetailcb006116 us = new Userdetailcb006116(fname, lname);
userdetailcb006116Facade.create(us);
RequestDispatcher rd = req.getRequestDispatcher("index.jsp");
rd.forward(req, resp);
}
}
Код класса сущности:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Entity;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
/**
*
* @author H4k3r
*/
@Entity
@Table(name = "USERDETAILSCB006116")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Userdetailscb006116.findAll", query = "SELECT u FROM Userdetailscb006116 u"),
@NamedQuery(name = "Userdetailscb006116.findByFname", query = "SELECT u FROM Userdetailscb006116 u WHERE u.fname = :fname"),
@NamedQuery(name = "Userdetailscb006116.findByLname", query = "SELECT u FROM Userdetailscb006116 u WHERE u.lname = :lname")})
public class Userdetailscb006116 implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 100)
@Column(name = "FNAME")
private String fname;
@Size(max = 100)
@Column(name = "LNAME")
private String lname;
public Userdetailscb006116() {
}
public Userdetailscb006116(String fname) {
this.fname = fname;
}
public String getFname() {
return fname;
}
public void setFname(String fname) {
this.fname = fname;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
@Override
public int hashCode() {
int hash = 0;
hash += (fname != null ? fname.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 Userdetailscb006116)) {
return false;
}
Userdetailscb006116 other = (Userdetailscb006116) object;
if ((this.fname == null && other.fname != null) || (this.fname != null && !this.fname.equals(other.fname))) {
return false;
}
return true;
}
@Override
public String toString() {
return "Entity.Userdetailscb006116[ fname=" + fname + " ]";
}
}
код фасада:
import Entity.Userdetailscb006116;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
/**
*
* @author H4k3r
*/
@Stateless
public class Userdetailscb006116Facade extends AbstractFacade<Userdetailscb006116> implements Userdetailscb006116FacadeLocal {
@PersistenceContext(unitName = "cb006116_ThemePark-ejbPU")
private EntityManager em;
@Override
protected EntityManager getEntityManager() {
return em;
}
public Userdetailscb006116Facade() {
super(Userdetailscb006116.class);
}
}