1

我尝试仅使用部署描述符在 EJB 3.0 中注入依赖项。当我将我的应用程序部署到 Glassfish (v3.1) 时,我得到了这个异常:

java.lang.RuntimeException: Warning : Unable to determine local  business vs. remote business designation for  EJB 3.0 ref Local ejb-ref name=ejb/Test2,Local 3.x interface =pl.Test2Local,ejb-link=Test2,lookup=,mappedName=,jndi-name=,refType=Session

我不知道我做错了什么。有人可以帮我吗?

ejb-jar.xml 描述符是:

<session>
    <ejb-name>Test2</ejb-name>
    <remote>pl.Test2Remote</remote>
    <local>pl.Test2Local</local>
    <ejb-class>pl.Test2</ejb-class>
    <session-type>Stateless</session-type>
</session>

<session>
    <ejb-name>Test</ejb-name>
    <remote>pl.TestRemote</remote>
    <local>pl.TestLocal</local>
    <ejb-class>pl.Test</ejb-class>
    <session-type>Stateless</session-type>
    <ejb-local-ref>
        <ejb-ref-name>ejb/Test2</ejb-ref-name>
        <local>pl.Test2Local</local>
        <ejb-link>Test2</ejb-link>
        <injection-target>
            <injection-target-class>pl.Test</injection-target-class>
            <injection-target-name>test2</injection-target-name>
        </injection-target>
    </ejb-local-ref>
</session>

类pl.Test:

public class Test implements TestRemote, TestLocal {
private Test2Local test2;
public Test() {
}

}

4

2 回答 2

1

解决方案是:

<enterprise-beans>
    <session id="Test">
        <ejb-name>Test</ejb-name>
        <ejb-class>pl.Test</ejb-class>
        <session-type>Stateless</session-type>
        <transaction-type>Container</transaction-type>
        <ejb-local-ref>
            <ejb-ref-name>pl.Test/test2</ejb-ref-name>
            <local>pl.Test2Local</local>
            <injection-target>
                <injection-target-class>pl.Test</injection-target-class>
                <injection-target-name>test2</injection-target-name>
            </injection-target>
        </ejb-local-ref>
        <depends-on/>
    </session>
    <session id="Test2">
        <ejb-name>Test2</ejb-name>
        <mapped-name></mapped-name>
        <ejb-class>pl.Test2</ejb-class>
        <session-type>Stateless</session-type>
        <transaction-type>Container</transaction-type>
        <depends-on/>
    </session>
</enterprise-beans>

于 2011-08-24T09:56:21.140 回答
0

您需要在 XML 中替换以下标签:

远程 = 业务远程本地 = 业务本地

于 2013-02-13T11:18:49.263 回答