0

私はこれらすべてのものに非常に新しいです。GlassFishを介してWebサービスを起動しようとしています。このプロジェクトをビルドしようとすると、エラーが発生します。

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 org.glassfish.apf.AnnotationInfo@3b63118a. 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)

何が問題になっているのかわかりませんが、メッセージによると、MeasurementResurces.javaファイルに含まれている必要があります...

/*
 * 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();
    }
    */
}

誰かが少なくとも何が問題なのかというヒントを持っていますか?

4

1 に答える 1

1

nameおよびを宣言せずにタイプレベルEJBを使用していbeanInterfaceます。

/**
 *
 * @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);
    }

    ...
 }       
于 2013-02-08T21:59:12.610 に答える