2009-07-17 4 views
0

글래스 피쉬에 배치 된 EAR로 압축 된 간단한 웹 애플리케이션이 있습니다. EAR에는 웹 모듈과 EJB 모듈이 있습니다. 웹 모듈에는 얼굴 페이지와 ManagedBean이 있습니다. 얼굴 페이지에는 버튼 만 있고, 버튼은 ManagedBean의 메소드에 묶여 있으며 버튼을 클릭하면 실제로 메소드가 실행됩니다.Faces BackingBean에서 EJB3 호출하기

관리 Bean : 내가 오류가

public class Bar { 

    public Bar() { 
    } 

    @EJB StudentProfileFacade f; 

    public void hello(ActionEvent evt) { 
     System.out.println("*** f: " + f); 
    } 
} 

EJB를 주입 가져 오지입니다

: 나는 웹 모듈이 EJB를 찾을 수 있도록 할 필요가 무엇

Exception attempting to inject Unresolved Ejb-Ref com.web.Bar/[email protected]: [email protected]@[email protected]@null into class com.web.Bar 

모듈 및 EJB가 포함되어 있습니까?

+0

EJB에 전역 JNDI 이름이 할당 되었습니까? –

답변

0

di 대신 jndi 검색을 시도하십시오.

private StudentProfileFacadeInt getStudentProfileFacade() { 
try { 
    InitialContext ctx = new InitialContext(); 
    return (StudentProfileFacadeInt) ctx.lookup("<application_name>/StudentProfileFacade/local"); 
} catch (Exception e) { 
    e.printStackTrace(); 
    throw new RuntimeException("couldn't lookup StudentProfileFacade", e); 
} 
} 

경우 StudentProfileFacadeIntStudentProfileFacade에 대한 로컬 interfejs이다 : 그것은처럼 보일 수 있습니다.