2013-02-08 2 views
0

임이 모든 것들에 아주 새롭습니다. GlassFish를 통해 웹 서비스를 시작하려고합니다. 이 프로젝트를 빌드하려고하면 오류가 발생합니다. 나는 그것이 파일 MeasurementResurces.java에 있어야하는 메시지에 잘못되어 가고 있지만 따라 어떤 단서를 가지고 있겠지GlassFish 예외

ant -f /home/philipp/NetBeansProjects/sks3 -DforceRedeploy=false -Ddirectory.deployment.supported=true -Dnb.wait.for.caches=true run 
init: 
deps-module-jar: 
deps-ear-jar: 
deps-jar: 
check-rest-config-props: 
generate-rest-config: 
library-inclusion-in-archive: 
library-inclusion-in-manifest: 
compile: 
compile-jsps: 
In-place deployment at /home/philipp/NetBeansProjects/sks3/build/web 
Initializing... 
deploy?DEFAULT=/home/philipp/NetBeansProjects/sks3/build/web&name=sks3&contextroot=/sks3&force=true failed on GlassFish Server 3.1.2 
Error occurred during deployment: Exception while deploying the app [sks3] : Invalid TYPE-level @EJB with name() = [] and beanInterface = [class java.lang.Object] in class Webservice.MeasurementResources. Each TYPE-level @EJB must specify both name() and beanInterface().at [email protected] Please see server.log for more details. 
/home/philipp/NetBeansProjects/sks3/nbproject/build-impl.xml:1028: The module has not been deployed. 
See the server log for details. 
BUILD FAILED (total time: 6 seconds) 

...

/* 
* To change this template, choose Tools | Templates 
* and open the template in the editor. 
*/ 
package Webservice; 

import Exception.DALException; 
import dal.MeasurementDao; 
import javax.ejb.EJB; 
import javax.ejb.Stateless; 
import javax.inject.Inject; 
import javax.inject.Named; 
import javax.ws.rs.Path; 
import repo.Measurement; 

/** 
* 
* @author philipp 
*/ 
//@Stateless 
//@inject 
@EJB 
//@LocalBean 
@Named 
@Path("Measurement") 
public class MeasurementResources { 
    @Inject 
    MeasurementDao mDao; 
    public void add(Measurement arg) throws DALException{ 
     mDao.save(arg); 
    } 
/* public void getAll(Measurement arg) throws DALException{ 
     mDao.getAll(); 
    } 
    */ 
} 

누군가가 문제를 적어도 힌트 무슨 일이있다 ?

+0

가 서버 로그 봤어? – Preston

답변

1

namebeanInterface을 선언하지 않고 유형 수준 EJB를 사용 중입니다.

/** 
* 
* @author philipp 
*/ 
//@Stateless 
//@inject 
@EJB(name="MyEjb", beanInterface=RemoteEjb.class) 
//@LocalBean 
@Named 
@Path("Measurement") 
public class MeasurementResources { 
    @Inject 
    MeasurementDao mDao; 
    public void add(Measurement arg) throws DALException{ 
     mDao.save(arg); 
    } 
} 

@Remote 
public interface RemoteEjb { 
    public void doSomething(); 
} 

@Stateless 
public class MyEjb implements RemoteEjb { 
    ... 
} 

name은 삽입하려는 EJB의 이름입니다. beanInterface은 로컬 또는 원격 인터페이스입니다. 진짜 주사는 아니에요. 주석을 배치 설명자 ejb-ref 요소의 대체물로 사용하는 방법입니다. ejb를 삽입하려면 JNDI 조회를 사용해야합니다.

나는 당신이 일을하려고하지만, EJB를 주입하는 일반적인 방법은 다음과 같다 무엇 모르는 : 그것은 알 수 있듯이

@Named 
@Path("Measurement") 
public class MeasurementResources { 
    @EJB 
    private MyEjb myejb; 

    @Inject 
    MeasurementDao mDao; 
    public void add(Measurement arg) throws DALException{ 
     mDao.save(arg); 
    } 

    ... 
}  
관련 문제