开发者

Must or must not extend javax.ejb.EJBLocalObject interface?

While migrating from JBoss 4.3 to 5.1 the following issue occured:

The first Exception occurs during deploy time with no implementation of EJBLocalObject:

Caused by: java.lang.IllegalStateException: EJB 3.0 Core Specification Violation (4.6.9): The session beanÔÇÖs local interface interface com.company.project.BeanLocal must extend the javax.ejb.EJBLocalO
bject interface.
        at org.jboss.metadata.annotation.creator.ejb.jboss.LocalHomeProcessor.setLocal(LocalHomeProcessor.java:73)
        at org.jboss.metadata.annotation.creator.ejb.jboss.LocalHomeProcessor.process(LocalHomeProcessor.java:66)
        at org.jboss.metadata.annotation.creator.ejb.jboss.LocalHomeProcessor.process(LocalHomeProcessor.java:45)
        at org.jboss.metadata.annotation.creator.AbstractProcessor.processClass(AbstractProcessor.java:215)
        at org.jboss.metadata.annotation.creator.AbstractProcessor.processClass(AbstractProcessor.java:172)
        at org.jboss.metadata.annotation.creator.ejb.jboss.AbstractEnterpriseBeanProcessor.process(AbstractEnterpriseBeanProcessor.j
ava:119)
        at org.jboss.metadata.annotation.creator.ejb.jboss.AbstractEnterpriseBeanProcessor.process(AbstractEnterpriseBeanProcessor.j
ava:94)
        at org.jboss.metadata.annotation.creator.ejb.jboss.AbstractEnterpriseBeanProcessor.process(AbstractEnterpriseBeanProcessor.j
ava:52)
        at org.jboss.metadata.annotation.creator.AbstractCreator.process(AbstractCreator.java:154)
        at org.jboss.metadata.annotation.creator.AbstractCreator.processMetaData(AbstractCreator.java:87)
        at org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator.create(JBoss50Creator.java:109)
        at org.jboss.deployment.OptAnnotationMetaDataDeployer.processJBossMetaData(OptAnnotationMetaDataDeployer.java:134)
        at org.jboss.deployment.OptAnnotationMetaDataDeployer.processMetaData(OptAnnotationMetaDataDeployer.java:84)
        at org.jboss.deployment.AnnotationMetaDataDeployer.deploy(AnnotationMetaDataDeployer.java:177)
        ... 32 more

OK, then I implemented th开发者_Python百科e interfaces, but JBoss isn't satisfied and is now complaining: the bean must not implement EJBLocalObject! Any Ideas?

Caused by: java.lang.IllegalStateException: EJB 3.0 Core Specification Violation (4.6.6): The session beanÔÇÖs business interface in
terface com.company.project.BeanLocal must not extend the javax.ejb.EJBLocalObject interface.
        at org.jboss.metadata.annotation.creator.ejb.jboss.LocalProcessor.addBusinessInterface(LocalProcessor.java:57)
        at org.jboss.metadata.annotation.creator.ejb.jboss.LocalProcessor.process(LocalProcessor.java:76)
        at org.jboss.metadata.annotation.creator.ejb.jboss.LocalProcessor.process(LocalProcessor.java:45)
        at org.jboss.metadata.annotation.creator.AbstractProcessor.processClass(AbstractProcessor.java:222)
        at org.jboss.metadata.annotation.creator.AbstractProcessor.processClass(AbstractProcessor.java:172)
        at org.jboss.metadata.annotation.creator.ejb.jboss.AbstractEnterpriseBeanProcessor.process(AbstractEnterpriseBeanProcessor.j
ava:119)
        at org.jboss.metadata.annotation.creator.ejb.jboss.AbstractEnterpriseBeanProcessor.process(AbstractEnterpriseBeanProcessor.j
ava:94)
        at org.jboss.metadata.annotation.creator.ejb.jboss.AbstractEnterpriseBeanProcessor.process(AbstractEnterpriseBeanProcessor.j
ava:52)
        at org.jboss.metadata.annotation.creator.AbstractCreator.process(AbstractCreator.java:154)
        at org.jboss.metadata.annotation.creator.AbstractCreator.processMetaData(AbstractCreator.java:87)
        at org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator.create(JBoss50Creator.java:109)
        at org.jboss.deployment.OptAnnotationMetaDataDeployer.processJBossMetaData(OptAnnotationMetaDataDeployer.java:134)
        at org.jboss.deployment.OptAnnotationMetaDataDeployer.processMetaData(OptAnnotationMetaDataDeployer.java:84)
        at org.jboss.deployment.AnnotationMetaDataDeployer.deploy(AnnotationMetaDataDeployer.java:177)
        ... 32 more

EDIT: I should mention that the bean is a EJB3.0 with provides also an EJB 2.1 client view.

The declaration looks like this:

@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@Stateless
@RemoteHome(R2PRegistrationHome.class)
@RemoteHomeBinding(jndiBinding = JNDINames.BEAN_FOR_EJB_2_1_EJBHOME)
@LocalHome(R2PRegistrationLocalHome.class)
@LocalHomeBinding(jndiBinding = JNDINames.BEAN_FOR_EJB_2_1_LOCALHOME)
public class Bean implements BeanLocal, BeanRemote {
}


To make your life simpler I suggest not making a single bean both an EJB3 and EJB2 bean. Create a separate EJB2 bean that delegates to the EJB3 one.

This also makes it easier to simply delete the EJB2 bean as soon as you don't have to support that anymore.

Additionally you can remove both @TransactionManagement(TransactionManagementType.CONTAINER) and @TransactionAttribute(TransactionAttributeType.REQUIRED). These are both the defaults and not needed as EJB3 emphasizes convention over configuration. The style you're starting to program in seems to be a little anti to the spirit of EJB3. This may not be a problem if you are the only programmer, but other people trained in EJB3 may not react kindly to it.

The following should be enough:

@Stateless
public class Bean implements BeanLocal, BeanRemote {
}


The Bean class should not implement component interfaces. Remove the implements clause from the Bean class, change the BeanLocal interface to extend EJBLocalObject, and change the BeanRemote interface to extend EJBObject.


According to the second stacktrace it appears that you are using the same interface as both local and remote interface. If you create separate remote and local interfaces, respectively, you should be fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜