Я получаю странное исключение, в то время, как мой удаленный ejb вызывается из моего управляемого JSF Bean. При первом вызове компонента, результаты возвращаются на экран. Однако, если я затем щелкните действие, которое вызывает EJB во второй раз, то я получаю следующее исключение:Второй вызов удаленного EJB3 компонента из jsf в другом приложении - Делегат не установлен
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 находятся в отдельных веб-приложениях. Интерфейсы ejb и jta-объекты находятся в файле jar, который находится внутри каждого приложения. Как я уже говорил ранее, первый звонок для извлечения списка стран возвращается успешно, но второй звонок, чтобы получить пиво для страны, возвращает исключение:
Вот мой управляемый боб.
@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 {
}
Хмм, если я не использую аннотацию @EJB и вместо этого выполняю поиск вручную, нет проблем – zargarf