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

发布于 2024-11-30 08:58:24 字数 1560 浏览 1 评论 0原文

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

Class pl.Test:

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

}

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() {
}

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

秋风の叶未落 2024-12-07 08:58:24

解决办法是:

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

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>

肥爪爪 2024-12-07 08:58:24

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

remote = Business-remote
本地 = 商业本地

you need to replace below tags in the XML:

remote = business-remote
local = business-local

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文