ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » WMQ integration with weblogic

Post new topic  Reply to topic
 WMQ integration with weblogic « View previous topic :: View next topic » 
Author Message
azeemdin
PostPosted: Thu Jun 27, 2013 2:24 am    Post subject: WMQ integration with weblogic Reply with quote

Newbie

Joined: 27 Jun 2013
Posts: 6

hi,
I am working on a POC, I need to create a MDB deployed in weblogic (11g) and listen on a queue, I want to use WMQInitialContextFactory for connectivity, I have used following configuration for [weblogic-ejb-jar.xml]

Code:

<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-ejb-jar
   xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.2/weblogic-ejb-jar.xsd">
   <wls:weblogic-enterprise-bean>
      <!--options:DESTINATION_JNDI -->
      <wls:ejb-name>TestMDB</wls:ejb-name>
      <wls:message-driven-descriptor>
         <wls:destination-jndi-name>TEST</wls:destination-jndi-name>
         <wls:initial-context-factory>com.ibm.mq.jms.context.WMQInitialContextFactory</wls:initial-context-factory>
         <wls:provider-url>HOST:PORT/SYSTEM.ADMIN.SVRCONN</wls:provider-url>
         <wls:connection-factory-jndi-name>QMGR</wls:connection-factory-jndi-name>
      </wls:message-driven-descriptor>
   </wls:weblogic-enterprise-bean>
</wls:weblogic-ejb-jar>


while deploying MDB in weblogic I am having following exception.
Quote:
<Jun 26, 2013 10:18:22 PM AST> <Warning> <EJB> <BEA-010061> <The Message-Driven EJB: TestMDB is unable to connect to the JMS destination: TEST. The Error was:
weblogic.jms.common.JMSException: A WebSphere MQ Queue Manager cannot does not support directory structured queue definitions
at weblogic.jms.common.CDS.processDD(CDS.java:770)
at weblogic.jms.common.CDS.lookupDDAndCalloutListener(CDS.java:387)
at weblogic.jms.common.CDS.access$300(CDS.java:42)
at weblogic.jms.common.CDS$DDListenerRegistrationTimerListener.timerExpired(CDS.java:214)
at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: javax.naming.OperationNotSupportedException: A WebSphere MQ Queue Manager cannot does not support directory structured queue definitions
at com.ibm.mq.jms.context.MQContext.lookupLink(MQContext.java:1461)
at javax.naming.InitialContext.lookupLink(InitialContext.java:472)
at weblogic.jms.common.CDS.checkForeign(CDS.java:819)
at weblogic.jms.common.CDS.access$400(CDS.java:42)
at weblogic.jms.common.CDS$3.run(CDS.java:751)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.jms.common.CrossDomainSecurityManager.contact admin(CrossDomainSecurityManager.java:131)
at weblogic.jms.common.CDS.processDD(CDS.java:746)
... 7 more
>
<Jun 26, 2013 10:18:32 PM AST> <Warning> <EJB> <BEA-010061> <The Message-Driven EJB: TestMDB is unable to connect to the JMS destination: TEST. The Error was:
weblogic.jms.common.JMSException: A WebSphere MQ Queue Manager cannot does not support directory structured queue definitions
at weblogic.jms.common.CDS.processDD(CDS.java:770)
at weblogic.jms.common.CDS.lookupDDAndCalloutListener(CDS.java:387)
at weblogic.jms.common.CDS.ddLookup(CDS.java:1419)
at weblogic.jms.common.CDS.access$800(CDS.java:42)
at weblogic.jms.common.CDS$DDLookupTimerListener.timerExpired(CDS.java:1293)
at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: javax.naming.OperationNotSupportedException: A WebSphere MQ Queue Manager cannot does not support directory structured queue definitions
at com.ibm.mq.jms.context.MQContext.lookupLink(MQContext.java:1461)
at javax.naming.InitialContext.lookupLink(InitialContext.java:472)
at weblogic.jms.common.CDS.checkForeign(CDS.java:819)
at weblogic.jms.common.CDS.access$400(CDS.java:42)
at weblogic.jms.common.CDS$3.run(CDS.java:751)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.jms.common.CrossDomainSecurityManager.contact admin(CrossDomainSecurityManager.java:131)
at weblogic.jms.common.CDS.processDD(CDS.java:746)

I have already successfully deployed same MDB using file based URL i.e using RefFSContextFactory. But my environment is having 100s of queues and 50+ queue managers, I don't want to create JNDI objects for all (.bindings file). I am not sure if I am doing right, kindly need expert comments and advice.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jun 27, 2013 2:47 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

You're going to have to create an activation spec, a separate and distinct and unique activation spec, for every MDB you want to create.

So it's not clear how that's significantly different from creating JNDI entries for all queues and all qmgrs at your organization.

And it would be entirely astounding if every single queue on every single queue manager in your corporate network was being read by an MDB hosted in weblogic using the same JNDI.

Again, activation specs are very specific to a single queue on a single queue manager.

The error you're getting is reasonably explicit. The WMQInitialContextFactory is not capable of acting as the kind of JNDI directory you are asking it to be.

I don't know what it actually means to be a "directory structured queue definition", but it's possible that you simply need to specify that the destination is a "queue://" destination rather than simply "TEST".

Since you're using WebLogic, I would really expect that you would be using WebLogic's JNDI as the initial context.
Back to top
View user's profile Send private message
azeemdin
PostPosted: Thu Jun 27, 2013 3:02 am    Post subject: Reply with quote

Newbie

Joined: 27 Jun 2013
Posts: 6

thank you very much mqjeff for your reply and clarifications. Actually this MDB is only for POC to validate if deployed in weblogic can connect to MQ using WMQInitialContextFactory. Why exactly we need this that is totally as per our understanding. We have an existing environment and your suggestion/comments are highly appreciated in this regard. What we are trying to achieve that we are going to introduce weblogic in our existing infrastructure and as per recommendation, we should use weblogic JNDI or creating a foreign server or jms module within weblogic to communicate with MQ. But we want to avoid extra configuration in this case like we want to use existing QMGR and Queue names to receive a request in MDB or any other application deployed in weblogic and send reply back to caller using MQMD. If we create local JNDIs, jms modules or bridge in weblogic we will have to configure all required MQ objects which we want to bypass. Can you please share your expert advice for this scenario.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu Jun 27, 2013 3:09 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

No matter what JNDI repository you use, you still have to create an activation spec for every MDB.

Not one single activation spec for ALL MDBs, but one activation spec for EACH MDB.

So if you need 100 MDBs, you need 100 activation specs. If you need to read from 1000 queues, you need 1000 activation specs to create 1000 MDBs.

Again, the error is reasonably specific, and I don't entirely know what it means, but I suggest that it's because you're using the plain value "TEST" as the destination, rather than a destination url that would start something like "queue://".

And when i say "suggest" I mean "That's all the advice I have".

Go, read, think, try, repeat.
Back to top
View user's profile Send private message
azeemdin
PostPosted: Thu Jun 27, 2013 3:29 am    Post subject: Reply with quote

Newbie

Joined: 27 Jun 2013
Posts: 6

Thanks mqjeff

I agree that for each MDB we need to create activation spec, but if we create file based JNDI or use weblogic JNDI we need to configure reply queue configuration as well, that exactly we don't want.

For weblogic we need to configure bridges between weblogic and MQ and configure all request queues as well as reply queues. For request queues we are fine to define all configuration, whether file base JNDI or configuration in weblogic, but for reply queues do we really need to configure that too?

We have some other products implemented in our environment along with POJO or some open source frameworks that uses inbound gateway pattern and for these we don't need to pre define any configuration for reply queues.

I am not sure about overall concepts, really sorry if asking any stupid question.

I tried defining queue TEST as "queue://TEST" but now getting this error, also tried with "queue://QMGR/TEST"
Quote:
<Jun 27, 2013 2:17:07 PM AST> <Warning> <EJB> <BEA-010061> <The Message-Driven EJB: TestMDB is unable to connect to the JMS destination: queue://TEST. The Error was:
javax.naming.NamingException: Unable to communicate with the queue manager while looking up object queue://TEST
at com.ibm.mq.jms.context.MQContext.lookup(MQContext.java:947)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at weblogic.jms.common.CDS$2.run(CDS.java:508)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.jms.common.CrossDomainSecurityManager.contact admin(CrossDomainSecurityManager.java:131)
at weblogic.jms.common.CDS.lookupDestination(CDS.java:502)
at weblogic.jms.common.CDS.lookupDDAndCalloutListener(CDS.java:367)
at weblogic.jms.common.CDS.access$300(CDS.java:42)
at weblogic.jms.common.CDS$DDListenerRegistrationTimerListener.timerExpired(CDS.java:214)
at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Thu Jun 27, 2013 8:27 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

To be of any value your JMSException handling needs to extract the linked exception, if it is not null.
This is the way to get the provider's error codes.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
azeemdin
PostPosted: Tue Jul 02, 2013 11:39 am    Post subject: Reply with quote

Newbie

Joined: 27 Jun 2013
Posts: 6

I created one standalone java program and it worked fine

Code:

package com.test;

import java.util.Properties;

import javax.jms.DeliveryMode;
import javax.jms.JMSException;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class TestClass {

   public static void main(String[] args) {
      Context context;
      QueueConnection queueConn = null;
      try {
         Properties env = new Properties();
         env.put(Context.INITIAL_CONTEXT_FACTORY,
               "com.ibm.mq.jms.context.WMQInitialContextFactory");
         env.put(Context.PROVIDER_URL,
               "localhost:1414/SYSTEM.ADMIN.SVRCONN");
         context = new InitialContext(env);
         QueueConnectionFactory cf = (QueueConnectionFactory) context
               .lookup("MQGR");
         Queue queue = (Queue) context.lookup("TEST");
         queueConn = cf.createQueueConnection();
         QueueSession queueSession = queueConn.createQueueSession(false,
               Session.AUTO_ACKNOWLEDGE);
         QueueSender queueSender = queueSession.createSender(queue);
         queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
         TextMessage message = queueSession.createTextMessage("Hello");
         queueSender.send(message);
         System.out.println("sent: " + message.getText());

      } catch (NamingException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      } catch (JMSException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
      } finally {
         if(queueConn != null) {
            try {
               queueConn.close();
            } catch (JMSException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
            }            
         }
      }
   }
}


But when I want to use same configuration in MDB (deploy in weblogic), it fails with below error:
Quote:
JMS destination: queue://MQGR/TEST. The Error was:
javax.naming.NamingException: Unable to communicate with the queue manager while looking up object queue://MQGR/TEST
at com.ibm.mq.jms.context.MQContext.lookup(MQContext.java:947)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at weblogic.jms.common.CDS$2.run(CDS.java:508)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.jms.common.CrossDomainSecurityManager.contact admin(CrossDomainSecurityManager.java:131)
at weblogic.jms.common.CDS.lookupDestination(CDS.java:502)
at weblogic.jms.common.CDS.lookupDDAndCalloutListener(CDS.java:367)
at weblogic.jms.common.CDS.access$300(CDS.java:42)
at weblogic.jms.common.CDS$DDListenerRegistrationTimerListener.timerExpired(CDS.java:214)
at weblogic.timers.internal.TimerImpl.run(TimerImpl.java:273)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:545)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
>

Following is my MDB:
Code:
package com.test;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

@MessageDriven(name = "TestMDB")
public class TestMDB implements MessageListener {
   public void onMessage(Message msg) {
      System.out.println("\n=========================================");
      System.out.println("=> Message received!");

      if (msg instanceof TextMessage) {

         try {
            System.out.println("=> Message: "
                  + ((TextMessage) msg).getText());
         } catch (JMSException e) {
            e.printStackTrace();
            System.out.println(e.getLinkedException().getMessage());
            e.getLinkedException().printStackTrace();
         }
      }

      System.out.println("=========================================");
   }

   @PostConstruct
   public void postCreate() {
      System.out.println("Bean Created");
   }

   @PreDestroy
   public void preDestroy() {
      System.out.println("Bean Destroyed");
   }
}

And weblogic-ejb-jar.xml:
Quote:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-ejb-jar
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-ejb-jar"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-ejb-jar http://xmlns.oracle.com/weblogic/weblogic-ejb-jar/1.2/weblogic-ejb-jar.xsd">
<wls:weblogic-enterprise-bean>
<wls:ejb-name>TestMDB</wls:ejb-name>
<wls:message-driven-descriptor>
<wls:destination-jndi-name>queue://MQGR/TEST</wls:destination-jndi-name>
<wls:initial-context-factory>com.ibm.mq.jms.context.WMQInitialContextFactory</wls:initial-context-factory>
<wls:provider-url>localhost:1414/SYSTEM.ADMIN.SVRCONN</wls:provider-url>
<wls:connection-factory-jndi-name>MQGR</wls:connection-factory-jndi-name>
</wls:message-driven-descriptor>
</wls:weblogic-enterprise-bean>
</wls:weblogic-ejb-jar>

Can anyone please advise.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Jul 02, 2013 7:46 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Again: There is no point in printing the stack trace on a JMSException.
What you do need to print, should it not be null is the LINKED EXCEPTION.
It will contain the error codes of the provider. Without those there is little to no help for you.
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
azeemdin
PostPosted: Tue Jul 02, 2013 9:01 pm    Post subject: Reply with quote

Newbie

Joined: 27 Jun 2013
Posts: 6

I am really sorry fjb_saper you had to repeat that, but I tried to enable all debug options in weblogic but still unable to get linked exception.

I will look into this, if somehow I can get the related exception details.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Wed Jul 03, 2013 12:24 am    Post subject: Re: WMQ integration with weblogic Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

azeemdin wrote:
I tried to enable all debug options in weblogic but still unable to get linked exception.

The Java EE "linked exception" is the same as the Java SE "cause". In the java.lang.Throwable.printStackTrace() output, the lines typically starting with "Caused by: " indicate linked exceptions.

Use either the javax.jms.JMSException.getLinkedException() method or the java.lang.Throwable.getCause() method to get the linked exception.
Back to top
View user's profile Send private message
azeemdin
PostPosted: Wed Jul 03, 2013 7:33 am    Post subject: Reply with quote

Newbie

Joined: 27 Jun 2013
Posts: 6

Thanks rekarm01 for the advise, but the problem is exception is not being raised from the code itself as you can see in the trace.

I am stuck at this point and unable to get the required exception details from the container (weblogic)
Back to top
View user's profile Send private message
rekarm01
PostPosted: Wed Jul 03, 2013 4:17 pm    Post subject: Re: WMQ integration with weblogic Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

azeemdin wrote:
Code:
catch (JMSException e) {
    e.printStackTrace();
    System.out.println(e.getLinkedException().getMessage());
    e.getLinkedException().printStackTrace();
}

The "e.printStackTrace()" typically prints the message and stack trace not just for e, but also for its linked exceptions, so the last two lines above would be redundant.

Note that the linked exception itself could be null, or it could be another JMSException, with its own linked exception, and so on ...

azeemdin wrote:
the problem is exception is not being raised from the code itself

javax.naming.NamingException also has the getRootCause(), getExplanation(), and other methods, which may provide details that don't appear in the stack trace. Consult the javadoc for more information.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » WMQ integration with weblogic
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.