In Spring Framework 6.0 dedicated EJB access has been removed. In Spring Framework 5.x EJB access is done using the
LocalStatelessSessionProxyFactoryBean, SimpleRemoteStatelessSessionProxyFactoryBean,
LocalSlsbInvokerInterceptor and SimpleRemoteSlsbInvokerInterceptor classes found in the org.springframework.ejb.access package.
These classes can be referenced in Spring XML files such as application-config.xml.
Here is an example of this use case:
<bean id="myEjb" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
They can also be referenced in Java files like this:
import org.springframework.ejb.access.*;
@Bean
public SimpleRemoteStatelessSessionProxyFactoryBean myEjb() {
SimpleRemoteStatelessSessionProxyFactoryBean factory = new SimpleRemoteStatelessSessionProxyFactoryBean();
}
This rule flags the usage of the org.springframework.ejb.access package in Java .class files or .xml files.
For Spring 6.0 use JNDI directly via JndiObjectFactoryBean in Java files
or jee:jndi-lookup in .xml files.
Here is an example with 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;
}
}
Here is an example with 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"
....
<jee:jndi-lookup id="myEjb"
jndi-name="java:global/myApp/MyRemoteBean!com.example.ejb.MyBean"
proxy-interface="com.example.ejb.MyBean" />
</beans>
For more information, see the following resources: