How to configure Jboss EAP7.0 WorkManager in Spring 4.2 - spring

I am trying to implement the jca based jms in spring with Jboss EAP 7.0 and below are my configuration.
<bean class="org.jboss.resource.adapter.jms.JmsResourceAdapter" id="jbossResourceAdapter"/>
<bean id="messageHubTaskExecuter" class="org.springframework.jca.work.WorkManagerTaskExecutor">
<property name="workManager" value="wm/default"/>
</bean>
<bean id="jbossResourceAdapterFactory" class="org.springframework.jca.support.ResourceAdapterFactoryBean">
<property name="resourceAdapter" ref="jbossResourceAdapter"/>
<property name="workManager" ref="messageHubTaskExecuter"/>
</bean>
I got the below exception
Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: wm/default -- service jboss.naming.context.java.wm.default
Caused by: javax.naming.NameNotFoundException: wm/default -- service jboss.naming.context.java.wm.default"}}
Please let me know how to get the work manager instance in spring 4.2 from Jboss EAP 7.0
Thanks much.

Related

JNDI lookup failure

i would be grateful if someone can help me rectify the issue in my code. Not sure where I'm going wrong.
Currently my persistence.xml contains
<property name="hibernate.transaction.manager_lookup_class" value="#####.hibernate.JbossTSTransactionManagerLookup"/>
<property name="hibernate.current_session_context_class" value="jta"/>
along with
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="####"/>
<property name="jpaDialect" ref="jpaDialect"/>
</bean>
<bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
<property name="transactionManagerName" value="java:comp/env/TransactionManager"/>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
Context initialization failed : org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [###XMLConfig.xml]: Invocation of init method failed; nested exception is org.springframework.transaction.TransactionSystemException: JTA TransactionManager is not available at JNDI location [java:comp/env/TransactionManager]; nested exception is org.springframework.jndi.TypeMismatchNamingException: Object of type [class com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple] available at JNDI location [java:comp/env/TransactionManager] is not assignable to [javax.transaction.TransactionManager]
Caused by: org.springframework.transaction.TransactionSystemException: JTA TransactionManager is not available at JNDI location [java:comp/env/TransactionManager]; nested exception is org.springframework.jndi.TypeMismatchNamingException: Object of type [class com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple] available at JNDI location [java:comp/env/TransactionManager] is not assignable to [javax.transaction.TransactionManager]
at org.springframework.transaction.jta.JtaTransactionManager.lookupTransactionManager(JtaTransactionManager.java:598)
Caused by: org.springframework.jndi.TypeMismatchNamingException: Object of type [class com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionManagerImple] available at JNDI location [java:comp/env/TransactionManager] is not assignable to [javax.transaction.TransactionManager] at org.springframework.jndi.JndiTemplate.lookup()
at org.springframework.transaction.jta.JtaTransactionManager.lookupTransactionManager()
Looks like there is some issue with the classpath of your project. Check if there are two versions of the same dependency in your project. In my case I had multiple versions of the jboss-transaction jar in the classpath, keeping just one version of it fixed the issue for me. Check if there is any transitive dependency which is causing this issue which you can exclude in your maven pom.

Trying to deploy a Spring Service on WSO2 Application Service

I'm trying to deploy a Spring Service in WSO2 Application Service. I did THIS tutorial and the app works fine on Eclipse, but when I try to deploy it on WSO2 I get this error:
Cannot load Spring beans. Please check the Spring context
configuration file and verify that the defined Spring beans exist in
the .jar file.
I unziped de .jar file and JdbcCustomerDAO class is there with all the others.
Spring context:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="customerDAO" class="com.mkyong.customer.dao.impl.JdbcCustomerDAO">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="url" />
<property name="username" value="username" />
<property name="password" value="password" />
</bean>
</beans>
I also tried to include spring and mysql-connector-java jars on /repository/components/extensions as says HERE.
EDIT:
ERROR {org.wso2.carbon.springservices.ui.SpringServiceMaker} - Cannot
load Spring beans. Please check the Spring context configuration file
and verify that the defined Spring beans exist in the .jar file.
{org.wso2.carbon.springservices.ui.SpringServiceMaker}
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot
find class
[org.springframework.jdbc.datasource.DriverManagerDataSource] for bean
with name 'dataSource' defined in resource loaded through InputStream;
nested exception is java.lang.ClassNotFoundException:
org.springframework.jdbc.datasource.DriverManagerDataSource
Looks like it couldn't find spring-jdbc, so I added the jar to extensions but now I get this error:
ERROR {org.wso2.carbon.springservices.ui.SpringServiceMaker} - Cannot load
Spring beans. Please check the Spring context configuration file and
verify that the defined Spring beans exist in the .jar file.
{org.wso2.carbon.springservices.ui.SpringServiceMaker}
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'dataSource' defined in resource loaded
through InputStream: Instantiation of bean failed; nested exception is
org.springframework.beans.BeanInstantiationException: Could not
instantiate bean class
[org.springframework.jdbc.datasource.DriverManagerDataSource]:
Constructor threw exception; nested exception is
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
I understand that commons.logging is also missing, but when I try to add it to extensions, WSO2 doesn't start. I get a lot of
Log4j:ERROR Could not instantiate...

EJB remote call from standalone client to JBoss server is not working in Multi threading

I am using spring container in a batch operation that realize many calls to an remote EJB. When the operation is single-thread everything works fine but when try to use multi-threading to gain performance it throws:
Exception in thread "taskExecutor-1" javax.ejb.EJBException: java.io.IOException: Channel Channel ID e9c80c0d (outbound) of Remoting connection 18f42160 to servername/ip:port has been closed
My stand-alone cliente dependecy is:
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ejb-client-bom</artifactId>
<type>pom</type>
<version>7.2.0.Final</version>
</dependency>
I'm also using spring's SimpleRemoteStatelessSessionProxyFactory to inject the lookup beans
<bean id="jndiProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="file:/path/jboss-ejb-client.properties" />
</bean>
<bean id="jndiTemplate" class="org.springframework.jndi.JndiTemplate">
<property name="environment" ref="jndiProperties" />
</bean>
<bean id="operation" class="org.springframework.ejb.access.SimpleRemoteStatelessSessionProxyFactoryBean">
<property name="jndiName" value="ejb:remote/interface/location" />
<property name="jndiTemplate" ref="jndiTemplate" />
<property name="businessInterface" value="com.MyBussinesInterfae" />
</bean>
In my tests I verified that if a Thread-A creates the InitContext and does the JNDI EJB lookup and creates the instance of the EJB remote inferface (under the SRSSPFBean) it can invoke methods via the EJB remote interface, but if an Thread-B gets the reference of the EJB remote interface and tries to invoke a method the exception is thrown.
The only similiar problem found on my search is here and seems related to bugs on Jboss AS 7. I am using Jboss eap 6.2.
Thanks in advance for any help.

How to do jndi lookup of MQ connection factory defined in Websphere app Server from Spring

I am trying to connect to a MQ connection factory defined in Websphere app Server 7.0.
But I couldnt find a right connectionfactory interface for the MQ to define in Spring.
However when I tried to hardcode the connection details in the spring config file, I am able to connect to the Queue Manager.
What is the right interface/format to use in Spring beans to load the MQ connection factory defined in Websphere appl server?
Working Code
<bean id="mqConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="hostName">
<value>127.0.0.1</value>
</property>
<property name="port">
<value>1414</value>
</property>
<property name="queueManager">
<value>MYQM</value>
</property>
<property name="transportType">
<value>1</value>
</property>
</bean>
Not Working Code
<bean id="mqConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="jms/WASQM"/>
<property name="lookupOnStartup" value="false"/>
<property name="cache" value="true" />
<property name="proxyInterface" value="com.ibm.mq.jms.MQQueueConnectionFactoryFactory" />
</bean>
where WASQM is the MQ connection factory defined in Websphere
Error with the Non working code
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mqConnectionFactory' defined in ServletContext resource [/WEB-INF/config/config-mq.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: [com.ibm.mq.jms.MQQueueConnectionFactoryFactory] is not an interface
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
Caused by: java.lang.IllegalArgumentException: [com.ibm.mq.jms.MQQueueConnectionFactoryFactory] is not an interface
I need help in replacing the not working code with a right code.
Spring - 3.0.5
IBM MQ and Web App Servers - 7.0
Right way to do is
Create the resource in Queue Connection Factory in Websphere App Server (not in Connection Factory)
Use javax.jms.QueueConnectionFactory as the connection factory in spring config
<bean id="mqConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="WASQM"/>
<property name="lookupOnStartup" value="false"/>
<property name="cache" value="true" />
<property name="proxyInterface" value="javax.jms.QueueConnectionFactory" />
</bean>
This page gave me the hint.

Mule ESB - does the lib override any application library

I have used Mule Studio 3.2.1 to develop a Mule application. Within that application I have used org.springframework.ws.client.core.WebServiceTemplate to send a Webservice request to another application.
I have used the following config
<bean id="myWsTemplate" clsass="org.springframework.ws.client.core.WebServiceTemplate">
<constructor-arg ref="messageFactory" />
<property name="defaultUri" value="${my.soap.endpoint}" />
<property name="interceptors">
<list>
<ref bean="acqSecurityInterceptor" />
</list>
</property>
<bean id="acqSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
<property name="validationActions" value="NoSecurity"/>
<property name="securementActions" value="NoSecurity" />
</bean>
I have used Maven dependency of
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-security</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
This uses wss4j-1.6.5.jar as a dependency.
Now when I deploy the application in Mule 3.2.0 it throws the following error
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'validationActions' threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.ws.security.util.WSSecurityUtil.decodeAction(Ljava/lang/String;Ljava/util/List;)I
PropertyAccessException 2: org.springframework.beans.MethodInvocationException: Property 'securementActions' threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.ws.security.util.WSSecurityUtil.decodeAction(Ljava/lang/String;Ljava/util/List;)I
Now the lib/opt directory of Mule 3.2.0 comes with wss4j-1.5.8-osgi.jar for which the the method signature on WSSecurityutil is public static int decodeAction(String action, Vector actions)
while the one that has been attempted is
decodeAction(Ljava/lang/String;Ljava/util/List;) which is present in wss4j.1.6.5
My question is even if my app has the wss4j-1.6.5.jar in it why is the classloader still trying to use the one in mule/lib/opt. Should the one in the app not override of take precedence?
If not is there a way to get it work that way
ok using the following config in mule-deploy.properties helped
loader.override=-org.apache.ws.security.util.WSSecurityUtil
ref
http://www.mulesoft.org/documentation/display/MULE3USER/Classloader+Control+in+Mule
but still loads of issues with jars coming built in Mule Studio as plugins and then trying to deploy in standalone Mule. Will create an assorted list of such issues in another thread.

Resources