我有两个无状态会话Bean。调用层次结构就像:
MyClass-> UserManagerBean - > BookManagerBean
MyClass通过JNDI查找远程获取UserManagerBean。 反过来,UserManagerBean通过JNDI查找远程获取BookManagerBean。 BookManagerBean正在抛出BookException。
问题: 我可以在从BookManagerBean抛出异常之前看到日志,但是当我在UserManagerBean中捕获此异常时,线程会移动到某个地方并且永远不会出现在UserManagerBean的catch块中。容器似乎吞下了这个例外。这导致了STUCK线程。
注意:令人惊讶的是,相同的代码适用于其他5个WLS实例,但只在一台服务器上出现问题。您是否考虑围绕此问题进行任何weblogic配置?
public class MyClass {
public void findBook(Long bookId) throws Exception{
try{
UserManagerBean userManager = (UserManager) JNDIServiceLocator.getInstance().getRemoteObject(jndiName, 'UserManager' );
userManager.find(bookId);
}catch (Exception e){
Log.log("Exception in MyClass.findBook"); // Thread does not come back to this point. This logger is not getting printed
throw e;
}
UserManagerBean如下:
@Stateless(mappedName ="UserManager")
@Remote(UserManager.class)
public class UserManagerBean {
public Book findBook(Long bookId) throws Exception{
try{
BookManagerBean bookManager = (BookManagerBean) JNDIServiceLocator.getInstance().getRemoteObject(jndiName, 'BookManager' );
bookManager.find(bookId);
}catch (Exception e){
Log.log("Exception in UserManagerBean.findBook"); // **** Thread does not come back to this point. This logger is not getting printed
throw e;
}
}
BookManagerBean类如下所示:
@Stateless(mappedName ="BookManager")
@Remote(BookManagerBean .class)
public class BookManagerBean {
public Book findBook(Long bookId) throws Exception{
try{
//Logic to find Book
}catch (Exception e){
Log.log("Exception");
throw e;
}
}
}
这有效: 如果我使用new运算符更改UserManagerBean中的代码以创建bean,我将从BookManagerBean抛出异常。
BookManagerBean bookManager = new BookManagerBean();
bookManager.find(bookId);