2010-02-13 4 views
0

Eclipse에서 작업 중이며 Glassfish와 MySQL을 사용하여 엔터프라이즈 응용 프로그램을 만들고 싶습니다.EJB가 엔터프라이즈 응용 프로그램에서 인식되지 않습니다.

WeatherEJB 및 WeatherWeb이라는 EJB 및 WEB 모듈을 사용하여 엔터프라이즈 응용 프로그램 프로젝트를 만들었습니다.

WeatherEJB 프로젝트에서 JPA를 사용하여 테이블에서 엔티티를 생성했으며 생성 된 엔티티 국가를 랩핑하기 위해 CountryDAOB를 구현하는 StateDAO라는 원격 세션 빈을 만들었습니다.

WeatherWeb 프로젝트에서 Java Build Bath의 WeatherEJB 프로젝트에 대한 참조, 프로젝트 참조 및 모듈 종속성을 추가했습니다.

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; 
    } 
} 

내가 성공적으로 글래스 피시에 응용 프로그램을 배포 할 수 있지만, I를 :

다음, WeatherWeb 프로젝트에서, 나는 다음과 같습니다 CountryController (에서 '요청'범위)라는 관리 빈을 생성 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 

무엇이 누락 되었습니까? 또는 내가 뭘 잘못하고 있니? 대신 구현 클래스의

답변

1

사실 :

@EJB 
CountryDAOBean countryDao; 
:

@EJB 
CountryDAO countryDao; 

나는 인터페이스를 사용해야

관련 문제