在不同应用程序中从jsf对远程EJB3 bean的第二次调用-未设置委托 [英] Second Call to remote EJB3 bean from jsf in different application - Delegate not set

查看:91
本文介绍了在不同应用程序中从jsf对远程EJB3 bean的第二次调用-未设置委托的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm getting a strange exception the SECOND time my remote ejb is called from my JSF Managed Bean. The first time the bean is called, the results are returned to the screen. However if I then click an action that calls the ejb for a second time, then I get the following Exception:

 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)

有人知道这是为什么吗,我需要做些什么来解决这个问题?

Does anyone know why this is and what I need to do to get around it?

EJB和jsf位于单独的Web应用程序中。 ejb接口和jta实体位于每个应用程序内的jar文件中。就像我之前说过的,第一次检索到国家列表的调用成功返回,但是第二次获得一个国家的啤酒的调用返回了以下异常:

The EJB and jsf are in separate web applications. The ejb interfaces and the jta entities are in a jar file that is within each application. As I said previously, the first call to retrieve the list of countries returns successfully, but a second call to get the beers for a country returns the follwing exception:

这里是我的托管Bean。

Here is my managed 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接口

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代理/存根进行了不正确的反序列化。

I believe this was fixed by PM61337, which fixed a variety of issues related to deserialization of JSF state. The exception from the APAR shows a local EJB proxy being serialized incorrectly, whereas your problem is improper deserialization of a remote EJB proxy/stub.

这篇关于在不同应用程序中从jsf对远程EJB3 bean的第二次调用-未设置委托的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆