Search
Calendar
May 2024
S M T W T F S
« Sep    
 1234
567891011
12131415161718
19202122232425
262728293031  
Your widget title
Archives

PostHeaderIcon Spring using multi instances of JndiTemplate

Case

Spring application context file:

    <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>

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.

Leave a Reply