简体   繁体   English

ejb归档jar中循环依赖的无状态Bean未部署在JBoss 5.1.0上

[英]Cyclically dependent Stateless beans in ejb archive jar not getting deployed on JBoss 5.1.0

I have created an EJB project which has the following java files . 我创建了一个具有以下java文件的EJB项目。 It does not deploy on the JBoss 5.1.0 and spits out deployment error which is appended after java code below . 它没有部署在JBoss 5.1.0上,并吐出了部署错误,该错误附加在下面的Java代码之后。 But the same jar gets deployed on JBoss AS 7.1. 但是在JBoss AS 7.1上部署了相同的jar。 Why the jar is not getting deployed on JBoss 5.1 ? 为什么jar无法部署在JBoss 5.1上?

Please note that , the bean implementation BeanA has-a BeanB's local interface and bean implementation of BeanB has-a BeanA's local interface so it is a cycle. 请注意,Bean实现BeanA具有-BeanB的本地接口,而BeanB的Bean实现具有-BeanA的本地接口,因此这是一个循环。

BeanALocalInterface.java BeanALocalInterface.java

package com.xyz;    
import javax.ejb.Local;    
    @Local    
public interface BeanALocalInterface {
    public void executeLocal();
}

BeanA.java BeanA.java

package com.xyz;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@Stateless
public class BeanA implements  BeanALocalInterface {
    @EJB    private BeanBLocalInterface beanBLocalInterface;
    public BeanA() {}
    public void executeLocal() {System.out.println("executing in  BeanA"); beanBLocalInterface.executeLocal();}
    public void executeRemote() {System.out.println("executing in  BeanA"); }
}

BeanBLocalInterface.java BeanBLocalInterface.java

package com.xyz;
import javax.ejb.Local;
@Local
public interface BeanBLocalInterface {
    public void executeLocal();
}

BeanB.java BeanB.java

package com.xyz;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@Stateless
public class BeanB  implements BeanBLocalInterface  {
    @EJB private BeanALocalInterface localInterface;
    public BeanB() {  }
    public void executeLocal() { localInterface.executeLocal(); }
    public void executeRemote() { System.out.println("executing in  BeanB");}
}

Error Logs while deploying CyclicalBeans.jar in JBOSS 5.1.0 在JBOSS 5.1.0中部署CyclicalBeans.jar时出现错误日志

11:59:31,557 INFO  [JBossASKernel] Created KernelDeployment for: CyclicalBeans.jar
11:59:31,557 INFO  [JBossASKernel] installing bean: jboss.j2ee:jar=CyclicalBeans.jar,name=BeanA,service=EJB3
11:59:31,557 INFO  [JBossASKernel]   with dependencies:
11:59:31,557 INFO  [JBossASKernel]   and demands:
11:59:31,573 INFO  [JBossASKernel]      jndi:BeanB/local-com.xyz.BeanBLocalInterface
11:59:31,573 INFO  [JBossASKernel]      jboss.ejb:service=EJBTimerService
11:59:31,573 INFO  [JBossASKernel]   and supplies:
11:59:31,573 INFO  [JBossASKernel]      jndi:BeanA/local-com.xyz.BeanALocalInterface
11:59:31,588 INFO  [JBossASKernel]      jndi:BeanA/local
11:59:31,588 INFO  [JBossASKernel]      Class:com.xyz.BeanARemoteInterface
11:59:31,588 INFO  [JBossASKernel]      jndi:BeanA/remote-com.xyz.BeanARemoteInterface
11:59:31,588 INFO  [JBossASKernel]      Class:com.xyz.BeanALocalInterface
11:59:31,604 INFO  [JBossASKernel]      jndi:BeanA/remote
11:59:31,604 INFO  [JBossASKernel] Added bean(jboss.j2ee:jar=CyclicalBeans.jar,name=BeanA,service=EJB3) to KernelDeployment of: CyclicalBeans.jar
11:59:31,604 INFO  [JBossASKernel] installing bean: jboss.j2ee:jar=CyclicalBeans.jar,name=BeanB,service=EJB3
11:59:31,619 INFO  [JBossASKernel]   with dependencies:
11:59:31,619 INFO  [JBossASKernel]   and demands:
11:59:31,619 INFO  [JBossASKernel]      jboss.ejb:service=EJBTimerService
11:59:31,635 INFO  [JBossASKernel]      jndi:BeanA/local-com.xyz.BeanALocalInterface
11:59:31,635 INFO  [JBossASKernel]   and supplies:
11:59:31,635 INFO  [JBossASKernel]      Class:com.xyz.BeanBLocalInterface
11:59:31,635 INFO  [JBossASKernel]      jndi:BeanB/local-com.xyz.BeanBLocalInterface
11:59:31,651 INFO  [JBossASKernel]      jndi:BeanB/local
11:59:31,651 INFO  [JBossASKernel]      jndi:BeanB/remote
11:59:31,666 INFO  [JBossASKernel] Added bean(jboss.j2ee:jar=CyclicalBeans.jar,name=BeanB,service=EJB3) to KernelDeployment of: CyclicalBeans.jar
11:59:31,666 INFO  [EJB3EndpointDeployer] Deploy AbstractBeanMetaData@68f7b23c{name=jboss.j2ee:jar=CyclicalBeans.jar,name=BeanA,service=EJB3_endpoint bean=org.jboss.ejb3.endpoint.deployers.impl.EndpointImpl properties=[container] constructor=null autowireCandidate=true}
11:59:31,666 INFO  [EJB3EndpointDeployer] Deploy AbstractBeanMetaData@3b870737{name=jboss.j2ee:jar=CyclicalBeans.jar,name=BeanB,service=EJB3_endpoint bean=org.jboss.ejb3.endpoint.deployers.impl.EndpointImpl properties=[container] constructor=null autowireCandidate=true}
11:59:31,744 WARN  [HDScanner] Failed to process changes
org.jboss.deployers.client.spi.IncompleteDeploymentException: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):

DEPLOYMENTS MISSING DEPENDENCIES:
  Deployment "jboss.j2ee:jar=CyclicalBeans.jar,name=BeanA,service=EJB3" is missing the following dependencies:
    Dependency "<UNKNOWN jboss.j2ee:jar=CyclicalBeans.jar,name=BeanA,service=EJB3>" (should be in state "Described", but is actually in state "** UNRESOLVED Demands 'jndi:BeanB/local-com.xyz.BeanBLocalInterface' **")
  Deployment "jboss.j2ee:jar=CyclicalBeans.jar,name=BeanA,service=EJB3_endpoint" is missing the following dependencies:
    Dependency "jboss.j2ee:jar=CyclicalBeans.jar,name=BeanA,service=EJB3" (should be in state "Configured", but is actually in state "PreInstall")
  Deployment "jboss.j2ee:jar=CyclicalBeans.jar,name=BeanB,service=EJB3" is missing the following dependencies:
    Dependency "<UNKNOWN jboss.j2ee:jar=CyclicalBeans.jar,name=BeanB,service=EJB3>" (should be in state "Described", but is actually in state "** UNRESOLVED Demands 'jndi:BeanA/local-com.xyz.BeanALocalInterface' **")
  Deployment "jboss.j2ee:jar=CyclicalBeans.jar,name=BeanB,service=EJB3_endpoint" is missing the following dependencies:
    Dependency "jboss.j2ee:jar=CyclicalBeans.jar,name=BeanB,service=EJB3" (should be in state "Configured", but is actually in state "PreInstall")

DEPLOYMENTS IN ERROR:
  Deployment "<UNKNOWN jboss.j2ee:jar=CyclicalBeans.jar,name=BeanA,service=EJB3>" is in error due to the following reason(s): ** UNRESOLVED Demands 'jndi:BeanB/local-com.xyz.BeanBLocalInterface' **
  Deployment "<UNKNOWN jboss.j2ee:jar=CyclicalBeans.jar,name=BeanB,service=EJB3>" is in error due to the following reason(s): ** UNRESOLVED Demands 'jndi:BeanA/local-com.xyz.BeanALocalInterface' **

        at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:993)
        at org.jboss.deployers.plugins.deployers.DeployersImpl.checkComplete(DeployersImpl.java:939)
        at org.jboss.deployers.plugins.main.MainDeployerImpl.checkComplete(MainDeployerImpl.java:873)
        at org.jboss.system.server.profileservice.repository.MainDeployerAdapter.checkComplete(MainDeployerAdapter.java:128)
        at org.jboss.system.server.profileservice.hotdeploy.HDScanner.scan(HDScanner.java:369)
        at org.jboss.system.server.profileservice.hotdeploy.HDScanner.run(HDScanner.java:255)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
        at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:662)

@IgnoreDependency annotation on injected Beans will resolve this issue. 注入的Bean上的@IgnoreDependency注释将解决此问题。 Please Modify BeanA.java and BeanB.java as follows: 请按如下所示修改BeanA.java和BeanB.java:

BeanA.java BeanA.java

package com.xyz;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import org.jboss.ejb3.annotation.IgnoreDependency;
@Stateless
public class BeanA implements  BeanALocalInterface {
    @IgnoreDependency
    @EJB(name="ejb/BeanBLocalInterface")    private BeanBLocalInterface beanBLocalInterface;
    public BeanA() {}
    public void executeLocal() {System.out.println("executing in  BeanA"); beanBLocalInterface.executeLocal();}
    public void executeRemote() {System.out.println("executing in  BeanA"); }
}

BeanB.java BeanB.java

package com.xyz;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import org.jboss.ejb3.annotation.IgnoreDependency;

@Stateless
public class BeanB  implements BeanBLocalInterface  {
    @IgnoreDependency
    @EJB(name="ejb/BeanALocalInterface ") private BeanALocalInterface localInterface;
    public BeanB() {  }
    public void executeLocal() { localInterface.executeLocal(); }
    public void executeRemote() { System.out.println("executing in  BeanB");}
}

I derived my solution from the following question answer link . 我从以下问题答案链接中得出了解决方案。 answer link 答案链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM