部署描述符中的ejb引用(没有注释)

时间:2011-08-17 08:14:01

标签: dependency-injection glassfish ejb-3.0 deployment-descriptor ejb-jar.xml

我尝试仅使用部署描述符在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() {
}

}

2 个答案:

答案 0 :(得分: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>

答案 1 :(得分:0)

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

remote = business-remote  local = business-local