0
我正在使用Eclipse,我想使用Glassfish和MySQL創建企業應用程序。EJB在企業應用程序中未被識別
我創建了一個名爲WeatherEJB和WeatherWeb的EJB和WEB模塊的企業應用程序項目。
在WeatherEJB項目中,我使用JPA生成實體表,使用JPA創建一個無狀態的遠程會話bean,名爲CountryDAO,實現CountryDAOBean,以便覆蓋生成的實體Country。
在WeatherWeb項目中,我添加了對Java Build浴中的WeatherEJB項目的引用,項目引用和模塊依賴項。
然後,在WeatherWeb項目中,我創建了一個名爲CountryController(在「請求」範圍)託管bean,它看起來像這樣:
import javax.ejb.EJB;
import model.Country;
import service.CountryDAO;
public class CountryController
{
@EJB
CountryDAO countryDao;
private Country country;
public CountryController()
{
country = new Country();
}
public String saveCountry()
{
String returnValue = "success";
try
{
countryDao.saveCountry(country);
}
catch (Exception e){
e.printStackTrace();
returnValue = "failure";
}
return returnValue;
}
public Country getCountry(){
return country;
}
public void setCountry(Country country){
this.country = country;
}
}
雖然我可以成功部署在Glassfish應用程序,當我嘗試訪問使用CountryController的jsf,我得到以下錯誤:
type Exception report
message
descriptionThe server encountered an internal error() that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: javax.faces.FacesException: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref managedBeans.CountryController/[email protected]: [email protected]@[email protected]@null into class managedBeans.CountryController
root cause
javax.faces.FacesException: javax.faces.FacesException: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref managedBeans.CountryController/[email protected]: [email protected]@[email protected]@null into class managedBeans.CountryController
root cause
javax.faces.FacesException: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref managedBeans.CountryController/[email protected]: [email protected]@[email protected]@null into class managedBeans.CountryController
root cause
com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref managedBeans.CountryController/[email protected]: [email protected]@[email protected]@null into class managedBeans.CountryController
root cause
javax.naming.NameNotFoundException: service.CountryDAO#service.CountryDAO not found
我在想什麼?或者我做錯了什麼?