[jboss-user] [JBoss Messaging] - Re: JBoss 5.0.1, how to create new topic

maxogm do-not-reply at jboss.com
Tue Apr 28 23:33:27 EDT 2009


I try that example yesterday, and always I got


  | Unable to find operation createQueue(java.lang.String,java.lang.String)
  | 

This is my example:

  | package com.jboss.test;
  | 
  | import java.util.Properties;
  | 
  | import javax.management.MBeanServerConnection;
  | import javax.management.ObjectName;
  | import javax.naming.Context;
  | import javax.naming.InitialContext;
  | import javax.naming.NameNotFoundException;
  | 
  | 
  | public class MakeQueue {
  | 
  | 	public static void main(String[] args) throws Exception {
  | 
  | 		Properties props = new Properties();
  | 		props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
  | 		props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");
  | 		props.put(Context.PROVIDER_URL, "jnp://localhost:1100");
  | 
  | 		InitialContext iniCtx = new InitialContext(props);
  | 
  | 		try{
  | 			iniCtx.lookup("queue/test");
  | 		}catch (NameNotFoundException e) {
  | 
  | 
  | 			MBeanServerConnection mBeanServer = lookupMBeanServerProxy(iniCtx);
  | 
  | 			ObjectName serverObjectName = new ObjectName("jboss.messaging:service=ServerPeer");
  | 
  | 			String queueName = "test";
  | 
  | 			mBeanServer.invoke(serverObjectName, "createQueue",
  | 					new Object[] {queueName, "queue/test"},
  | 					new String[] {"java.lang.String", "java.lang.String"});
  | 
  | 		}
  | 	}
  | 
  | 	private static MBeanServerConnection lookupMBeanServerProxy(InitialContext ic) throws Exception
  | 	{
  | 		if (ic == null)
  | 		{   	  
  | 			ic = new InitialContext();
  | 		}
  | 		return (MBeanServerConnection)ic.lookup("jmx/invoker/RMIAdaptor");
  | 	}
  | 
  | }
  | 

In build path I include all jar from JBoss 5.0.1/client and jboss-messaging.jar

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4227418#4227418

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4227418



More information about the jboss-user mailing list