如何在spring中使用ejb?

7lrncoxx  于 2021-07-26  发布在  Java
关注(0)|答案(0)|浏览(237)

我正试着注射 EJB 在websphere服务器中使用spring应用程序来调用他的方法。
我下载了ejb的jar并将其作为库添加到项目中。jar公开了一个远程接口。
1:库中的ejb jar
然后我试图让spring理解它是一个ejb。我把这个放在web.xml里面

<description />
        <ejb-ref-name>ejb/AberturaEJBRemoteRef</ejb-ref-name>
        <ejb-ref-type>Session</ejb-ref-type>
        <home />
        <remote>
            br.com.zzz.xxx.servcaptura.abertura.ejb.AberturaEJBRemote
        </remote>
        <ejb-link>AberturaEJB</ejb-link>
    </ejb-ref>

然后我在app.context中尝试了以下两种配置:
第一次尝试:

<jee:remote-slsb id="abertura" jndi- name="ejb/AberturaEJBRemoteRef#br.com.zzz.xxx.servcaptura.abertura.ejb.AberturaEJBRemote"
           business-interface="br.com.zzz.xxx.servcaptura.abertura.ejb.AberturaEJBRemote"
           home-interface="br.com.zzz.xxx.servcaptura.abertura.ejb.AberturaEJBRemote"
           cache-home="false" lookup-home-on-startup="false"
           refresh-home-on-connect-failure="true" />

第二次尝试:

<bean id="abertura"
          class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean" lazy-init="true">
        <property name="jndiName" value="ejb/AberturaEJBRemoteRef" />
        <property name="businessInterface" value="br.com.zzz.xxx.servcaptura.abertura.ejb.AberturaEJBRemote" />
    </bean>

<bean id="acompanhamentoWebService"  class="br.com.zzz.xxx.integracaosinistro.servacompws.webservice.AcompanhamentoWebService">
        <property name="abertura">
            <ref bean="abertura" />
        </property>
    </bean>

在课堂上,我做的是:

@Service
@WebService
public class AcompanhamentoWebService {

  @Autowired(required = true)
    private AberturaEJBRemote abertura;
...

第二个Spring不明白它是一颗豆子。
在第一次配置尝试时,使用jee:remote-slsb,在调用ejb方法后,我得到一个错误:

name: ejb/AberturaEJBRemoteRef#br.com.zzz.xxx.servcaptura.abertura.ejb.AberturaEJBRemote: First component in name AberturaEJBRemoteRef#br.com.zzz.xxx.servcaptura.abertura.ejb.AberturaEJBRemote not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]

我真的不知道我是否正确地尝试了这个,因为我以前从未使用过ejb。调用jar内部的远程方法是正确的吗?
你觉得我做错了什么?
对不起,英语不好。谢谢。
更新
我建立了一个例子,似乎我的方法是好的。但它在websphere中缺少ejb配置。为了远程调用ejb,我读到我需要ejb存储和可用的服务器信息。我还没有这个信息。
我认为我可以直接从jar访问ejb中的方法。但我明白不是这样的。
当问题解决或出现其他信息时,我会回到这里。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题