[Mc4j-development] [ mc4j-Bugs-916667 ] ClassCastException
Brought to you by:
ghinkl
From: SourceForge.net <no...@so...> - 2004-03-16 07:50:50
|
Bugs item #916667, was opened at 2004-03-15 06:43 Message generated for change (Comment added) made by nobody You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=493495&aid=916667&group_id=60228 Category: Connections Group: MC4J 1.2b1 Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: ClassCastException Initial Comment: Created MBeanServer with ID: 1e4cbc4:fb4ef2d33c:- 8000:1096782-D:1 RMIConnectorServer started at: service:jmx:rmi://localhost/jndi/jrmp When trying to connect to server via MC4J (V1.2) the following error occurs: A java.lang.ClassCastException exception has occurred. java.lang.ClassCastException at mx4j.rmi.jrmp.JRMPConnector.narrow (JRMPConnector.java:) The connection properties are: Initial Context Factory: com.sun.jndi.rmi.registry.RegistryContextFactory JNDI Name: jmrp Server URL: rmi://localhost:1099 Connection Type: MX4J Source Code: import java.io.IOException; import java.net.MalformedURLException; import java.util.HashMap; import java.util.Map; import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; import javax.management.MBeanException; import javax.management.MBeanRegistrationException; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.MalformedObjectNameException; import javax.management.NotCompliantMBeanException; import javax.management.ObjectName; import javax.management.ReflectionException; import javax.management.remote.JMXConnectorServer; import javax.management.remote.JMXConnectorServerFactory; import javax.management.remote.JMXServiceURL; import javax.naming.Context; /** * @author Michael Behnck */ public class JMXConn { public static void main(String[] args) { // Create a MBeanServer MBeanServer server = MBeanServerFactory.createMBeanServer(); try { // Create and start the naming service ObjectName naming = new ObjectName("Naming:type=rmiregistry"); server.createMBean ("mx4j.tools.naming.NamingService", naming, null); server.invoke (naming, "start", null, null); } catch (InstanceAlreadyExistsException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MBeanRegistrationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NotCompliantMBeanException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstanceNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ReflectionException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MBeanException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MalformedObjectNameException e) { // TODO Auto-generated catch block e.printStackTrace(); } JMXServiceURL address = null; try { // The address of the connector address = new JMXServiceURL("rmi", "localhost", 0, "/jndi/jrmp"); } catch (MalformedURLException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } // Initial Context and Provider URL Map environment = new HashMap(); environment.put (Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.r egistry.RegistryContextFactory"); environment.put (Context.PROVIDER_URL, "rmi://localhost:1099"); JMXConnectorServer cntorServer; try { // Create and start the JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer (address, environment, server); cntorServer.start(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } Thank you, Michael Behnck ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2004-03-15 23:50 Message: Logged In: NO So what would I have to do in order to make a "JSR-160" connection with MC4J (what I'm supposed to do). Everything's working fine when using the MX4J 1.1 RMI connector (JRMP adaptor). Cheers, Michael ---------------------------------------------------------------------- Comment By: Greg Hinkle (ghinkl) Date: 2004-03-15 17:53 Message: Logged In: YES user_id=773314 It looks like your creating a JSR-160 style adaptor and then trying to connect the proprietary mx4j 1.1 rmi connector to it. You want to select "JSR-160" from the connection type in MC4J for this type of connection. (I suppose this is now misleading now that MX4J support JSR-160 style service adaptors. I'll have to fix that.hu) ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=493495&aid=916667&group_id=60228 |