java - 第二次从不同应用程序中的 jsf 调用远程 EJB3 bean - 未设置委托(delegate)

标签 java primefaces ejb-3.1 websphere-8

第二次从 JSF Managed Bean 调用远程 ejb 时,我遇到了一个奇怪的异常。第一次调用该 bean 时,结果将返回到屏幕。但是,如果我随后单击第二次调用 ejb 的操作,则会出现以下异常:

 SystemErr     R java.rmi.RemoteException: CORBA BAD_OPERATION 0x0 No; nested exception is: 
    org.omg.CORBA.BAD_OPERATION: The delegate has not been set!  vmcid: 0x0  minor code: 0  completed: No
[10/06/13 09:35:26:341 BST] 00000041 SystemErr     R    at com.ibm.CORBA.iiop.UtilDelegateImpl.mapSystemException(UtilDelegateImpl.java:330)
[10/06/13 09:35:26:341 BST] 00000041 SystemErr     R    at javax.rmi.CORBA.Util.mapSystemException(Util.java:84)
[10/06/13 09:35:26:341 BST] 00000041 SystemErr     R    at com.ibm.CORBA.iiop.UtilDelegateImpl.isLocal(UtilDelegateImpl.java:739)
[10/06/13 09:35:26:341 BST] 00000041 SystemErr     R    at javax.rmi.CORBA.Util.isLocal(Util.java:281)
[10/06/13 09:35:26:341 BST] 00000041 SystemErr     R    at com.ejb.view._BelgianBeerSessionBeanRemote_Stub.getAllBeveragesForCountry(_BelgianBeerSessionBeanRemote_Stub.java)
[10/06/13 09:35:26:341 BST] 00000041 SystemErr     R    at com.web.BeerStorePageBean.getBeersForCountry(BeerStorePageBean.java:64)

有谁知道这是为什么以及我需要做什么来解决它?

EJB 和 jsf 位于不同的 Web 应用程序中。 ejb 接口(interface)和 jta 实体位于每个应用程序内的 jar 文件中。正如我之前所说,检索国家/地区列表的第一次调用成功返回,但获取某个国家/地区的啤酒的第二次调用返回以下异常:

这是我的托管 Bean。

@ManagedBean
@ViewScoped
public class BeerStorePageBean implements Serializable {

    private static final long serialVersionUID = -303245258622324227L;
    @EJB(lookup = "java:global/BelgianBeersEarProject/BelgianBeersEJBProject/BelgianBeerSessionBean!com.ejb.view.BelgianBeerSessionBeanRemote")
    private BelgianBeerSessionBeanRemote store;
    private List<Beverage> beverages = null;

    public List<Beverage> getBeverages() {
        return beverages;
    }

    public void setBeverages(List<Beverage> beverages) {
        this.beverages = beverages;
    }

    public BelgianBeerSessionBeanRemote getStore() {
        return store;
    }

    public void setStore(BelgianBeerSessionBeanRemote store) {
        this.store = store;
    }

    private List<Country> countries = null;

    @PostConstruct
    public void populateCountries() {
        countries = store.getAllCountries();

    }

    public List<Country> getAllCountries() {

        return countries;
    }

    public void getBeersForCountry(Country c) {

        try {
            setBeverages(getStore().getAllBeveragesForCountry(c.getId()));
        } catch (Exception e) {
            e.printStackTrace();
            FacesContext.getCurrentInstance().addMessage(
                    null,
                    new FacesMessage("There was an error getting the beers: "
                            + e.getMessage()));
        }

    }



}

这是我的 EJB:

@Stateless
public class BelgianBeerSessionBean implements BelgianBeerSessionBeanRemote,
        BelgianBeerSessionBeanLocal {

    private static final long serialVersionUID = 7878013037900683879L;
    @PersistenceContext(unitName = "BeerJPAProject")
    private EntityManager em;

    public BelgianBeerSessionBean() {
        // TODO Auto-generated constructor stub
    }

    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public List<Country> getAllCountries() {

        TypedQuery<Country> q = em.createNamedQuery("getCountries",
                Country.class);
        return q.getResultList();
    }

    @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void saveCountries(List<Country> countries) {
        for (Country c : countries) {
            em.persist(c);
        }

    }

    @Override
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public List<Beverage> getAllBeveragesForCountry(int countryId) {
        TypedQuery<Beverage> q = em.createNamedQuery("getBeveragesByCountry",
                Beverage.class);
        q.setParameter("countryId", countryId);
        return q.getResultList();
    }
}

这里是ejb接口(interface)

public interface BelgianBeerSessionInterface extends Serializable {
    List<Country> getAllCountries();

    void saveCountries(List<Country> countries);

    List<Beverage> getAllBeveragesForCountry(int countryId);
}


@Remote
public interface BelgianBeerSessionBeanRemote extends
        BelgianBeerSessionInterface, Serializable{

}

@Local
public interface BelgianBeerSessionBeanLocal extends
        BelgianBeerSessionInterface {

}

最佳答案

我相信此问题已由 PM61337 修复,修复了与 JSF 状态反序列化相关的各种问题。 APAR 的异常显示本地 EJB 代理序列化不正确,而您的问题是远程 EJB 代理/ stub 的反序列化不正确。

关于java - 第二次从不同应用程序中的 jsf 调用远程 EJB3 bean - 未设置委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17020019/

相关文章:

java - 如何创建复杂查询的请求? @Query jpql spring jpa

java - 使用 PrimePush 时出现 NullPointerException

java - 查找 EJB 组件的正确方法是什么?

java - 在 javascript 中使用 java 对象时出现 IllegalAccessException

Java 字符串 - UTF 和字节表示

jsf-2 - 为什么? - 完成方法 ="#{testBean.itemList}": Method not found

jsf - 如何重置 p :dataList/p:dataTable on every page? 的行索引

java - @EJB 返回 null

java - 为什么这个参数在我的 Bean 中作为 Null 发送?

java - 将 PDF 附加到电子邮件