简体   繁体   English

具有相同名称的多个EJB bean

[英]Multiple EJB beans with same name

We have two EJB beans that have the same name (say MyBean) but are in different packages (different sub modules), say com.example.module1 and com.example.module2 and they implement entirely different interfaces. 我们有两个具有相同名称(例如MyBean)但位于不同包(不同子模块)中的EJB bean,例如com.example.module1和com.example.module2,它们实现了完全不同的接口。 Apache TomEE+ 1.7.2 recognizes only one of them randomly on each deploy and completely ignores the other one, not even a warning! Apache TomEE + 1.7.2在每个部署中只能随机识别其中一个,而完全忽略另一个,甚至没有警告!

Tried changing openejb.deploymentId.format property in the conf/system.properties to the two below, but that didn't help. 尝试将conf / system.properties中的openejb.deploymentId.format属性更改为以下两个,但这没有帮助。

openejb.deploymentId.format = {appId}/{ejbJarId}/{ejbName}

openejb.deploymentId.format = {appId}/{ejbJarId}/{ejbClass}

Anyone know how to fix this problem? 有人知道如何解决此问题吗? Thanks much 非常感谢

Have you tried setting a name for each? 您是否尝试过为每个名称设置名称?

@Stateless(name="MyBean1")
public class MyBean implements MyBeanLocal

or annotations 或注释

@Documented
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
public @interface TypeOne {

}

@Documented
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
public @interface TypeTwo {

}


@TypeOne
@Stateless
public class MyBean implements MyBeanLocal

@TypeTwo
@Stateless
public class MyBean implements MyBeanLocal

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

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