无法创建无状态EJB

时间:2014-06-01 12:14:59

标签: eclipse jpa glassfish ejb managed-bean

我创建了一个包含EJB和JPA项目的动态Web项目。发布项目没有问题,但是当我调用EJB时​​,我得到“无法创建无状态EJB”错误。这是我的dao和ejb;

KitaplarDAO.java

@Stateless
@LocalBean
public class KitaplarDAO extends GenericDAO<Kitaplar> implements Serializable{

private static final long serialVersionUID = 1L;

public KitaplarDAO(Class<Kitaplar> entityClass) {
    super(entityClass);
}

@Override
public List<Kitaplar> findAll(String query) {
    return super.findAll("tumkitaplarigetir");
}

}

KitaplarFacadeImpl.java

@Stateless
public class KitaplarFacadeImpl implements KitaplarFacade,Serializable {


private static final long serialVersionUID = 1L;
@EJB
KitaplarDAO kitapDao;

@Override
public void save(Kitaplar kitaplar) {
    kitapDao.save(kitaplar);

}

@Override
public void update(Kitaplar kitaplar) {
    kitapDao.update(kitaplar);

}

@Override
public List<Kitaplar> findAll(String sorgu) {
    return kitapDao.findAll(sorgu);
}

KitaplarFacade.java

@Local
public interface KitaplarFacade {

public abstract void save(Kitaplar kitaplar);

public abstract void update(Kitaplar kitaplar);

public abstract void delete(Kitaplar kitaplar);

public abstract List<Kitaplar> findAll(String sorgu);

}

这是我使用Facade服务的ManagedBean;

@ManagedBean(name = "kitaplariGetir")
@ViewScoped
public class KitaplariGetir implements Serializable {

private static final long serialVersionUID = 1L;

private List<Kitaplar> kitaplar = new ArrayList<Kitaplar>();

@EJB
KitaplarFacade service;

@PostConstruct
public void initialize() {
    initList();
}

private void initList() {
    try {
        kitaplar = service.findAll("tumkitaplarigetir");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

public List<Kitaplar> getKitaplar() {
    return kitaplar;
}

public void setKitaplar(List<Kitaplar> kitaplar) {
    this.kitaplar = kitaplar;
}

}

这是stacktrace;

  Caused by: javax.ejb.CreateException: Could not create stateless EJB

SEVERE:at com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:534) 严重:在com.sun.ejb.containers.StatelessSessionContainer.access $ 000(StatelessSessionContainer.java:95) 严重:在com.sun.ejb.containers.StatelessSessionContainer $ SessionContextFactory.create(StatelessSessionContainer.java:724) 严重:......还有102个 严重:引起:java.lang.InstantiationException:com.mesutemre.businesDAOs.KitaplarDAO 严重:在java.lang.Class.newInstance0(Class.java:357) 严重:在java.lang.Class.newInstance(Class.java:325) 严重:在com.sun.ejb.containers.BaseContainer._constructEJBInstance(BaseContainer.java:1663) 严重:在com.sun.ejb.containers.BaseContainer.createEjbInstanceAndContext(BaseContainer.java:1646) 严重:在com.sun.ejb.containers.StatelessSessionContainer.createStatelessEJB(StatelessSessionContainer.java:475)

我的代码有问题吗?那么如何解决这个问题呢。

0 个答案:

没有答案