ejb reference in deployment descriptor (without annotations )

爷,独闯天下 提交于 2019-12-13 02:23:47

问题


I try to inject dependency in EJB 3.0 using only deployment descriptor. When I deploy my app to Glassfish (v3.1) I get this exception:

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

I have no idea what I do wrong. Can anybody help me, please?

The ejb-jar.xml descriptor is:

<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>

Class pl.Test:

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

}


回答1:


The solution is:

<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>




回答2:


you need to replace below tags in the XML:

remote = business-remote local = business-local



来源:https://stackoverflow.com/questions/7089670/ejb-reference-in-deployment-descriptor-without-annotations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!