Recent Posts
Archives

Posts Tagged ‘JndiTemplate’

PostHeaderIcon Spring using multi instances of JndiTemplate

Case

Spring application context file:

[xml]
<bean id="jmsQueueConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jonathan.jms-connection-factory.external"/>
<property name="jndiEnvironment">
<props>
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
<prop key="java.naming.provider.url">
t3://anOtherServer:8521
</prop>
<prop key="java.naming.security.principal">jonathan</prop>
<prop key="java.naming.security.credentials">jonathan</prop>
<prop key="weblogic.jndi.enableDefaultUser">true</prop>
</props>
</property>
</bean>
<bean id="mainJndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
<prop key="java.naming.provider.url">t3://mainServer:1234</prop>
<prop key="java.naming.security.principal">myPrincipal</prop>
<prop key="java.naming.security.credentials">myPassword</prop>
<prop key="weblogic.jndi.enableDefaultUser">false</prop>
</props>
</property>
</bean>
[/xml]

Description

I use two instances of JndiTemplate to send JMS messages on two different queues, on two different Weblogic domains, using two different Ldap directories. When I try to send messages on the second server, it does not work: I get an error because the second server receives credentials that should be sent to the first server.

[Security:090398]Invalid Subject: principals=[...]

Quick fix

Remove the properties weblogic.jndi.enableDefaultUser from within the XML.