gpt4 book ai didi

java - EJB 2.1 在集群中抛出包装的远程异常

转载 作者:太空宇宙 更新时间:2023-11-04 11:45:45 25 4
gpt4 key购买 nike

我们正在将 Weblogic 10.3.6 应用程序迁移到 Weblogic 12.2.1.2。我们有许多 EJB 2.1 bean 构成应用程序的一部分。我们在使用其中一些 Bean 时遇到了一个奇怪的问题。

当我们有 1 个 ejb 调用另一个 ejb 并且该 bean 抛出一个已检查异常(例如 RuleException extends Exception)时,这将作为 RemoteException (RemoteEJBInvokeException) 抛出。仅当应用程序在集群中运行时才会发生这种情况。如果我针对独立的 jvm 进行部署,它可以正常工作。

一般的EJB模式是Facade模式。在 Facade bean 中,我们使用标准 JNDI 查找来定位 Home,然后运行 ​​create 方法来返回业务接口(interface)/impl

InitialContext ctx = new InitialContext();
ReportManagementHome reportManagementHome = (ReportManagementHome) ctx.lookup("ReportManagement");
ReportManagement reportManagement = reportManagementHome.create();

ReportManagement bean 运行业务逻辑并抛出 RuleException。

这是外观中调用第二个 bean 的示例方法:

public String doTest() {
String s = null;
try
{
s = reportManagement.doValidate();
}
catch ( RuleException re )
{
rollBack();
} catch (RemoteException e)
{
e.printStackTrace();
}

return s;
}

这是第二个 bean 中的 doValidate() 方法:

public String doValidate( )
throws RuleException, CustomException
{

int test = 1;

if (test == 1)
{
throw new RuleException();
}

return "Hello";

}

尽管 RuleException 已正确到达并抛出,但当外观捕获它时,它已是 RemoteException

这是 ejbs/接口(interface)的示例列表:

ReportManagement
ReportManagementBean
ReportManagementFacade
ReportManagementFacadeBean
ReportManagementFacadeHome
ReportManagementFacadeLocal
ReportManagementFacadeLocalHome
ReportManagementHome
ReportManagementLocal
ReportManagementLocalHome

这是ejb-jar.xml

    <?xml version='1.0' encoding='UTF-8'?>
<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
version="2.1">
<enterprise-beans>
<session>
<display-name>ReportManagementFacade</display-name>
<ejb-name>ReportManagementFacade</ejb-name>
<home>com.ejb.ReportManagementFacadeHome</home>
<remote>com.ejb.ReportManagementFacade</remote>
<local-home>com.ejb.ReportManagementFacadeLocalHome</local-home>
<local>com.ejb.ReportManagementFacadeLocal</local>
<ejb-class>com.ejb.ReportManagementFacadeBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<session>
<display-name>ReportManagement</display-name>
<ejb-name>ReportManagement</ejb-name>
<home>com.ejb.ReportManagementHome</home>
<remote>com.ejb.ReportManagement</remote>
<local-home>com.ejb.ReportManagementLocalHome</local-home>
<local>com.ejb.ReportManagementLocal</local>
<ejb-class>com.ejb.ReportManagementBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>ReportManagementFacade</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>ReportManagement</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>

这是 weblogic-ejb-jar.xml

    <?xml version='1.0' encoding='UTF-8'?>
<weblogic-ejb-jar xmlns="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.2/weblogic-ejb-jar.xsd">
<weblogic-enterprise-bean>
<ejb-name>ReportManagementFacade</ejb-name>
<jndi-name>Destin8.ejb.reportmanagement.ReportManagementFacade</jndi-name>
<local-jndi-name>Destin8.ejb.reportmanagement.ReportManagementFacadeLocal</local-jndi-name>
<enable-call-by-reference>true</enable-call-by-reference>
</weblogic-enterprise-bean>
<weblogic-enterprise-bean>
<ejb-name>ReportManagement</ejb-name>
<jndi-name>Destin8.ejb.reportmanagement.ReportManagement</jndi-name>
<local-jndi-name>Destin8.ejb.reportmanagement.ReportManagementLocal</local-jndi-name>
<enable-call-by-reference>true</enable-call-by-reference>
</weblogic-enterprise-bean>
<weblogic-compatibility>
<entity-always-uses-transaction>true</entity-always-uses-transaction>
</weblogic-compatibility>
</weblogic-ejb-jar>

这是 StackTrace:

weblogic.rmi.RemoteEJBInvokeException: null; nested exception is: 
com.exception.RuleException
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:27)
at com.ejb.ReportManagement_tq6u66_EOImpl.doLUMValidate(Unknown Source)
at com.ejb.ReportManagementFacadeBean.doLUM(ReportManagementFacadeBean.java:82)
at com.ejb.ReportManagementFacade_sidvua_EOImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invokeInternal(SessionRemoteMethodInvoker.java:54)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:21)
at com.ejb.ReportManagementFacade_sidvua_EOImpl.doLUM(Unknown Source)
at com.ajf.Page1ManagedBean.refreshDate(Page1ManagedBean.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.sun.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:181)
at com.sun.el.parser.AstValue.invoke(AstValue.java:289)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:650)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:286)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:260)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:137)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:350)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:25)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:32)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:78)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3683)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3649)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:326)
at weblogic.security.service.SecurityManager.runAsForUserCode(SecurityManager.java:197)
at weblogic.servlet.provider.WlsSecurityProvider.runAsForUserCode(WlsSecurityProvider.java:203)
at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:71)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2433)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2281)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2259)
at weblogic.servlet.internal.ServletRequestImpl.runInternal(ServletRequestImpl.java:1691)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1651)
at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:270)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
Caused by: com.exception.RuleException
at com.ejb.ReportManagementBean.doLUMValidate(ReportManagementBean.java:92)
at com.ejb.ReportManagement_tq6u66_EOImpl.__WL_invoke(Unknown Source)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invokeInternal(SessionRemoteMethodInvoker.java:54)
at weblogic.ejb.container.internal.SessionRemoteMethodInvoker.invoke(SessionRemoteMethodInvoker.java:21)
... 55 more

对于此事的任何指导将不胜感激。

最佳答案

Oracle 根据我的要求在补丁中修复了这个问题。该补丁的链接在这里 Patch Link 。您需要 Oracle 支持登录才能访问它。

关于java - EJB 2.1 在集群中抛出包装的远程异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42366490/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com