3 Replies Latest reply on May 8, 2006 11:26 AM by mskonda

    Using JMS in Jboss

    chrischris

      Hey,

      ich just have a problem realizing jms over the jboss server. Actually, if you want to implement a JMS-Producer or JMS-Consumer you need to define a ?*-servie.xml? file which hast to be copied in the deployed directory of the server and it has to be in Classpath off the consumer. So this file hast to be on the client side as well. So, is there a way to put the information of the ?-service.xml? in the code of the client, so that it don´t have to be in the classpath any more? I need that for a very special implementation

      kind regards

      Chris

        • 1. Re: Using JMS in Jboss

          I am not sure whether I got your question right.

          But, *-service.xml is used (one of the uses) to deploy your destinations (for an example, check under, deploy\jboss-messaging.sar\destination-service.xml)

          <service>
           ....
          <mbean code="org.jboss.jms.server.destination.Queue"
           name="jboss.messaging.destination:service=Queue,name=ex"
           xmbean-dd="xmdesc/Queue-xmbean.xml">
           <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
           </mbean>
          </service>
          


          So, if your producer has to send messages to a queue ex, the above file deploys the respective queue in the messaging server.

          Now,if you have a producer or consumer, all it has to do is to find the destination name from JNDI. So, for example,
          Destination queue = (Destination) initialContext.lookup("ex");
          

          will look up the previously deployed queue and fire/consume messages respectively.

          so, if I get your question right, you don't need *-service.xml in the classpath of the client. All the client needs is jndi.properties (if you don't want to hard code your jndi properties in the code).

          Thanks
          /K

          • 2. Re: Using JMS in Jboss
            chrischris

            Hey,

            thank u for your answer. I did what u said, but I got another problem.

            This is a part of my Code:

            _____________________________________________________
            ...
            ...
            ...
            Properties properties = new Properties();

            properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

            properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");

            properties.put(Context.PROVIDER_URL, "localhost");

            ctx = new InitialContext(properties);
            ...
            ...
            ...
            _____________________________________________________

            and when I start it, than I get the following ecxeption, and I have noch clue what that realy mean, and what I can do...

            _____________________________________________________
            failed to start bundle JmsQueueStubBundle
            [stderr] javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
            [stderr] at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
            [stderr] at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
            [stderr] at javax.naming.InitialContext.init(Unknown Source)
            [stderr] at javax.naming.InitialContext.(Unknown Source)
            [stderr] at jmsQueueStubBundlePackage.Activator.start(Activator.java:67)
            [stderr] at org.knopflerfish.framework.BundleImpl$1.run(BundleImpl.java:281)
            ...
            ...
            ...
            _____________________________________________________


            • 3. Re: Using JMS in Jboss

              It says the NamingContextFactory class is not found - add jnp-client.jar to your client classpath (it is found in $JBOSS_HOME/client directory)

              Thanks
              /K