Results 1 to 5 of 5

Thread: MessageDrivenPOJO's and Websphere MQ - help required

  1. #1

    Default MessageDrivenPOJO's and Websphere MQ - help required

    Hello

    A third party are sending text data through websphere mq into one of two queues. I am charged with retrieving the data and loading it into an oracle database.

    With this in mind I have opened a discourse elesewhere on the forum and have reached a given point - special thanks to Lyserg, any mistakes in my code are entirely my own and are probably to do with me not understanding properly.

    Anyway.......

    I have created an interface like so....

    Code:
    public interface TextMessageDelegate {
        void onMessage(String text);
     }
    which is implemented in the following...

    Code:
    public class A2OCardMessage implements TextMessageDelegate
    {
    	public void onMessage(String cardMessage) {
    		
    		try {
    			// TODO put in the stored procedure stuff here....
    			System.out.println(cardMessage);	
    		}catch (RuntimeException e){
    			e.printStackTrace();
    		}
    	}
    }
    This, I believe is pretty much the sum total of what I require to get the data back, the devil being the the config....

    My applicationcontext looks like so......

    Code:
    <beans>
    
    	<!-- MQ definitions -->
    	<bean id="messageBean" class="appl.message.A2OCardMessage">
    
    	</bean>
    
    	<bean id="listener" class="org.springframework.jms.listener.adapter.MesssageListenerAdapter">
    		<property name="delegate" ref="messageBean"/>
    	</bean>
    
    	<bean id="container" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    		<property name="connectionFactory" ref="connectionFactory"/>
    		<property name="messageListener" ref="listener"/>
    		<property name="destination" ref="requestQueue"/>
    	</bean>
    	
    	<bean id="requestQueue" class="com.ibm.mq.jms.MQQueue" depends-on="connectionFactory">
    		<property name="baseQueueManagerName" value="ECSTHP01"/>
    		<property name="baseQueueName" value="A2O.EXP.CARD.SIT"/>
    		<property name="targetClient" value="1"/>
    		<property name="persistence" value="-1"/>
    	</bean>
    	
    	<bean id="connectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
    		<property name="queueManager" value="ECSTHP01"/>
    		<property name="transportType" value="1"/>
    	</bean>
    
    	<!-- database definitions -->
    	<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="java:comp/env/jdbc/a2o"/>
    	</bean>
    		
    	<bean id="lwsSessionFactory"
    		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="dataSource">
    			<ref local="dataSource" />
    		</property>
     		<property name="hibernateProperties"> 
    			<props>
    				<prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
    				<prop key="hibernate.show_sql">true</prop>
    				<prop key="hibernate.c3p0.minPoolSize">10</prop>
    				<prop key="hibernate.c3p0.maxPoolSize">20</prop>
    				<prop key="hibernate.c3p0.timeout">600</prop>
    				<prop key="hibernate.c3p0.max_statement">10</prop>
    				<prop key="hibernate.generate_statistics">true</prop>
    				<prop key="hibernate.cache.use_query_cache">true</prop>
    			</props>
    		</property>
    	</bean>
    	
    </beans>
    and web.xml has been amended to show like so.....

    Code:
    <web-app id="WebApp_ID" version="2.4"
    	xmlns="http://java.sun.com/xml/ns/j2ee"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    	<display-name>Display Name</display-name>
    
    	<context-param>
    	  <param-name>contextConfigLocation</param-name>
    	  <param-value>applicationContext.xml</param-value>
    	</context-param>
    
    	<listener>
    	  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener>
    
    	<session-config>
    		<!-- Default to 5 minute session timeouts -->
    		<session-timeout>5</session-timeout>
    	</session-config>
    
    	<welcome-file-list>
    		<welcome-file>index.html</welcome-file>
    	</welcome-file-list>
    
    	<resource-ref>
    		<description>Oracle</description>
    		<res-ref-name>jdbc/a2o</res-ref-name>
    		<res-type>javax.sql.DataSource</res-type>
    		<res-auth>Container</res-auth>
    		<res-sharing-scope>Shareable</res-sharing-scope>
    	</resource-ref>
    
    </web-app>
    I have an ant build file like so.....to create a .ear file for deploying in websphere

    Code:
    <project name="A2OMQCard_Build" default="build_full" basedir=".">
    		
    	<property name="webapp" value="${basedir}/jardir" />
    	<property name="base" value="A2OMQCardInterface" />
    	<property name="javaSource" value="${basedir}/src" />
    	<property name="webSource" value="${basedir}/WebContent" />
    	
    	<fileset dir="${webSource}/WEB-INF/lib" id="libs">
    		<include name="com.ibm.mq.jar" />
    		<include name="com.ibm.mqbind.jar" />
    		<include name="com.mq.mqjms.jar" />
    		<include name="commons-logging" />
    		<include name="connector.jar" />
    		<include name="dhbcore.jar" />
    		<include name="fscontext.jar" />
    		<include name="jms.jar" />
    		<include name="jmscommon.jar" />
    		<include name="jndi.jar" />
    		<include name="jta.jar" />
    		<include name="ldap.jar" />
    		<include name="log4j-1.2.11.jar" />
    		<include name="ojdbc14.jar" />
    		<include name="providerutil.jar" />
    		<include name="rmm.jar" />
    		<include name="spring.jar" />
    	</fileset>
    
    	
    	<!-- Production Build -->
    	<target name="build_full" depends="javac_src,support_files,create_war">
    		<ear destfile="${base}.ear" appxml="${basedir}/EarContent/META-INF/application.xml">
    			<fileset dir="${basedir}" includes="*.war" />
    		</ear>
    	</target>
    
    	<target name="support_files" depends="setup">
    		<copy todir="${webapp}/META-INF">
    			<fileset dir="${webSource}/META-INF" />
    		</copy>
    		<copy todir="${libDir}">
    			<fileset id="libs" dir="${webSource}/WEB-INF/lib"/>
    		</copy>
    
    		<copy file="${webSource}/WEB-INF/web.xml" todir="${webapp}/WEB-INF" />
    		<copy todir="${webapp}/WEB-INF/classes">
    			<fileset dir="${basedir}/src">
    				<include name="*.xml" />
    				<include name="*.properties" />
    			</fileset>
    		</copy>
    		<copy todir="${webapp}/WEB-INF/classes/appl/business">
    			<fileset dir="${basedir}/src/appl/business">
    				<include name="*.xml" />
    				<include name="*.properties" />
    			</fileset>
    		</copy>
    
    	</target>
    
    	<!-- set global properties for this build -->
    	<target name="setup" if="webapp">
    		<property name="sourceDir" value="${basedir}/src" />
    		<property name="utilsDir" value="${webapp}/WEB-INF/utils" />
    		<property name="outputDir" value="${webapp}/WEB-INF/classes" />
    		<property name="libDir" value="${webapp}/WEB-INF/lib" />
    		<mkdir dir="${webapp}" />
    		<mkdir dir="${sourceDir}" />
    		<mkdir dir="${utilsDir}" />
    		<mkdir dir="${outputDir}" />
    		<mkdir dir="${libDir}" />
    	</target>
    
    	<!-- Clean all directories -->
    	<target name="clean">
    		<delete failonerror="false" description="clean up">
    			<fileset file="${base}.war" />
    			<fileset file="${base}.ear" />
    			<fileset file="${webapp}/*.jsp" />
    			<fileset file="${webapp}/WEB-INF/web.xml" />
    			<fileset dir="${webapp}/WEB-INF/classes" />
    			<fileset dir="${webapp}/WEB-INF/utils" />
    			<fileset dir="${webapp}/WEB-INF/src" />
    			<fileset file="${webapp}/WEB-INF/lib/*.*" />
    		</delete>
    	</target>
    
    	<!-- Set the javac classpath -->
    	<path id="compile.classpath">
    		<fileset id="libs" dir="${webSource}/WEB-INF/lib"/>
    	</path>
    
    	<target name="javac_src" depends="setup" description="compile the src ">
    		<javac srcdir="${sourceDir}" destdir="${outputDir}" source="1.4">
    			<classpath refid="compile.classpath" />
    		</javac>
    	</target>
    
    	<!-- Package the files into a Web Application -->
    	<target name="create_war" if="webapp" description="build the war file ">
    		<jar destfile="${base}.war" basedir="${webapp}" defaultexcludes="yes">
    			<exclude name="**/lib/*"/>
    		</jar>
    	</target>
    
    </project>

    Firstly could someone quickly run an eye over what I have done to confirm if I am on the right tracks..and secondly when I deploy the .ear file I am getting the following error.....

    Code:
    AppDeploymentException: [null] com.ibm.etools.j2ee.commonarchivecore.exception.DeploymentDescriptorLoadException: IWAE0022E Exception occurred loading deployment descriptor for module "A2OMQInterface.war" in EAR file "/hosting/configs/WebSphereD01/DeploymentManager/profiles/Dmgr_CD01/wstemp/0/upload/A2OMQCardInterface.ear"

    Could someone help me to sort this out....

    Thanks in advance

  2. #2
    Join Date
    Nov 2006
    Location
    Germany
    Posts
    452

    Default

    Hi,

    your way is the right one. To run the application in you application server you should use JMS Quees that are defined as Ressources inside the application server (to make connection/session pooling easier).
    Also you have to configure the workmanager like i explain before.

    If you want to use transaction between your messaging system and the oracle database, then you have to use the Websphere JTA Transaction Manager.

    AppDeploymentException: [null] com.ibm.etools.j2ee.commonarchivecore.exception.De ploymentDescriptorLoadException: IWAE0022E Exception occurred loading deployment descriptor for module "A2OMQInterface.war" in EAR file "/hosting/configs/WebSphereD01/DeploymentManager/profiles/Dmgr_CD01/wstemp/0/upload/A2OMQCardInterface.ear"
    If you are deploying an servlet 2.3 App in the Websphere 6.0 then you should have a look here

    http://www-1.ibm.com/support/docview...id=swg1PQ98556

    Your best friend google found lots on stuff while googling for "IWAE0022E"

    Regards
    lyserg

  3. #3
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,842

    Default

    It also looks like you will need to provide a 'defaultListenerMethod' property on your MesssageListenerAdapter bean definition. The value would be 'onMessage' (the method of your delegate bean). Otherwise, the built-in default is 'handleMessage'. Another option of course would be to change the method name in your TextMessageDelegate.

  4. #4

    Default

    I have found the issue with the deployment and, as expected, it was entirely an error of mine - thanks
    Last edited by rowens; Apr 5th, 2007 at 03:44 AM.

  5. #5

    Default

    I have deployed the app in websphere. However I have now encountered the following error....

    Code:
    [4/5/07 14:06:31:624 BST] 0000006a ContextLoader E org.springframework.web.context.ContextLoader initWebApplicationContext Context initialization failed
                                     org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'container' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError
    Caused by: java.lang.NoClassDefFoundError
    	at com.ibm.mq.MQSESSIONServer.getMQSESSION(MQSESSIONServer.java:68)
    	at com.ibm.mq.MQSESSION.getSession(MQSESSION.java:493)
    	at com.ibm.mq.MQManagedConnectionJ11.<init>(MQManagedConnectionJ11.java:155)
    	at com.ibm.mq.MQBindingsManagedConnectionFactoryJ11._createManagedConnection(MQBindingsManagedConnectionFactoryJ11.java:153)
    	at com.ibm.mq.MQBindingsManagedConnectionFactoryJ11.createManagedConnection(MQBindingsManagedConnectionFactoryJ11.java:189)
    	at com.ibm.mq.StoredManagedConnection.<init>(StoredManagedConnection.java:80)
    	at com.ibm.mq.MQSimpleConnectionManager.allocateConnection(MQSimpleConnectionManager.java:171)
    	at com.ibm.mq.MQQueueManager.obtainBaseMQQueueManager(MQQueueManager.java:754)
    	at com.ibm.mq.MQQueueManager.construct(MQQueueManager.java:688)
    	at com.ibm.mq.MQQueueManager.<init>(MQQueueManager.java:469)
    	at com.ibm.mq.MQSPIQueueManager.<init>(MQSPIQueueManager.java:52)
    	at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:2248)
    	at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnection.java:1749)
    	at com.ibm.mq.jms.MQQueueConnection.<init>(MQQueueConnection.java:144)
    	at com.ibm.mq.jms.MQQueueConnection.<init>(MQQueueConnection.java:54)
    	at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:106)
    	at com.ibm.mq.jms.MQQueueConnectionFactory.createConnection(MQQueueConnectionFactory.java:954)
    	at org.springframework.jms.listener.AbstractMessageListenerContainer.createConnection(AbstractMessageListenerContainer.java:993)
    	at org.springframework.jms.listener.AbstractMessageListenerContainer.refreshSharedConnection(AbstractMessageListenerContainer.java:459)
    	at org.springframework.jms.listener.DefaultMessageListenerContainer.establishSharedConnection(DefaultMessageListenerContainer.java:589)
    	at org.springframework.jms.listener.AbstractMessageListenerContainer.initialize(AbstractMessageListenerContainer.java:418)
    	at org.springframework.jms.listener.DefaultMessageListenerContainer.initialize(DefaultMessageListenerContainer.java:386)
    	at org.springframework.jms.listener.AbstractMessageListenerContainer.afterPropertiesSet(AbstractMessageListenerContainer.java:399)
    	at org.springframework.jms.listener.DefaultMessageListenerContainer.afterPropertiesSet(DefaultMessageListenerContainer.java:352)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1057)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1024)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:421)
    	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
    	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:140)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
    	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:273)
    	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
    	at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
    	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
    	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
    	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
    	at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1403)
    	at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:396)
    	at com.ibm.ws.webcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:115)
    	at com.ibm.ws.webcontainer.VirtualHost.addWebApplication(VirtualHost.java:128)
    	at com.ibm.ws.webcontainer.WebContainer.addWebApp(WebContainer.java:924)
    	at com.ibm.ws.webcontainer.WebContainer.addWebApplication(WebContainer.java:877)
    	at com.ibm.ws.runtime.component.WebContainerImpl.install(WebContainerImpl.java:167)
    	at com.ibm.ws.runtime.component.WebContainerImpl.start(WebContainerImpl.java:391)
    	at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1228)
    	at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1067)
    	at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:547)
    	at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:751)
    	at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:892)
    	at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:1412)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:324)
    	at javax.management.modelmbean.RequiredModelMBean.invokeMethod(RequiredModelMBean.java:1366)
    	at javax.management.modelmbean.RequiredModelMBean.invoke(RequiredModelMBean.java:1012)
    	at mx4j.server.interceptor.InvokerMBeanServerInterceptor.invoke(InvokerMBeanServerInterceptor.java:233)
    	at mx4j.server.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:128)
    	at mx4j.server.interceptor.SecurityMBeanServerInterceptor.invoke(SecurityMBeanServerInterceptor.java:86)
    	at mx4j.server.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:128)
    	at mx4j.server.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:128)
    	at mx4j.server.interceptor.ContextClassLoaderMBeanServerInterceptor.invoke(ContextClassLoaderMBeanServerInterceptor.java:167)
    	at mx4j.server.MX4JMBeanServer.invoke(MX4JMBeanServer.java:1249)
    	at com.ibm.ws.management.AdminServiceImpl$1.run(AdminServiceImpl.java:990)
    	at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
    	at com.ibm.ws.management.AdminServiceImpl.invoke(AdminServiceImpl.java:906)
    	at com.ibm.ws.management.connector.AdminServiceDelegator.invoke(AdminServiceDelegator.java:157)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:324)
    	at com.ibm.ws.management.connector.soap.SOAPConnector.invoke(SOAPConnector.java:345)
    	at com.ibm.ws.management.connector.soap.SOAPConnector.service(SOAPConnector.java:212)
    	at com.ibm.ws.management.connector.soap.SOAPConnection.handleRequest(SOAPConnection.java:55)
    	at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:680)
    	at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:484)
    	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1470)
    
    [4/5/07 14:06:31:661 BST] 0000006a WebApp        E   Error creating bean with name 'container' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError
    Just to add some background - I am using transportType = 0 rather than 1 as need to use bindings as we are unable to run listeners on the MQ instance we have from the application server.

    Does anyone know if there are further config factors that need to be addressed when using bindings?
    Last edited by rowens; Apr 5th, 2007 at 09:19 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •