Second Call to remote EJB3 bean from jsf in different application - Delegate not set

≯℡__Kan透↙ 提交于 2019-12-11 07:19:50

问题


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?

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:

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

    }



}

Here is my 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();
    }
}

Here are the ejb interfaces

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 {

}

回答1:


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.



来源:https://stackoverflow.com/questions/17020019/second-call-to-remote-ejb3-bean-from-jsf-in-different-application-delegate-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!