简体   繁体   中英

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. Apache TomEE+ 1.7.2 recognizes only one of them randomly on each deploy and completely ignores the other one, not even a warning!

Tried changing openejb.deploymentId.format property in the conf/system.properties to the two below, but that didn't help.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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