English 中文(简体)
必须或不得延长javax.ejb.EJB Local 目标接口?
原标题:Must or must not extend javax.ejb.EJBLocalObject interface?

在从JBos4.3迁移到5.1时,出现了以下问题:

第一个例外是在部署期间,没有执行EJB LocalObject:

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 the 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:我应该提到,信使是EJB3.0,也提供了EJB 2.1客户的观点。

声明认为:

@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 {
}
最佳回答

班级不应实施部件接口。 将执行条款从Bean类别删除,改变Bean Local界面,以扩大EJB LocalObject,并改变BeanRemote接口以扩大EJBObject。

问题回答

为了让你的生活更加简单,我建议不要把一个表象变成一个EJB3和EJB2。 创建一个单独的EJB2灯,代表EJB3。

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

此外,您可以删除@transactionManagement(TransactionManagementType.CONTAINER)。 这些都是缺省,不需要,因为EJB3强调公约过于组合。 你重新开始方案的做法似乎与EJB3的精神背道而驰。 如果你是唯一的策划者,这不会成为一个问题,但是在EJB3培训的其他人可能不会对此做出反应。

下面的内容应当足够:

@Stateless
public class Bean implements BeanLocal, BeanRemote {
}

根据第二套中程,你似乎正在使用与当地和偏远地区相同的接口。 如果你分别建立单独的远程和地方接口,就应当罚款。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...