我在 java 中收到此错误消息。
你们有谁知道我该如何解决这个问题?
HTTP Status 500 - Filter execution threw an exception
类型Exception report
信息Filter execution threw an exception
描述The server encountered an internal error that prevented it from fulfilling this request.
例外
javax.servlet.ServletException: Filter execution threw an exception
root cause
java.lang.Error: Unresolved compilation problem:
The method createNamedQuery(String) in the type EntityManager is not applicable for the arguments (String, Class<User>)
bg.tu_sofia.cinema.dao.UserDAOImpl.getAllUsers(UserDAOImpl.java:22)
bg.tu_sofia.cinema.dao.UserDAOImpl.usernameExists(UserDAOImpl.java:52)
bg.tu_sofia.cinema.filters.UserReconcilerFilter.doFilter(UserReconcilerFilter.java:54)
note The full stack trace of the root cause is available in the SAP logs.
用户DOAImpl
package bg.tu_sofia.cinema.dao;
import java.util.List;
import javax.persistence.EntityManager;
import bg.tu_sofia.cinema.entities.Cinema;
import bg.tu_sofia.utils.EntityManagerUtils;
public class CinemaDAOImpl implements CinemaDAO {
private EntityManager em;
private EntityManagerUtils dbUtils;
public CinemaDAOImpl() {
this.dbUtils = EntityManagerUtils.getInstance();
this.em = dbUtils.getEntityManagerInstance();
}
public List<Cinema> getAllCinemas() {
return em.createNamedQuery("AllCinemas", Cinema.class).getResultList();
}
public Cinema getCinemaByID(long id) {
return em.find(Cinema.class, id);
}
public void addCinema(Cinema cinema) {
dbUtils.startTransaction(em);
em.persist(cinema);
dbUtils.commitTransaction(em);
}
public void removeCinema(Cinema cinema) {
//TODO : don't forget when removing a cinema to remove all its related screenings.
dbUtils.startTransaction(em);
em.remove(cinema);
dbUtils.commitTransaction(em);
}
public void removeCinemaByID(long removalID) {
removeCinema(getCinemaByID(removalID));
}
}