Recent Posts
Archives

Posts Tagged ‘JMS’

PostHeaderIcon java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[myRole]

Short stacktrace:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myJmsTemplate' (...) Invocation of init method failed; nested exception is java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[myRole]

Complete stacktrace

(copy paste in a text editor if the complete stack is not displayed in your browser):

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myJmsTemplate' defined in URL [zip:C:/workarea/development/servers/wl_server/servers/XXXX/tmp/_WL_user/XXXXXXXXXXXX-ear/7gtxm8/XXXXXXXX-services-ejb.jar!/com/XXXXX/businessApplicationContext-XXXXXXXX.xml]: Cannot resolve reference to bean 'myJmsQueueConnectionFactory' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myJmsQueueConnectionFactory' defined in URL [zip:C:/workarea/development/servers/wl_server/servers/ejbtier/tmp/_WL_user/XXXXXX-ear/7gtxm8/XXXXXXXX.jar!/com/bnpparibas/primeweb/businessApplicationContextXXXXXXXXXXXX.xml]: Invocation of init method failed; nested exception is java.lang.SecurityException: [Security:090398]Invalid Subject: principals=[myRole]
 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)
 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
 at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
 at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)
(...)

The issue appears when I try to deploy an EJB sending JMS messages from my Weblogic server, to another one, in another domain.

Fix:

  • I have not fixed the issue myself, I gave pieces of advice to the teams in charge of solving them. But I assume following guidelines are OK.
  • Indeed there are two issues: one on credentials and another on servers
  • Servers need trust each other. More information is available here. I assume trust is granted thanks to the use of certificates.
  • On another hand, credentials from my server, it is to say here “myRole” must be accepted by distant Ldap juridiction. I assume that distant EJB environment must something like:
    • distantEnvironment.put(InitialContext.SECURITY_PRINCIPAL, "myRole");

Now it should work!

PostHeaderIcon Deploy a JMS destination queue with Spring

Abstract

Case: we have to send JMS messages to a third-party server, using Spring. Of course, we have to discriminate production, UAT and developments environments. We can decide to use one Spring configuration file per environment, but it is complex to maintain.

Here is the way I proceded:

Declare the factory

[xml]<bean id="myJmsQueueConnectionFactory">
<property name="jndiName" value="my.jms.QueueConnectionFactory"/>
<property name="jndiTemplate" ref="myJmsJndiTemplate"/>
</bean>[/xml]

Declare a Jndi Template

[xml]<bean id="myJmsJndiTemplate">
<property name="environment">
<props>
<prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop>
<prop key="java.naming.provider.url"><strong>${my.jms.host}</strong></prop>
</props>
</property>
</bean>[/xml]
The variable ${my.jms.host} is used to indicate the actual destination host. The value is given in a property file myConfig.properties, for instance:

my.jms.host=t3://127.0.0.1:1234

Obviously, each environnement needs its ad hoc property file!

Declare a JMS Template

It gathers the factory and the queue name.
[xml]<bean id="myJmsTemplate">
<property name="connectionFactory" ref="myJmsQueueConnectionFactory"/>
<property name="defaultDestination" ref="myJmsQueue"/>
</bean>[/xml]

Declare the destination queue

[xml]<bean id="myJmsQueue">
<property name="jndiName" value="my.jms.destination.queue.name"/>
</bean>[/xml]

Ensure the property file is in classpath

[xml]<bean id="conf">
<property name="locations">
<list>
<value>classpath*:myConfig.properties</value>
</list>
</property>
</bean>[/xml]
Restart WebLogic, deploy your EAR. Now it should work!

Notice: in case you’re not sure the distant host is up or not, you may add this attribute to your beans: lazy-init="true"

PostHeaderIcon weblogic.jms.common.MessageFormatException: JMSClientExceptions: Invalid property name, “my-personnal-id”

Error:

weblogic.jms.common.MessageFormatException: JMSClientExceptions: Invalid property name, "my-personnal-id"

Fix:

Rename the property as myPersonalId for instance. Indeed, owing to JMS specification, properties on JMS messages must be written in alphanumeric characters. Therefore, hyphen '-' and periods '.' are forbidden.