Could somebody help be to understand why "java.naming.security.principal" and "java.naming.security.credentials" keys were put into JndiTemplate weren't applied while lookup.
Problem details:
When I call ejb via spring proxy that was injected by jndi template it doesn't send userPrincipal and Credentials to ejb, and if I сheck value of javax.ejb.SessionContext.getCallerPrincipal() it will be set to "anonymous" on Ejb.
Application server - WebLogic 10.3.
My Spring's xml file:
My Test java class file is:Code:<beans default-lazy-init="true"> <bean id="jndiTemplate" 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://localhost:7001</prop> <prop key="java.naming.security.principal">test-user</prop> <prop key="java.naming.security.credentials">g0dGres9</prop> </props> </property> </bean> <bean id="testBean" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean"> <property name="jndiName" value="app.Bean1"/> <property name="businessInterface" value="test.Bean1"/> <property name="jndiTemplate" ref="jndiTemplate"/> </bean> </beans>
Code:import test.Bean1; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.XmlBeanFactory; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; import java.util.List; public class Test { private static XmlBeanFactory beanFactory; public static void main(String... params) throws Exception { Bean1 bean = (Bean1) getBeanFactory().getBean("testBean"); bean.callSomeMethod(); } public static BeanFactory getBeanFactory() { if (beanFactory == null) { final Resource resource = new FileSystemResource("spring.xml"); beanFactory = new XmlBeanFactory(resource); beanFactory.preInstantiateSingletons(); } return beanFactory; } }


Reply With Quote