WebLogic JNDI integration¶
WebLogic JNDI integration enables Spring applications to lookup and access remote Enterprise JavaBeans (EJBs) or other resources hosted on a WebLogic Server instance^[weblogic-spring-jpa.md].
Configuration¶
To integrate with WebLogic via JNDI in a Spring application, developers typically define the environment properties and the remote bean proxy within the Spring context configuration (e.g., applicationContext.xml).
JNDI Environment Properties¶
A properties bean must be configured to supply the necessary WebLogic connection details^[weblogic-spring-jpa.md]:
- Initial Context Factory: Set to
weblogic.jndi.WLInitialContextFactory. - Provider URL: The WebLogic Server address (e.g.,
t3://localhost:8080). - Security Principal: The username for authentication (e.g.,
weblogic). - Security Credentials: The password for the user.
<beans:properties id="jndiEnvironment">
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
<prop key="java.naming.provider.url">t3://localhost:8080</prop>
<prop key="java.naming.security.principal">weblogic</prop>
<prop key="java.naming.security.credentials">1qaz2wsx</prop>
</beans:properties>
Remote Bean Lookup¶
The JndiObjectFactoryBean class is used to create a proxy for the remote EJB service^[weblogic-spring-jpa.md]. This bean requires the JNDI name of the remote service and a reference to the configured JNDI environment^[weblogic-spring-jpa.md].
<bean id="casualGameLottGroupSeriesServiceRemote"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"
value="bpm.ejb.CasualGameLottGroupSeriesService#core.bpm.service.settings.CasualGameLottGroupSeriesServiceRemote"></property>
<property name="jndiEnvironment" ref="jndiEnvironment" />
</bean>
Usage¶
Once configured, the remote service can be injected into application components and used like a local bean^[weblogic-spring-jpa.md]. For example, injecting CasualGameLottGroupSeriesServiceRemote allows the application to invoke methods such as getTopCasualGame remotely^[weblogic-spring-jpa.md].
Related Concepts¶
- [[Java EE]]
- Spring Framework
- [[EJB]]
Sources¶
^[weblogic-spring-jpa.md]