2

I have a requirement to configure JBoss WorkManager in my application. Earlier the configuration was as follows:

<bean id="taskExecutor" class="org.springframework.scheduling.commonj.WorkManagerTaskExecutor">
    <property name="workManagerName" value="wm/default" />
</bean>

The clas "WorkManagerTaskExecutor" is intended for WebSphere and WebLogc. But we are migrating our application from WebSphere to JBOss. So I have the following configuration.

web.xml

<resource-ref id="ResourceRef_1163654014164">
<description>WorkManager</description>
<res-ref-name>WorkManager</res-ref-name>
<res-type>org.jboss.resource.work.JBossWorkManager</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref> 

jboss-web.xml

<resource-ref id="ResourceRef_1163654014164">
<description>WorkManager</description>
<res-ref-name>WorkManager</res-ref-name> 
<jndi-name>WorkManager</jndi-name>
<ignore-dependency/>
</resource-ref>

applicationContext.xml

<bean id="taskExecutor"     class="org.springframework.jca.work.jboss.JBossWorkManagerTaskExecutor">     
</bean>

Exception Log:

17:04:39,472 ERROR [LogInterceptor] 

EJBException in method: public abstract com.test.ejb.timer.SLATimer com.test.ejb.timer.SLATimerHome.create() throws javax.ejb.CreateException,java.rmi.RemoteException, causedBy:
org.springframework.beans.factory.BeanCreationException

: Error creating bean with name 'taskExecutor' defined in class path resource [spring-messaging.xml]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Could not initialize JBossWorkManagerTaskExecutor because JBoss API is not available: 

java.lang.reflect.InvocationTargetException
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean    (AbstractAutowireCapableBeanFactory.java:1420)

Caused by: java.lang.IllegalStateException: Could not initialize JBossWorkManagerTaskExecutor because JBoss API is not available: 

java.lang.reflect.InvocationTargetException

Please help to fix the above issue.

Thanks

chaatna
  • 61
  • 3
  • 9

2 Answers2

1

I am answering my question myself which may be helpful for somebody.

Removed configuration in web.xml and jboss.web.xml for this JBoss Work Manager.

Have the following configuration in applicationContext.xml

<bean id="jbossResourceAdapter" class="org.jboss.resource.adapter.jms.JmsResourceAdapter"/>

<bean id="mbeanServer" class="org.jboss.mx.util.MBeanServerLocator" factory-method="locateJBoss"/>

<bean id="chanduWorkManager" factory-bean="mbeanServer" factory-method="getAttribute">
    <constructor-arg>
        <bean class="org.springframework.jmx.support.ObjectNameManager" factory-method="getInstance">
            <constructor-arg value="jboss.jca:service=ChanduWorkManager" />
        </bean>
    </constructor-arg>
    <constructor-arg value="Instance" />
</bean>

<bean id="taskExecutor" class="org.springframework.jca.work.WorkManagerTaskExecutor">
    <property name="workManager" ref="chanduWorkManager"/>
</bean>

<bean id="jbossResourceAdapterFactory" class="org.springframework.jca.support.ResourceAdapterFactoryBean">
    <property name="resourceAdapter" ref="jbossResourceAdapter"/>
    <property name="workManager" ref="taskExecutor"/>
</bean>

<bean id="jbossActivationSpecFactory" class="org.springframework.jms.listener.endpoint.StandardJmsActivationSpecFactory">
    <property name="activationSpecClass" value="org.jboss.resource.adapter.jms.inflow.JmsActivationSpec"/>
    <property name="defaultProperties">
        <props>
            <prop key="sessionTransacted">false</prop>
            <prop key="minSession">1</prop>
            <prop key="maxSession">15</prop>
        </props>
    </property>
</bean>

Hope it will help somebody. Thanks, Chandrasekhar Aadhanapattu

chaatna
  • 61
  • 3
  • 9
0

Find this may be the right answer....

In my case also AS is JBoss...

Spring WorkManagerTaskExecutor cannot initialize in websphere

Community
  • 1
  • 1
Dev Anand Sadasivam
  • 699
  • 7
  • 21
  • 49