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 » EJB Descriptor -- make MQ my 3rd Party JMS Provider

Post new topic  Reply to topic
 EJB Descriptor -- make MQ my 3rd Party JMS Provider « View previous topic :: View next topic » 
Author Message
dant
PostPosted: Fri May 13, 2005 7:50 am    Post subject: EJB Descriptor -- make MQ my 3rd Party JMS Provider Reply with quote

Newbie

Joined: 01 Apr 2005
Posts: 5

Hello all. This forum has helped me once before, and I'm hoping you EJB experts out there can help a newbie with EJBs.

I have deployed a MDB into the Oracle 10g App Server (orion). This MDB can listen to a queue and process the message. My problem is that I cannot send messages from my MDB to other queues. I'm pretty sure this is because I do not have my EJB descriptors set up correctly to map 3rd party resources into the App Server's own JNDI context. I've been struggling with this for two days!

As a quick note, MQ works flawlessly with JMS standalone applications that don't involve the application server. Our system has two JNDI contexts present:

1) A JNDI context created through the JMSAdmin tool (ships with MQ):
"java:comp/resource/MQSeries/". This was created with JMSAdmin.config properties:
Code:

PROVIDER_URL=file:/opt/mqm/JNDI-Directory
INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory

2) A JNDI context that is provided by Oracle 10g. This JNDI context is looked up via the typical "java:comp/env/".

Our problem is configuring the EJB descriptors to map these 3rd party resources (MQ Managers and Queues) to the Oracle provided JNDI context.

Here is our ejb-jar.xml and orion-ejb-jar.xml descriptors:

ejb-jar.xml:
Code:

<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
    <display-name>Production Message Driven Bean</display-name>
    <enterprise-beans>
        <message-driven>
            <display-name>prodMdb</display-name>
            <ejb-name>prodMdb</ejb-name>
            <ejb-class>message.handler.ProdMessageConsumerBean</ejb-class>
            <transaction-type>Container</transaction-type>
           
            <message-driven-destination>
                <destination-type>javax.jms.Queue</destination-type>
            </message-driven-destination>
               <resource-ref>
                <description>description</description>
                <res-ref-name>prodQCF</res-ref-name>
                <res-type>javax.jms.QueueConnectionFactory</res-type>
                <res-auth>Application</res-auth>
                <res-sharing-scope>Shareable</res-sharing-scope>
            </resource-ref>
            <resource-env-ref>
               <resource-env-ref-name>prodQ</resource-env-ref-name>
             <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
            </resource-env-ref>
        </message-driven>
    </enterprise-beans>

   
</ejb-jar>



orion-ejb-jar.xml:
Code:

<orion-ejb-jar>
  <enterprise-beans>
    <message-driven-deployment name="prodMdb" connection-factory-location="java:comp/resource/MQSeries/prodQCF" destination-location="java:comp/resource/MQSeries/prodQ"/>
  </enterprise-beans>
</orion-ejb-jar>



I've tried all kinds of variances and permutations to these files with res-ref-mapping elements in the orion-ejb-jar.xml, but I'm having no luck. I thought this would be a simple configuration -- I just can't see the forest from the trees at this point.

Any help or suggestion at all would be deeply appreciated. I'm completely stuck at the moment.

Thanks in advance.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Fri May 13, 2005 7:56 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Are you getting errors?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
dant
PostPosted: Fri May 13, 2005 8:22 am    Post subject: Reply with quote

Newbie

Joined: 01 Apr 2005
Posts: 5

jefflowrey wrote:
Are you getting errors?


Well, not MQ errors specifically. We get a javax.naming.Exception when we try to lookup a queue named "prodS". This prodS queue definitely exists in the MQ JNDI context at java:comp/resource/MQSeries/prodS.

Log4j output:
Code:

2005-05-13 12:04:35,943 DEBUG [<logger name removed]                                       ] [JmsMessagePackage getQNeeds(strQueue) qManager = com.ibm.mq.jms
.MQQueueConnectionFactory@44c1e504] [ApplicationServerThread-6] [4519182]

2005-05-13 12:04:35,944 ERROR [<logger name removed>                                       ] [JmsMessagePackage NamingException raised:  javax.naming.NameNot
FoundException: prodS not found in prodMdb] [ApplicationServerThread-6] [4519183]


snippet of code that causes this error:
Code:

try {
     
      javax.naming.Context jndiContext = ctx.getInitialContext();
      logger.debug("JmsMessagePackage getQNeeds(strQueue) jndiContext = " + jndiContext);

      //the line below retrieves the prodQCF object correctly
      QueueConnectionFactory qManager = (QueueConnectionFactory)
      jndiContext.lookup(ctx.getQManager());   
     
      //this line fails to find the queue resource
      javax.jms.Queue qName = (javax.jms.Queue) jndiContext.lookup("java:comp/env/prodS");
      logger.debug("JmsMessagePackage getQNeeds(strQueue) qName = " + qName);
      queue_conn = qManager.createQueueConnection();
      queue_session =
        queue_conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
      queue_sender = queue_session.createSender(qName); // queue variable name
     
     
    } catch (NamingException e) {
       logger.error("JmsMessagePackage NamingException raised:  " + e);
    } catch (JMSException e) {
       logger.error("JmsMessagePackage JMSException raised:  " + e);
    }


For kicks, here is my orion-application.xml which informs Oracle App Server of the MQ JNDI context:
Code:

<orion-application>
<resource-provider
    class="com.evermind.server.deployment.ContextScanningResourceProvider"
    name="MQSeries">
    <description>
      MQSeries resource provider
    </description>
    <property
      name="java.naming.factory.initial"
      value="com.sun.jndi.fscontext.RefFSContextFactory">
    </property>
    <property
      name="java.naming.provider.url"
      value="file:////opt/JNDI-Directory">
    </property>
</resource-provider>
</orion-application>
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri May 13, 2005 10:36 am    Post subject: Reply with quote

Grand High Poobah

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

In your file context did you define your JNDI as
Quote:
java:comp/env/prodS
or did you change the JNDI from the file context to an environment reference resource in the JNDI context of your app server ?
[code]java:comp/env/jms/prodS=prodS, url=file:///.....[code]

This is a JNDI problem...
Enjoy
Back to top
View user's profile Send private message Send e-mail
dant
PostPosted: Sun May 15, 2005 12:37 pm    Post subject: Reply with quote

Newbie

Joined: 01 Apr 2005
Posts: 5

Yeah, it was a jndi mapping problem. I thought so initially when I first posted, but I suppose I was just mixed up and tired when I was trying different orion-ejb-jar.xml configurations.

Maybe someone else down the line will find this post useful, so I'll go ahead and post my solution.

ejb-jar.xml:

Code:

<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
    <display-name>Production Message Driven Bean</display-name>
    <enterprise-beans>
        <message-driven>
            <display-name>prodMdb</display-name>
            <ejb-name>prodMdb</ejb-name>
            <ejb-class>message.handler.MessageConsumerBean</ejb-class>
            <transaction-type>Container</transaction-type>
           
            <message-driven-destination>
                <destination-type>javax.jms.Queue</destination-type>
            </message-driven-destination>
          
         <resource-ref>
                <description>description</description>
                <res-ref-name>prodQCF</res-ref-name>
                <res-type>javax.jms.QueueConnectionFactory</res-type>
                <res-auth>Application</res-auth>
                <res-sharing-scope>Shareable</res-sharing-scope>
            </resource-ref>
           
         <resource-ref>
            <res-ref-name>prodQ</res-ref-name>
            <res-type>javax.jms.Queue</res-type>
            <res-auth>Application</res-auth>
                <res-sharing-scope>Shareable</res-sharing-scope>
            </resource-ref>
         
         <resource-ref>
            <res-ref-name>prodP</res-ref-name>
            <res-type>javax.jms.Queue</res-type>
            <res-auth>Application</res-auth>
                <res-sharing-scope>Shareable</res-sharing-scope>
            </resource-ref>
         
         <resource-ref>
            <res-ref-name>prodR</res-ref-name>
            <res-type>javax.jms.Queue</res-type>
            <res-auth>Application</res-auth>
                <res-sharing-scope>Shareable</res-sharing-scope>
            </resource-ref>
         
         <resource-ref>
            <res-ref-name>prodS</res-ref-name>
            <res-type>javax.jms.Queue</res-type>
            <res-auth>Application</res-auth>
                <res-sharing-scope>Shareable</res-sharing-scope>
            </resource-ref>
         
         <resource-ref>
            <res-ref-name>prodC</res-ref-name>
            <res-type>javax.jms.Queue</res-type>
            <res-auth>Application</res-auth>
                <res-sharing-scope>Shareable</res-sharing-scope>
            </resource-ref>
         
        </message-driven>
    </enterprise-beans>

   
</ejb-jar>




orion-ejb-jar.xml:

Code:

<orion-ejb-jar>
  <enterprise-beans>
    <message-driven-deployment
      name="prodMdb"
      connection-factory-location="java:comp/resource/MQSeries/prodQCF"
      destination-location="java:comp/resource/MQSeries/prodQ">
   
      <resource-ref-mapping location="java:comp/resource/MQSeries/prodQ" name="prodQ"/>
      <resource-ref-mapping location="java:comp/resource/MQSeries/prodP" name="prodP"/>
      <resource-ref-mapping location="java:comp/resource/MQSeries/prodR" name="prodR"/>
      <resource-ref-mapping location="java:comp/resource/MQSeries/prodS" name="prodS"/>
      <resource-ref-mapping location="java:comp/resource/MQSeries/prodC" name="prodC"/>
         
   </message-driven-deployment>
  </enterprise-beans>
</orion-ejb-jar>



orion-application.xml:

Code:

<orion-application>
<resource-provider
    class="com.evermind.server.deployment.ContextScanningResourceProvider"
    name="MQSeries">
    <description>
      MQSeries resource provider
    </description>
    <property
      name="java.naming.factory.initial"
      value="com.sun.jndi.fscontext.RefFSContextFactory">
    </property>
    <property
      name="java.naming.provider.url"
      value="file:////opt/JNDI-Directory">
    </property>
</resource-provider>
</orion-application>



Thanks for the responses!
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 » EJB Descriptor -- make MQ my 3rd Party JMS Provider
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.