Posts Tagged ‘Weblogic’
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.
Short Tutorial: Migration from EJB Entity to Hibernate
Case
- let’s consider an EJB Bean AnimalBean, linked to a table JL_Animal
- let’s have a human understandable name for the Pojo, let’s say: Animal
- let an EJB entity have following finders:
[java]
* @ejb.finder
* signature = "Collection findByBirthDate(java.lang.Integer birthDate)"
* query = "SELECT OBJECT(o) FROM AnimalBean AS o WHERE o.birthDate = ?1"
*
* @ejb.finder
* signature = "Collection findByCountryAndBirthDate(java.lang.String from,java.lang.Integer birthDate)"
* query = "SELECT OBJECT(o) FROM AnimalBean AS o WHERE o.country = ?1 AND o.birthDate = ?2"[/java]
Read the rest of this entry »
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!
The domain edit lock is owned by another session in exclusive mode – hence this deployment operation cannot proceed
Error:
On trying to redeploy an application myFooApplication
on BEA WebLogic 9:
weblogic.management.ManagementException: [Deployer:149164]The domain edit lock is owned by another session in exclusive mode - hence this deployment operation cannot proceed.
Fix:
- Shutdown Weblogic instances (including administration application)
- Delete the lock files:
$WL_HOME/edit.lok
$WL_HOME/servers/myFooApplication/tmp/myFooApplication.lok
weblogic.management.ManagementException: Unable to obtain lock
Exception:
weblogic.management.ManagementException: Unable to obtain lock on /$HOME/.../myDomain/tmp/myServer.lok. Server may already be running at weblogic.management.internal.ServerLocks.getServerLock(ServerLocks.java:159) at weblogic.management.internal.ServerLocks.getServerLock(ServerLocks.java:58) at weblogic.management.internal.DomainDirectoryService.start(DomainDirectoryService.java:75) at weblogic.t3.srvr.ServerServicesManager.startService(ServerServicesManager.java:374) at weblogic.t3.srvr.ServerServicesManager.startInStandbyState(ServerServicesManager.java:125) at weblogic.t3.srvr.T3Srvr.initializeStandby(T3Srvr.java:630) at weblogic.t3.srvr.T3Srvr.startup(T3Srvr.java:402) at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:361) at weblogic.Server.main(Server.java:67)
Fix:
- If possible, ensure you have admin rights
- else:
- delete
/$HOME/.../myDomain/cache
- delete
/$HOME/.../myDomain/data/ldap/ldapfiles/*.lok
- delete
/$HOME/.../myDomain/data/stores/diagnostics/*
- delete
/$HOME/.../myDomain/data/stores/default/*
- delete
/$HOME/.../myDomain/tmp/*.lok
- delete
XAException: JDBC driver does not support XA, hence cannot be a participant in two-phase commit
Error:
MyStrutsAction - Error on uploading: MyPersonnalClass@971720[primaryId=<null>,type=XXX,myDate=20080702,entityId=<null>,optimisticTimestamp=<null>] org.springframework.remoting.RemoteAccessException: Could not access remote service [my-service-bean]; nested exception is javax.transaction.TransactionRolledbackException: BEA1-0F416BB49A8BE6353E83: javax.transaction.xa.XAException: JDBC driver does not support XA, hence cannot be a participant in two-phase commit. To force this participation, set the GlobalTransactionsProtocol attribute to LoggingLastResource (recommended) or EmulateTwoPhaseCommit for the Data Source = myDatasource
Fix:
- Go on WebLogic console
- Then follow the pages: Home > Summary of JDBC Data Sources > myDatasource > Transactions
- Uncheck:
One-Phase Commit
- Check:
Emulate Two-Phase Commit
NoClassDefFoundError: com/sun/corba/se/connection/ORBSocketFactory
Error
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsQueueConnectionFactory' defined in class path resource MyResourceApplicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/sun/corba/se/connection/ORBSocketFactory
Fix: In the classpath, replace Weblogic 8.X
jars with Weblogic 9.2
jars