EJBを検索するために、専用の Spring EJBアクセスクラスを使用しないでください。

Spring Framework 6.0 では、専用のEJBアクセスが削除された。 Spring Framework 5.x では、EJBへのアクセスは LocalStatelessSessionProxyFactoryBean, SimpleRemoteStatelessSessionProxyFactoryBean, LocalSlsbInvokerInterceptor および SimpleRemoteSlsbInvokerInterceptor クラスは org.springframework.ejb.access パッケージで提供される。

これらのクラスは、次のような Spring XML ファイルで参照できます。 application-config.xml.

この使用例を紹介しよう:

<bean id="myEjb" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">

また、以下のように Java :


import org.springframework.ejb.access.*;	
@Bean
public SimpleRemoteStatelessSessionProxyFactoryBean myEjb() {
    SimpleRemoteStatelessSessionProxyFactoryBean factory = new SimpleRemoteStatelessSessionProxyFactoryBean();
}

このルールは org.springframework.ejb.access パッケージ Java .class ファイルまたは .xml ファイルのみ。 Spring 6.0 では、JNDI を直接使用します JndiObjectFactoryBean Java。 または jee:jndi-lookup in (存在する) .xml ファイルのみ。

以下はその例である JndiObjectFactoryBean:


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jndi.JndiObjectFactoryBean;
import com.example.ejb.MyRemoteBean;
@Configuration
public class EjbJndiConfig {

    @Bean
    public JndiObjectFactoryBean myRemoteEjb() {
        JndiObjectFactoryBean jndiBean = new JndiObjectFactoryBean();
        jndiBean.setJndiName("java:global/myApp/MyRemoteBean!com.example.ejb.MyRemoteBean");
        jndiBean.setProxyInterface(MyRemoteBean.class);
        jndiBean.setLookupOnStartup(false);  // delay lookup if needed
        return jndiBean;
    }
}

以下はその例である jee-jndi-lookup:

<beans xmlns=" http://www.springframework.org/schema/beans " xmlns:jee=" http://www.springframework.org/schema/jee " xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance ".... <je:jndi-ルックアップ id="myEjb" jndi-name="java:global/myApp/MyRemoteBean!com.example.ejb.MyBean" proxy-interface="com.example.ejb.MyBean" /> </beans>

詳しくは、以下のリソースを参照してください。