0 Replies Latest reply on May 3, 2013 8:25 AM by mayank.gupta

    Create queue at Runtime

    mayank.gupta

      Hi All ,

       

      I have the requirement to create the queue at runtime , below is the code that i am using but i am getting exception , is there anybody to help me ? I have also tried to replace the log4j-1.2.17.jar version to replace the old log4j.jar version , but this won't work again. I need the help from all of you.

       

      public class ManagementExample

      {

         public static void main(final String[] args) throws Exception

         {

            ModelControllerClient client = null;

            ModelNode op = new ModelNode();

            ModelNode address = op.get(ClientConstants.OP_ADDR);

            address.add("subsystem", "messaging");

            address.add("hornetq-server", "default");

       

       

            // the name of the queue

            String queue = "myQueue";

            address.add("jms-queue", queue);

       

       

            // the JNDI entries

            ModelNode entries = op.get("entries");

            entries.add("jms/queue/" + queue);

            entries.add("jboss/exported/jms/queue/" + queue);

       

       

            op.get(ClientConstants.OP).set(ClientConstants.ADD);

       

       

            try

            {

               client = ModelControllerClient.Factory.create(InetAddress.getByName("localhost"), 10190);

               ModelNode result = client.execute(op);

               System.out.println(result);

            }

            catch(Exception e)

            {

                      e.printStackTrace();

            }

            finally

            {

               if (client != null)

               {

                  try

                  {

                     client.close();

                  }

                  catch (Exception e)

                  {

                     // no-op

                  }

               }

            }

         }

      }

       

       

      Exception that i am getting is :

       

      Exception in thread "main" java.util.ServiceConfigurationError: org.xnio.XnioProvider: Provider org.xnio.nio.NioXnioProvider could not be instantiated: java.lang.NoSuchMethodError: org.jboss.logging.Logger.tracef(Ljava/lang/String;Ljava/lang/Object;)V

                at java.util.ServiceLoader.fail(ServiceLoader.java:224)

                at java.util.ServiceLoader.access$100(ServiceLoader.java:181)

                at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:377)

                at java.util.ServiceLoader$1.next(ServiceLoader.java:445)

                at org.xnio.Xnio.doGetInstance(Xnio.java:187)

                at org.xnio.Xnio.getInstance(Xnio.java:146)

                at org.jboss.remoting3.Remoting.createEndpoint(Remoting.java:73)

                at org.jboss.as.controller.client.impl.RemotingModelControllerClient.getOrCreateChannel(RemotingModelControllerClient.java:115)

                at org.jboss.as.controller.client.impl.RemotingModelControllerClient$1.getChannel(RemotingModelControllerClient.java:62)

                at org.jboss.as.protocol.mgmt.ManagementChannelHandler.executeRequest(ManagementChannelHandler.java:106)

                at org.jboss.as.protocol.mgmt.ManagementChannelHandler.executeRequest(ManagementChannelHandler.java:89)

                at org.jboss.as.controller.client.impl.AbstractModelControllerClient.executeRequest(AbstractModelControllerClient.java:252)

                at org.jboss.as.controller.client.impl.AbstractModelControllerClient.execute(AbstractModelControllerClient.java:151)

                at org.jboss.as.controller.client.impl.AbstractModelControllerClient.executeForResult(AbstractModelControllerClient.java:137)

                at org.jboss.as.controller.client.impl.AbstractModelControllerClient.execute(AbstractModelControllerClient.java:81)

                at ManagementExample.main(ManagementExample.java:37)

      Caused by: java.lang.NoSuchMethodError: org.jboss.logging.Logger.tracef(Ljava/lang/String;Ljava/lang/Object;)V

                at org.xnio.nio.NioXnio.<init>(NioXnio.java:76)

                at org.xnio.nio.NioXnioProvider.<clinit>(NioXnioProvider.java:34)

                at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

                at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)

                at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

                at java.lang.reflect.Constructor.newInstance(Constructor.java:525)

                at java.lang.Class.newInstance0(Class.java:374)

                at java.lang.Class.newInstance(Class.java:327)

                at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:373)

                ... 13 more