2017-02-21 3 views
1

Nous sommes en train de traiter le déplacement d'une application Weblogic 10.3.6 vers Weblogic 12.2.1.2. Nous avons beaucoup de beans EJB 2.1 qui font partie de l'application. Nous avons rencontré un problème étrange avec certains de ces haricots.EJB 2.1 lançant une exception distante encapsulée dans le cluster

Lorsque nous avons 1 appel ejb autre et que ce bean renvoie une exception vérifiée (par exemple, RuleException extends Exception), il est renvoyé comme RemoteException (RemoteEJBInvokeException). Cela se produit uniquement si l'application est en cours d'exécution dans un cluster. Si je me déploie contre un JVM autonome, cela fonctionne bien.

Le motif EJB général est un motif de façade. Dans la fève de façade, nous utilisons une recherche JNDI standard pour localiser la maison et puis exécutez la méthode de création pour retourner l'interface entreprise/impl

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

ReportManagement haricot dirige la logique métier et jette un RuleException.

Ceci est une méthode par exemple dans la façade qui appelle la 2ème haricot:

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

    return s; 
    } 

Voici la méthode doValidate() dans le 2ème haricot:

public String doValidate() 
     throws RuleException, CustomException 
    { 

    int test = 1; 

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

    return "Hello"; 

    } 

Bien que le RuleException soit atteint correctement et jeté , au moment où la façade l'attrape, c'est un RemoteException.

Ceci est une liste d'exemple des interfaces/EJB:

ReportManagement 
ReportManagementBean 
ReportManagementFacade 
ReportManagementFacadeBean 
ReportManagementFacadeHome 
ReportManagementFacadeLocal 
ReportManagementFacadeLocalHome 
ReportManagementHome 
ReportManagementLocal 
ReportManagementLocalHome 

Voici le 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> 

Voici le 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> 

Et voici le 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 

Toutes les instructions à ce sujet seront très appréciées.

+0

Est-ce que 'RuleException' est sérialisable? –

+0

'public class RuleException extends Exception implémente Serializable' Exception extends Throwable qui implémente Serializable donc définitivement Serializable. Aussi dans ma classe de test, il n'a pas de propriétés supplémentaires. – andyfinch

+0

@andyfinch nous sommes également confrontés au même problème, pouvez-vous s'il vous plaît nous dire comment avez-vous le résoudre? –

Répondre

0

Cela a été corrigé dans un correctif par Oracle à ma demande. Le lien pour ce patch est ici Patch Link. Vous aurez besoin d'une connexion Oracle Support pour pouvoir y accéder.

0

Ce:

<enable-call-by-reference>true</enable-call-by-reference> 

provoque vos appels à distance dans la même machine virtuelle Java pour avoir la sémantique d'un appel local, y compris la gestion des exceptions.

+0

Merci, mais modifier ce paramètre ne résout pas mon problème. – andyfinch

+1

Assurez-vous de déployer complètement votre application, puis de la redéployer. WebLogic n'a historiquement pas été bon pour noter les changements dans les descripteurs de déploiement –

+0

Redémarré et supprimer les caches app/effacés mais toujours la même erreur. – andyfinch