【发布时间】:2016-03-29 23:08:59
【问题描述】:
我正在调整我的应用程序以在 Websphere 8.5.5 中工作,我发现我的应用程序没有注入 EJB,但 Jboss 7.1.1 中的同一个应用程序工作正常。
之后,我创建了一个虚拟应用程序,但它不起作用(仅添加 2 个整数)。
有人可以帮我吗?
已编辑:
package resources;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import co.com.prueba.local.SumadorLocal;
@ManagedBean
@ViewScoped
public class SumadorUI {
private Integer a;
private Integer b;
private Integer c;
@EJB
private SumadorLocal sumadorLocal;
@PostConstruct
private void init(){
System.out.println("Init :"+sumadorLocal);
}
public String sumar(){
c=sumadorLocal.sumador(a, b);
return null;
}
public Integer getA() {
return a;
}
public void setA(Integer a) {
this.a = a;
}
public Integer getB() {
return b;
}
public void setB(Integer b) {
this.b = b;
}
public Integer getC() {
return c;
}
public void setC(Integer c) {
this.c = c;
}
}
更新:
我添加新的 EJB 来测试问题注入是在 ManagedBean 中还是在所有应用程序中,并且只有问题是 ManagedBean。
【问题讨论】:
-
您需要发布一些代码和更具体的观察结果。
-
仅根据您的标签,我将假设您使用的是 JSF。仅提供的 JSF 实现是 integrated with CDI,因此如果您使用自定义 JSF 库,这可能是原因。提供代码片段和更多描述。如果您使用的是
@Inject,请尝试使用@EJB -
你是如何创建 SumadorUI 的实例的?
-
这个实例是由Application Server创建的,这是一个托管bean。
标签: jsf-2 ejb-3.0 websphere-8