1
I was written a simple MessageListener(MDB) it is working fine.How to handle runtime exceptions in this.

[Ex: if was try to deploy this listener with a wrong queue name like "XXXX" instead of right one that time it is showing Exceptions and moreover deployment failure also coming.]

So how to avoid this type of Exceptions is there any Annotations are available.

And I tried to handle inside the below Class(ORANGE_QUEUE_MDB). But the control is not coming to inside . Please help me how to solve this type of Errors.

@MessageDriven(name="WEBSPHERE_MDB",
        activationConfig = {  

                            @ActivationConfigProperty(propertyName="messagingType",propertyValue="javax.jms.MessageListener"),
                            @ActivationConfigProperty(propertyName = "destinationType",propertyValue = "javax.jms.Queue"),
                            @ActivationConfigProperty(propertyName = "destination", propertyValue = "ORANGE.QUEUE"),
                            @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),
                            @ActivationConfigProperty(propertyName = "channel", propertyValue = "SYSTEM.DEF.CONN"),
                            @ActivationConfigProperty(propertyName = "hostName", propertyValue = "192.168.22.29"),
                            @ActivationConfigProperty(propertyName = "queueManager", propertyValue = "manager"),
                            @ActivationConfigProperty(propertyName = "port", propertyValue = "1414"),
                            @ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT"),
                            @ActivationConfigProperty(propertyName = "username", propertyValue = "mqm"),
                            @ActivationConfigProperty(propertyName = "password", propertyValue = "password")

                            },
                            mappedName = "ORANGE.QUEUE", 
                            messageListenerInterface = MessageListener.class)

@ResourceAdapter(value = "wmq.jmsra.rar")
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@ApplicationException(rollback = true)

public class ORANGE_QUEUE_MDB extends RuntimeException implements MessageListener 
{
    public void onMessage(Message message) {

     try{
         TextMessage textMessage=(TextMessage) message;

        }
    catch(Exception e)
    {
        e.printStackTrace();
    }

When I deploy above listener(with wrong queue name) in Jboss it is showing below exception The Exception is like below :

11:17:14,630 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC00001: Failed to start service jboss.deployment.unit."WEBSPHERE_MDB.jar".component.WEBSPHERE_MDB.START: 
org.jboss.msc.service.StartException in service jboss.deployment.unit."WEBSPHERE_MDB.jar".component.WEBSPHERE_MDB.START: Failed to start service
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1767) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_25]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_25]
        at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_25]
Caused by: java.lang.RuntimeException: com.ibm.mq.connector.DetailedResourceException: MQJCA0001: An exception occurred in the JMS layer. 
See the linked exception for details., error code: MQJCA0001 A call to WebSphere MQ classes for JMS caused an exception to be thrown. 
See the linked exception for details of the failure.
        at org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponent.start(MessageDrivenComponent.java:171)
        at org.jboss.as.ee.component.ComponentStartService.start(ComponentStartService.java:44)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
        ... 3 more
**Caused by: com.ibm.mq.connector.DetailedResourceException:** MQJCA0001: An exception occurred in the JMS layer. See the linked exception for details., 
error code: MQJCA0001 A call to WebSphere MQ classes for JMS caused an exception to be thrown. See the linked exception for details of the failure.
        at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:124)
        at com.ibm.mq.connector.services.JCAExceptionBuilder.buildException(JCAExceptionBuilder.java:100)
        at com.ibm.mq.connector.inbound.MessageEndpointDeployment.start(MessageEndpointDeployment.java:351)
        at com.ibm.mq.connector.inbound.MessageEndpointDeployment.<init>(MessageEndpointDeployment.java:301)
        at com.ibm.mq.connector.ResourceAdapterImpl.endpointActivation(ResourceAdapterImpl.java:463)
        at org.jboss.jca.core.rar.EndpointImpl.activate(EndpointImpl.java:164)
        at org.jboss.as.ejb3.component.messagedriven.MessageDrivenComponent.start(MessageDrivenComponent.java:169)
        ... 6 more
**Caused by: com.ibm.msg.client.jms.DetailedInvalidDestinationException: JMSWMQ2008: Failed to open MQ queue 'OORANGE.QUEUE'.**
JMS attempted to perform an MQOPEN, but WebSphere MQ reported an error. Use the linked exception to determine the cause of this error. 
Check that the specified queue and queue manager are defined correctly.
        at com.ibm.msg.client.wmq.common.internal.Reason.reasonToException(Reason.java:520)
        at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:236)
        at com.ibm.msg.client.wmq.internal.WMQMessageConsumer.checkJmqiCallSuccess(WMQMessageConsumer.java:128)
        at com.ibm.msg.client.wmq.internal.WMQConsumerShadow.initialize(WMQConsumerShadow.java:856)
        at com.ibm.msg.client.wmq.internal.WMQAsyncConsumerShadow.initialize(WMQAsyncConsumerShadow.java:724)
        at com.ibm.msg.client.wmq.internal.WMQConnectionBrowser.<init>(WMQConnectionBrowser.java:1230)
        at com.ibm.msg.client.wmq.internal.WMQConnection.createConnectionBrowser(WMQConnection.java:872)
        at com.ibm.msg.client.jms.internal.JmsConnectionImpl.createConnectionBrowser(JmsConnectionImpl.java:922)
        at com.ibm.msg.client.jms.internal.JmsConnectionConsumerImpl.createConnectionBrowser(JmsConnectionConsumerImpl.java:238)
        at com.ibm.msg.client.jms.internal.JmsConnectionConsumerImpl.<init>(JmsConnectionConsumerImpl.java:166)
        at com.ibm.msg.client.jms.internal.JmsConnectionConsumerImpl.<init>(JmsConnectionConsumerImpl.java:116)
        at com.ibm.msg.client.jms.internal.JmsConnectionImpl.createConnectionConsumer(JmsConnectionImpl.java:415)
        at com.ibm.mq.jms.MQConnection.createConnectionConsumer(MQConnection.java:215)
        at com.ibm.mq.connector.inbound.MessageEndpointDeployment.createConnectionConsumer(MessageEndpointDeployment.java:486)
        at com.ibm.mq.connector.inbound.MessageEndpointDeployment.start(MessageEndpointDeployment.java:331)
        ... 10 more
**Caused by: com.ibm.mq.MQException: JMSCMQ0001: WebSphere MQ call failed with compcode '2' ('MQCC_FAILED') reason '2085' ('MQRC_UNKNOWN_OBJECT_NAME').**
        at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:223)
        ... 23 more

How to handle these exceptions and replace with Userdefind custom error message. Like (Queue Configuration error please check) etc.

Sicco
  • 6,167
  • 5
  • 45
  • 61
veeras
  • 61
  • 1
  • 4
  • 11
  • It's not clear what type of exception/error you're trying to catch. Can you paste an example? – Brett Kail Sep 10 '12 at 17:36
  • Thanks for your reply bkail, I updated above post with Exceptions which i got. Instead of those exceptions i need to display simple error message in a single line like: Configuration Exception – veeras Sep 11 '12 at 06:09
  • That error happens before the MDB gets control, so the try/catch can't work. I'm not familiar enough with JBoss to know how to reduce that error to a single line, sorry. – Brett Kail Sep 11 '12 at 12:38
  • My application is not deploying in Jboss when i give wrong Queue name like:@ActivationConfigProperty(propertyName = "destination", propertyValue = "XXX") instead of right Queue name (ORANGE.QUEUE).My intention is to deploy the application even-though when i give the wrong queue name. How to solve this problem – veeras Sep 12 '12 at 10:29

0 Answers0