11 Replies Latest reply on Dec 9, 2003 1:27 PM by brucec

    MBean depends for Topic ConnectionFactory

    brucec Newbie

      I've looked thru the forum for something on this, but haven't found anything so far even though it seems like a possibly common issue.

      We're still running jboss-3.0.4_tomcat-4.1.12 so the issue may be different for 3.1 or 3.2.

      I have an MBean that will be connecting to a JMS Topic and it needs to be deployed after the ConnectionFactory.

      What would be the correct syntax of the statement for deploying such an MBean?

      I tried jboss.jca:service=XaTxDs,name=jmsra
      as well as a couple of others, but haven't figured out the correct depends yet.

      Can anyone help on this?

        • 1. Re: MBean depends for Topic ConnectionFactory
          Juha Lindfors Master

          Try the topic itself, it should appear as an MBean on the console.

          -- Juha

          • 2. Re: MBean depends for Topic ConnectionFactory
            brucec Newbie

            Unfortunately the Topic itself is not enough.

            I have both the naming service and topic listed as , but the MBean start() still fails when it does the JNDI lookup on "ConnectionFactory".

            Here are the statements that I currently using:
            jboss:service=Naming
            jboss.mq.destination:service=Topic,name=HeartbeatTopic
            <!--
            jboss.jca:service=XaTxDS,name=jmsra
            -->

            and the MBean code that is failing looks like:
            topicConnectionFactory = (TopicConnectionFactory)jndi.lookup( "ConnectionFactory" );

            • 3. Re: MBean depends for Topic ConnectionFactory
              Raja Master

              Try doing a depends on
              jboss.mq:service=InvocationLayer,type=JVM

              This is the ObjectName for the JVM Invocation Layer and it is the one binding the java:/ConnectionFactory as JNDI Name.

              • 4. Re: MBean depends for Topic ConnectionFactory
                brucec Newbie

                Sounded like a winner, but this does not work either.

                When the MBean tries to start it still finds "ConnectionFactory not bound"

                • 5. Re: MBean depends for Topic ConnectionFactory
                  Juha Lindfors Master

                  Are you looking up the in-VM invocation layer from java: namespace or the global ConnectionFactory from your MBean though.

                  You need to add a dependency to a different IL if you're doing the latter.

                  -- Juha

                  • 6. Re: MBean depends for Topic ConnectionFactory
                    brucec Newbie

                    If I understand your question it is the in-VM invocation layer.

                    Below is a snippet of the code (yech - copy/paste lost indentation):

                    public class HeartbeatPublisher implements HeartbeatPublisherMBean,
                    Serializable {
                    public void start() {
                    TopicConnectionFactory _topicConnectionFactory;
                    try {
                    JndiServices jndi = new JndiServices();
                    _topicConnectionFactory = (TopicConnectionFactory)jndi.lookup( "ConnectionFactory" );
                    } catch ( NamingException e ) {
                    throw new HeartbeatInitializationException( "start()", e );
                    }
                    ...
                    }
                    }

                    import javax.naming.Context;
                    import javax.naming.InitialContext;
                    import javax.naming.NamingException;

                    public class JndiServices
                    {
                    private ContextFactory contextFactory;

                    public JndiServices()
                    {
                    this.contextFactory = new DefaultContextFactory();
                    }

                    public void bind(final String name, final Object object)
                    throws NamingException
                    {
                    execute(new ContextCallback()
                    {
                    public void doInContext(Context ctx) throws NamingException
                    {
                    ctx.bind(name, object);
                    logger.info("Bound JNDI object with name " + name);
                    }
                    });
                    }

                    public void rebind( final String name, final Object object )
                    throws NamingException
                    {
                    execute( new ContextCallback()
                    {
                    public void doInContext( Context ctx ) throws NamingException
                    {
                    ctx.rebind( name, object );
                    logger.info( "ReBound JNDI object with name " + name );
                    }
                    } );
                    }


                    public void unbind(final String name) throws NamingException
                    {
                    execute(new ContextCallback()
                    {
                    public void doInContext(Context ctx) throws NamingException
                    {
                    ctx.unbind(name);
                    logger.info("Unbound JNDI object with name " + name);
                    }
                    });
                    }


                    /**
                    * If this returns null, caller should deal with it
                    */
                    public Object lookup(final String name) throws NamingException
                    {
                    class LookupCallback implements ContextCallback
                    {
                    private Object o;
                    public void doInContext(Context ctx) throws NamingException
                    {
                    o = ctx.lookup(name);
                    }

                    public Object getObject()
                    {
                    return o;
                    }
                    }
                    LookupCallback lc = new LookupCallback();
                    execute(lc);
                    return lc.getObject();
                    }

                    /** Open up what is done so clients can provide a context callback
                    */
                    public void execute(ContextCallback cc) throws NamingException
                    {
                    Context ctx = null;
                    try
                    {
                    ctx = contextFactory.getContext();
                    cc.doInContext(ctx);
                    }
                    finally
                    {
                    try
                    {
                    if (ctx != null)
                    ctx.close();
                    }
                    catch (NamingException ex)
                    {
                    //
                    }
                    }
                    }
                    private class DefaultContextFactory implements ContextFactory
                    {
                    public Context getContext() throws NamingException
                    {
                    return new InitialContext();
                    }
                    }
                    }

                    • 7. Re: MBean depends for Topic ConnectionFactory
                      Raja Master

                      can you check if ConnectionFactory is listed in the JNDIView on jmx-console.


                      • 8. Re: MBean depends for Topic ConnectionFactory
                        brucec Newbie

                        Yes, the ConnectionFactory is listed in the JNDIView under the following:
                        java:Namespace, ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)
                        Global JNDI Namespace, ConnectionFactory (class: org.jboss.mq.SpyConnectionFactory)

                        Here is some of the server log file from this mornings latest attempt:
                        .
                        .
                        .
                        2003-12-09 08:43:34,808 INFO [org.jboss.mq.server.jmx.Topic.testDurableTopic] Starting
                        2003-12-09 08:43:34,809 INFO [org.jboss.mq.server.jmx.Topic.testDurableTopic] Bound to JNDI name: topic/testDurableTopic
                        2003-12-09 08:43:34,809 INFO [org.jboss.mq.server.jmx.Topic.testDurableTopic] Started
                        2003-12-09 08:43:34,809 INFO [org.jboss.mq.server.jmx.Queue.testQueue] Starting
                        2003-12-09 08:43:34,810 INFO [org.jboss.mq.server.jmx.Queue.testQueue] Bound to JNDI name: queue/testQueue
                        2003-12-09 08:43:34,811 INFO [org.jboss.mq.server.jmx.Queue.testQueue] Started
                        2003-12-09 08:43:34,811 INFO [org.jboss.mq.server.jmx.InterceptorLoader] Starting
                        2003-12-09 08:43:34,811 INFO [org.jboss.mq.server.jmx.InterceptorLoader] Started
                        2003-12-09 08:43:34,811 INFO [org.jboss.mq.server.jmx.Invoker] Starting
                        2003-12-09 08:43:34,812 INFO [org.jboss.mq.server.jmx.Invoker] Started
                        2003-12-09 08:43:34,812 INFO [org.jboss.mq.il.jvm.JVMServerILService] Starting
                        2003-12-09 08:43:34,854 INFO [org.jboss.mq.il.jvm.JVMServerILService] Started
                        2003-12-09 08:43:34,858 ERROR [STDERR] Dec 9, 2003 8:43:34 AM com.transdyn.dynac.heartbeat.server.HeartbeatPublisher start
                        INFO: starting ...
                        2003-12-09 08:43:34,865 ERROR [STDERR] Dec 9, 2003 8:43:34 AM com.transdyn.dynac.heartbeat.AbstractHeartbeat initialize
                        WARNING: javax.naming.NameNotFoundException: ConnectionFactory not bound
                        2003-12-09 08:43:34,870 WARN [org.jboss.system.ServiceController] Problem starting service Dynac:service=HeartbeatPublisher
                        com.transdyn.dynac.heartbeat.HeartbeatInitializationException: initialize()_CONNECTION_FACTORY
                        .
                        .
                        .

                        The following is my xml deploy statements for this MBean (including many commented out trys that didn't work):

                        <!-- jboss:service=Naming -->
                        <!-- jboss.mq.destination:service=Topic,name=HeartbeatTopic -->
                        <depends-list>
                        <depends-list-element>jboss.mq.destination:service=Topic,name=HeartbeatTopic</depends-list-element>
                        <depends-list-element>jboss.mq:service=InvocationLayer,type=JVM</depends-list-element>
                        <!-- <depends-list-element>jboss.jca:service=XaTxDS,name=jmsra</depends-list-element> -->
                        </depends-list>
                        <!-- these have been tried singly -->
                        <!-- jboss.jca:service=XaTxCM,name=jmsra ... hangs JBoss deploy -->
                        <!-- jboss.jca:service=CachedConnectionManager ... NO -->
                        <!-- jboss:service=XidFactory -->
                        <!-- jboss:service=JNDIView ... ConnectionFactory not bound -->
                        <!-- jboss.jca:service=RARDeployer ... HANGS JBoss deploy -->
                        <!-- jboss.mq:service=InvocationLayer,type=JVM ... ConnectionFactory not bound -->
                        <!-- jboss.mq:service=JMSProviderLoader,name=JBossMQProvider ... hangs after Bound java:/DefaultJMSProvider -->
                        <!-- jboss.jca:service=XaTxDS,name=jmsra ... HANGS JMX console -->

                        • 9. Re: MBean depends for Topic ConnectionFactory
                          Raja Master

                          Are you managing the depend attributes using a list. I see from your code that you have a depends-list setup. Can you try it as a depends?

                          • 10. Re: MBean depends for Topic ConnectionFactory
                            Juha Lindfors Master

                            You're looking up 'ConnectionFactory' from your MBean which is bound to OILInvocationLayer (assuming you haven't changed the default mappings).

                            So you probably need to wait (depend) at least until

                            jboss.mq:service=InvocationLayer,type=OIL

                            has started. This comes AFTER the JVMServerILService which you're depending on now (and thus starting the MBean perhaps too early...)

                            19:16:20,000 INFO [CacheStore] Creating
                            19:16:20,000 INFO [CacheStore] Created
                            19:16:20,010 INFO [MessageCache] Creating
                            19:16:20,010 INFO [MessageCache] Created
                            19:16:20,010 INFO [PersistenceManager] Creating
                            19:16:20,010 INFO [PersistenceManager] Created
                            19:16:20,010 INFO [DynamicStateManager] Creating
                            19:16:20,010 INFO [DynamicStateManager] Created
                            19:16:20,010 INFO [DestinationManager] Creating
                            19:16:20,030 INFO [DestinationManager] Created
                            19:16:20,040 INFO [A] Creating
                            19:16:20,040 INFO [A] Created
                            19:16:20,040 INFO [B] Creating
                            19:16:20,040 INFO [B] Created
                            19:16:20,040 INFO [C] Creating
                            19:16:20,040 INFO [C] Created
                            19:16:20,040 INFO [D] Creating
                            19:16:20,040 INFO [D] Created
                            19:16:20,040 INFO [ex] Creating
                            19:16:20,040 INFO [ex] Created
                            19:16:20,040 INFO [SecurityManager] Creating
                            19:16:20,050 INFO [SecurityManager] Created
                            19:16:20,050 INFO [testTopic] Creating
                            19:16:20,050 INFO [testTopic] Created
                            19:16:20,050 INFO [securedTopic] Creating
                            19:16:20,050 INFO [securedTopic] Created
                            19:16:20,050 INFO [testDurableTopic] Creating
                            19:16:20,050 INFO [testDurableTopic] Created
                            19:16:20,050 INFO [testQueue] Creating
                            19:16:20,050 INFO [testQueue] Created
                            
                            19:16:20,050 INFO [InterceptorLoader] Creating
                             19:16:20,050 INFO [InterceptorLoader] Created
                             19:16:20,060 INFO [Invoker] Creating
                             19:16:20,060 INFO [Invoker] Created
                             19:16:20,060 INFO [JVMServerILService] Creating
                             19:16:20,060 INFO [JVMServerILService] Created
                             19:16:20,060 INFO [RMIServerILService] Creating
                             19:16:20,070 INFO [RMIServerILService] Created
                             19:16:20,070 INFO [OILServerILService] Creating
                             19:16:20,070 INFO [OILServerILService] Created
                             19:16:20,070 INFO [UILServerILService] Creating
                             19:16:20,070 INFO [UILServerILService] Created
                            
                            19:16:20,070 INFO [DLQ] Creating
                            19:16:20,070 INFO [DLQ] Created
                            19:16:20,080 INFO [CacheStore] Starting
                            19:16:20,080 INFO [CacheStore] Started
                            19:16:20,080 INFO [MessageCache] Starting
                            19:16:20,080 INFO [MessageCache] Started
                            19:16:20,080 INFO [PersistenceManager] Starting
                            19:16:20,100 INFO [PersistenceManager] Started
                            19:16:20,100 INFO [DynamicStateManager] Starting
                            19:16:20,140 INFO [DynamicStateManager] Started
                            19:16:20,140 INFO [DestinationManager] Starting
                            19:16:20,160 INFO [DestinationManager] Started
                            19:16:20,170 INFO [A] Starting
                            19:16:20,210 INFO [A] Bound to JNDI name: queue/A
                            19:16:20,210 INFO [A] Started
                            19:16:20,210 INFO [B] Starting
                            19:16:20,210 INFO [B] Bound to JNDI name: queue/B
                            19:16:20,220 INFO [B] Started
                            19:16:20,220 INFO [C] Starting
                            19:16:20,220 INFO [C] Bound to JNDI name: queue/C
                            19:16:20,220 INFO [C] Started
                            19:16:20,220 INFO [D] Starting
                            19:16:20,220 INFO [D] Bound to JNDI name: queue/D
                            19:16:20,220 INFO [D] Started
                            19:16:20,230 INFO [ex] Starting
                            19:16:20,230 INFO [ex] Bound to JNDI name: queue/ex
                            19:16:20,230 INFO [ex] Started
                            19:16:20,230 INFO [SecurityManager] Starting
                            19:16:20,260 INFO [JaasSecurityManagerService] Created securityMgr=org.jboss.security.plugins.JaasSecurityManager@16089
                            a5
                            19:16:20,260 INFO [JaasSecurityManagerService] setCachePolicy, c=org.jboss.util.TimedCachePolicy@ecb67f
                            19:16:20,260 INFO [JaasSecurityManagerService] Added jbossmq, org.jboss.security.plugins.SecurityDomainContext@c16b18 t
                            o map
                            19:16:20,280 INFO [SecurityManager] Started
                            19:16:20,280 INFO [testTopic] Starting
                            19:16:20,301 INFO [testTopic] Bound to JNDI name: topic/testTopic
                            19:16:20,311 INFO [testTopic] Started
                            19:16:20,321 INFO [securedTopic] Starting
                            19:16:20,321 INFO [securedTopic] Bound to JNDI name: topic/securedTopic
                            19:16:20,321 INFO [securedTopic] Started
                            19:16:20,321 INFO [testDurableTopic] Starting
                            19:16:20,321 INFO [testDurableTopic] Bound to JNDI name: topic/testDurableTopic
                            19:16:20,321 INFO [testDurableTopic] Started
                            19:16:20,331 INFO [testQueue] Starting
                            19:16:20,331 INFO [testQueue] Bound to JNDI name: queue/testQueue
                            19:16:20,331 INFO [testQueue] Started
                            19:16:20,331 INFO [InterceptorLoader] Starting
                            19:16:20,331 INFO [InterceptorLoader] Started
                            19:16:20,331 INFO [Invoker] Starting
                            19:16:20,331 INFO [Invoker] Started
                            19:16:20,331 INFO [JVMServerILService] Starting
                            19:16:20,411 INFO [JVMServerILService] Started
                            19:16:20,411 INFO [RMIServerILService] Starting
                            19:16:20,591 INFO [RMIServerILService] Started
                            19:16:20,591 INFO [OILServerILService] Starting
                            19:16:20,591 INFO [OILServerILService] JBossMQ OIL service available at : 0.0.0.0/0.0.0.0:8090
                            19:16:20,661 INFO [OILServerILService] Started
                            19:16:20,661 INFO [UILServerILService] Starting
                            19:16:20,661 INFO [UILServerILService] JBossMQ UIL service available at : 0.0.0.0/0.0.0.0:8091
                            19:16:20,701 INFO [UILServerILService] Started
                            19:16:20,701 INFO [DLQ] Starting
                            19:16:20,701 INFO [DLQ] Bound to JNDI name: queue/DLQ
                            19:16:20,701 INFO [DLQ] Started
                            19:16:20,711 INFO [MainDeployer] Deployed package: file:/C:/Programs/JBoss/jboss-3.0.4/server/default/deploy/jbossmq-se
                            rvice.xml
                            


                            -- Juha


                            • 11. Re: MBean depends for Topic ConnectionFactory
                              brucec Newbie

                              You are absolutely correct, the correct depends for this is:
                              jboss.mq:service=InvocationLayer,type=OIL

                              Somehow I had combined thoughts from earlier replies and via experimentation found this JUST as your reply came through.

                              Thank you all - finally over this stumbling block.
                              On to others I suppose ;-)