JavaEE6 + Glassfish3.1.2.2 + EJB3.1的问题

时间:2016-02-23 12:09:39

标签: java rest glassfish ejb

我收到错误:

  

javax.ejb.EJBException:javax.ejb.EJBException:   javax.ejb.CreateException:无法创建无状态EJB

在我的应用中,我有以下代码:

@Path("/nodos")
@Stateless
public class NodosRestController extends NodosControllerRestController{
@Context
protected HttpServletRequest request;

@Inject
Log log;

@EJB(beanName = "NodoManager")
private NodoManager nm;

@EJB(name="TareaDescargaEventos")
private TareaDescargaEventos tde;

@EJB(beanName="TareaTransferenciaHuellas")
private TareaTransferenciaHuellas tareaTransferenciaHuellas;

@Resource
UserTransaction transaccion;

public NodosRestController() {
}

@GET
@GsonDevRootName("nodo")
@Produces(MediaType.APPLICATION_JSON)
public List<Nodo> getAllNodos() throws Throwable {
    return nm.findAllNodos();
}
@PUT
@GsonDevRootName("nodo")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Nodo updateNodo(Nodo nodo) throws Throwable {
    transaccion.begin();
    nodo = nm.updateNodo(nodo);
    transaccion.commit();
    return nodo;
}
}

当我不使用&#39;延伸&#39;程序工作,但当我使用它时程序失败

NodosControllerRestController课在这里:

public abstract class NodosControllerRestController {
@Context
protected UriInfo context;
@Context
protected HttpServletRequest request;
@Context
protected HttpServletResponse response;

//more code
}

1 个答案:

答案 0 :(得分:0)

您所显示的代码可能会出错,可能有多种原因。原因可能是在Glassfish注入字段或方法依赖期间遇到冲突异常。只需检查NodosControllerRestController是否存在任何不一致之处。进一步分析您的异常堆栈跟踪也会有所帮助。