Good morning everyone!
I find myself maintaining a project that makes use of a Spring context file, the truth is the first time I work with this type of technology. Anyway the point is that I am trying to implement a connection to a Weblogic remote queue, when I use the spring annotations, I can do it without any problem, but when I try to make this connection through the use of contexts, I have the following error:
java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[weblogic, Administrators] at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:309) at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java :555) at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:313) at weblogic.jms.frontend.FEConnectionFactoryImpl_12210_WLStub.connectionCreateRequest(Unknown Source) at weblogic.jms.client.JMSConnectionFactory.createConnection(JMSConnectionFactory.java:399 )
Actually I don't know if it's a security problem, (although that's the error that I get) because as I mentioned, I have already made this type of connection through annotations. I want to believe that the problem is in the implementation of my context file.
<bean id="wlMessageSenderRemote"
class="com.serviceplatform.example.jms.WLMessageSenderRemote">
<property name="wlMessageSenderRemote">
<ref bean="jmsTemplate" />
</property>
</bean>
<bean id="jmsTemplate"
class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref bean="connectionFactoryProxy" />
</property>
<property name="destinationResolver">
<ref bean="jmsDestinationResolver" />
</property>
<property name="receiveTimeout">
<value>50000</value>
</property>
</bean>
<!--Este es el bean donde no estoy segura de la implentación, pero igual trate eliminandolo y pasando el bean "jndiTemplateRemote" directamente en el bean "jmsTemplate" y obtuve el mismo error-->
<bean id="connectionFactoryProxy"
class="org.springframework.jms.connection.TransactionAwareConnectionFactoryProxy">
<constructor-arg ref="jndiTemplateRemote" />
</bean>
<bean id="jndiTemplateRemote"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>${example.example.wl.remote.jndi.name}</value>
</property>
<property name="lookupOnStartup" value="true" />
<property name="proxyInterface"
value="javax.jms.ConnectionFactory" />
</bean>
<bean id="jmsDestinationResolver"
class="org.springframework.jms.support.destination.JndiDestinationResolver">
<property name="jndiTemplate">
<ref bean="jndiTemplate" />
</property>
<property name="cache">
<value>true</value>
</property>
</bean>
<bean id="jndiTemplate"
class="org.springframework.jndi.JndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">${example.example.example.wl.remote.factory.initial}
</prop>
<prop key="java.naming.provider.url">${example.example.example.wl.remote.provider.url}
</prop>
<prop key="java.naming.security.principal">${example.example.example.wl.remote.credential.username}
</prop>
<prop key="java.naming.security.credentials">${example.example.example.wl.remote.credential.password}
</prop>
</props>
</property>
</bean>
In this bean file I also have remote connections to queues of type MQ. These connections do work.
This is the class I am basing myself on to make the implementation in beans and it is the one with which I have already managed to make the connection to the remote queue:
/**
* Clase de configuracion.
*/
@EnableJms
@Configuration
public class WLMessagingConfiguration {
/**
* bean que extrae la informacion del propertvi ies.
*/
@Autowired
CommonEnv commonEnv;
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public JndiObjectFactoryBean connectionFactory() {
JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean();
jndiObjectFactoryBean.setJndiTemplate(jndiTemplate());
jndiObjectFactoryBean.setJndiName(commonEnv.getProperty(Const.WL_JNDI));
return jndiObjectFactoryBean;
}
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public JndiTemplate jndiTemplate() {
JndiTemplate jndiTemplate = new JndiTemplate();
Properties jndiProps = new Properties();
jndiProps.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, commonEnv.getProperty(Const.WL_FACTORY));
jndiProps.setProperty(InitialContext.PROVIDER_URL, commonEnv.getProperty(Const.WL_PROVIDER));
jndiProps.setProperty(InitialContext.SECURITY_PRINCIPAL, commonEnv.getProperty(Const.WL_USERNAME));
jndiProps.setProperty(InitialContext.SECURITY_CREDENTIALS, commonEnv.getProperty(Const.WL_PASSWORD));
jndiTemplate.setEnvironment(jndiProps);
return jndiTemplate;
}
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public TransactionAwareConnectionFactoryProxy connectionFactoryProxy() {
return new TransactionAwareConnectionFactoryProxy((ConnectionFactory) connectionFactory().getObject());
}
@Bean(name = "wlJmsTemplate")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public JmsTemplate jmsTemplate() {
JmsTemplate template = new JmsTemplate();
template.setConnectionFactory(connectionFactoryProxy());
JndiDestinationResolver destinationResolver = new JndiDestinationResolver();
destinationResolver.setJndiTemplate(jndiTemplate());
destinationResolver.setCache(true);
template.setDestinationResolver(destinationResolver);
template.setReceiveTimeout(50000);
return template;
}
@Bean
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public DefaultJmsListenerContainerFactory containerFactory() {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(connectionFactoryProxy());
factory.setConcurrency(commonEnv.getProperty(Const.WL_CONCURRENCY));
JndiDestinationResolver destinationResolver = new JndiDestinationResolver();
destinationResolver.setJndiTemplate(jndiTemplate());
destinationResolver.setCache(true);
factory.setDestinationResolver(destinationResolver);
return factory;
}
}
The truth is that I have already been investigating everywhere, and the information I find is similar to what I have, but no matter how many times I have given it, I cannot solve it. If anyone has had this kind of situation, I would appreciate it if you could help me.
First of all, Thanks.
After several days getting different errors, I realized that it is really a "security" problem, well actually the solution I got was:
In addition to this, it is important to mention that I changed this bean in the following way.
Before:
After
Once this was done, it was possible to deposit in the Weblogic remote queue.