「MX4J note」の編集履歴(バックアップ)一覧はこちら
「MX4J note」(2005/12/26 (月) 01:59:08) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
* Trying to run MX4J 3.0.1 examples...
** javax.management.NotCompliantMBeanException: MBean is not compliant
C:\usr\local\mx4j-3.0.1\examples>java -cp \usr\local\lib\mx4j.jar;. mx4j.example
s.services.relation.RelationServiceExample
Creating RelationService in the MBeanServer
----------------------- done ----------------------------
create the relationType
The RelationType Names found in the RelationService: [personal_library]
----------------------- done ----------------------------
create RelationId for the relationType
----------------------- done ----------------------------
Creating MBeans to represent our relations
Could Not create the RelationService: javax.management.ReflectionException: The
MBean class could not be loaded by the context classloader
javax.management.ReflectionException: The MBean class could not be loaded by the
context classloader
at com.sun.jmx.mbeanserver.MBeanInstantiatorImpl.loadClass(Unknown Sourc
e)
at com.sun.jmx.mbeanserver.MBeanInstantiatorImpl.findClass(Unknown Sourc
e)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.createMBean(Unk
nown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.createMBean(Unk
nown Source)
at com.sun.jmx.mbeanserver.JmxMBeanServer.createMBean(Unknown Source)
at mx4j.examples.services.relation.RelationServiceExample.setUpRelations
(RelationServiceExample.java:93)
at mx4j.examples.services.relation.RelationServiceExample.main(RelationS
erviceExample.java:337)
Caused by: java.lang.ClassNotFoundException: mx4j/examples/services/relation/Sim
pleBooks
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
... 7 more
Cleaning up......
// Some docs on the net suggests using a property...
C:\usr\local\mx4j-3.0.1\examples>java -Djavax.management.builder.initial=mx4j.se
rver.MX4JMBeanServerBuilder -cp \usr\local\lib\mx4j.jar;. mx4j.examples.services
.relation.RelationServiceExample
Creating RelationService in the MBeanServer
----------------------- done ----------------------------
create the relationType
The RelationType Names found in the RelationService: [personal_library]
----------------------- done ----------------------------
create RelationId for the relationType
----------------------- done ----------------------------
Creating MBeans to represent our relations
Could Not create the RelationService: javax.management.NotCompliantMBeanExceptio
n: MBean is not compliant
javax.management.NotCompliantMBeanException: MBean is not compliant
at mx4j.server.MX4JMBeanServer.registerImpl(MX4JMBeanServer.java:818)
at mx4j.server.MX4JMBeanServer.createMBean(MX4JMBeanServer.java:745)
at mx4j.examples.services.relation.RelationServiceExample.setUpRelations
(RelationServiceExample.java:93)
at mx4j.examples.services.relation.RelationServiceExample.main(RelationS
erviceExample.java:337)
Cleaning up......
// It still fails !!
// Tried 1.4...
C:\usr\local\mx4j-3.0.1\examples>\j2sdk1.4.2_08\bin\java -cp \usr\local\lib\mx4j
.jar;. mx4j.examples.services.relation.RelationServiceExample
Created MBeanServer with ID: 158b649:108629c5b34:-8000:dcube:1
Creating RelationService in the MBeanServer
----------------------- done ----------------------------
create the relationType
The RelationType Names found in the RelationService: [personal_library]
----------------------- done ----------------------------
create RelationId for the relationType
----------------------- done ----------------------------
Creating MBeans to represent our relations
Could Not create the RelationService: javax.management.NotCompliantMBeanExceptio
n: MBean is not compliant
javax.management.NotCompliantMBeanException: MBean is not compliant
at mx4j.server.MX4JMBeanServer.registerImpl(MX4JMBeanServer.java:818)
at mx4j.server.MX4JMBeanServer.createMBean(MX4JMBeanServer.java:745)
at mx4j.examples.services.relation.RelationServiceExample.setUpRelations
(RelationServiceExample.java:93)
at mx4j.examples.services.relation.RelationServiceExample.main(RelationS
erviceExample.java:337)
Cleaning up......
// It still does not work!!
----
* 基本に戻って HelloWorldExample
やはり、そのままでは動かない...
Java 5.0 では Server を取得し、MBean を登録するだけで、後は適切な
com.sun.management.jmxremote プロパティを指定すればそれで JConsole
からみえるようになるが、MX4J ではそうはならない。コネクタ周りの造りが
違うということだ。
mx4j.examples.remote.simple.Server から名前登録らしき部分を
借用。しかし、このままでは bind のエラーが出る。おそらく JBoss が
同じように 1099 に rmiregistry サービスを起動しているため。
JBoss をとめると最終的には動作した。
動作するまでに、いくつか ClassNotFoundException を解決する
必要があった。mx4j.jar はすべてを含んでいるわけではなく、
mx4j-remote.jar, mx4j-tools.jar もクラスパスに含める必要が
あった。
// Create an instance of MBeanServer
MBeanServer server = MBeanServerFactory.createMBeanServer();
// Create an ObjectName for the MBean
ObjectName name = new ObjectName(":mbean=helloworld");
// Create and register the MBean in the MBeanServer
server.createMBean("mx4j.examples.mbeans.helloworld.HelloWorld", name, null);
// Invoke a method on it
server.invoke(name, "reloadConfiguration", new Object[0], new String[0]);
///////////////////// Begin Additional Code
ObjectName namingName = ObjectName.getInstance("naming:type=rmiregistry");
server.createMBean("mx4j.tools.naming.NamingService", namingName, null);
server.invoke(namingName, "start", null, null);
int namingPort = ((Integer)server.getAttribute(namingName, "Port")).intValue();
// int namingPort = 1099;
String jndiPath = "/jmxconnector";
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost/jndi/rmi://localhost:" + namingPort + jndiPath);
// Create and start the RMIConnectorServer
JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
connectorServer.start();
System.out.println("namingPort="+namingPort);
///////////////////// End Additionall Code
// Invoke an attribute on it
Integer times = (Integer)server.getAttribute(name, "HowManyTimes");
System.out.println("The configuration was reloaded " + times + " times.");
try { Thread.sleep(1000*1000); } catch (Exception e) {}
* Trying to run MX4J 3.0.1 examples...
** javax.management.NotCompliantMBeanException: MBean is not compliant
C:\usr\local\mx4j-3.0.1\examples>java -cp \usr\local\lib\mx4j.jar;. mx4j.example
s.services.relation.RelationServiceExample
Creating RelationService in the MBeanServer
----------------------- done ----------------------------
create the relationType
The RelationType Names found in the RelationService: [personal_library]
----------------------- done ----------------------------
create RelationId for the relationType
----------------------- done ----------------------------
Creating MBeans to represent our relations
Could Not create the RelationService: javax.management.ReflectionException: The
MBean class could not be loaded by the context classloader
javax.management.ReflectionException: The MBean class could not be loaded by the
context classloader
at com.sun.jmx.mbeanserver.MBeanInstantiatorImpl.loadClass(Unknown Sourc
e)
at com.sun.jmx.mbeanserver.MBeanInstantiatorImpl.findClass(Unknown Sourc
e)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.createMBean(Unk
nown Source)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.createMBean(Unk
nown Source)
at com.sun.jmx.mbeanserver.JmxMBeanServer.createMBean(Unknown Source)
at mx4j.examples.services.relation.RelationServiceExample.setUpRelations
(RelationServiceExample.java:93)
at mx4j.examples.services.relation.RelationServiceExample.main(RelationS
erviceExample.java:337)
Caused by: java.lang.ClassNotFoundException: mx4j/examples/services/relation/Sim
pleBooks
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
... 7 more
Cleaning up......
// Some docs on the net suggests using a property...
C:\usr\local\mx4j-3.0.1\examples>java -Djavax.management.builder.initial=mx4j.se
rver.MX4JMBeanServerBuilder -cp \usr\local\lib\mx4j.jar;. mx4j.examples.services
.relation.RelationServiceExample
Creating RelationService in the MBeanServer
----------------------- done ----------------------------
create the relationType
The RelationType Names found in the RelationService: [personal_library]
----------------------- done ----------------------------
create RelationId for the relationType
----------------------- done ----------------------------
Creating MBeans to represent our relations
Could Not create the RelationService: javax.management.NotCompliantMBeanExceptio
n: MBean is not compliant
javax.management.NotCompliantMBeanException: MBean is not compliant
at mx4j.server.MX4JMBeanServer.registerImpl(MX4JMBeanServer.java:818)
at mx4j.server.MX4JMBeanServer.createMBean(MX4JMBeanServer.java:745)
at mx4j.examples.services.relation.RelationServiceExample.setUpRelations
(RelationServiceExample.java:93)
at mx4j.examples.services.relation.RelationServiceExample.main(RelationS
erviceExample.java:337)
Cleaning up......
// It still fails !!
// Tried 1.4...
C:\usr\local\mx4j-3.0.1\examples>\j2sdk1.4.2_08\bin\java -cp \usr\local\lib\mx4j
.jar;. mx4j.examples.services.relation.RelationServiceExample
Created MBeanServer with ID: 158b649:108629c5b34:-8000:dcube:1
Creating RelationService in the MBeanServer
----------------------- done ----------------------------
create the relationType
The RelationType Names found in the RelationService: [personal_library]
----------------------- done ----------------------------
create RelationId for the relationType
----------------------- done ----------------------------
Creating MBeans to represent our relations
Could Not create the RelationService: javax.management.NotCompliantMBeanExceptio
n: MBean is not compliant
javax.management.NotCompliantMBeanException: MBean is not compliant
at mx4j.server.MX4JMBeanServer.registerImpl(MX4JMBeanServer.java:818)
at mx4j.server.MX4JMBeanServer.createMBean(MX4JMBeanServer.java:745)
at mx4j.examples.services.relation.RelationServiceExample.setUpRelations
(RelationServiceExample.java:93)
at mx4j.examples.services.relation.RelationServiceExample.main(RelationS
erviceExample.java:337)
Cleaning up......
// It still does not work!!
----
* 基本に戻って HelloWorldExample
やはり、そのままでは動かない...
Java 5.0 では Server を取得し、MBean を登録するだけで、後は適切な
com.sun.management.jmxremote プロパティを指定すればそれで JConsole
からみえるようになるが、MX4J ではそうはならない。コネクタ周りの造りが
違うということだ。
mx4j.examples.remote.simple.Server から名前登録らしき部分を
借用。しかし、このままでは bind のエラーが出る。おそらく JBoss が
同じように 1099 に rmiregistry サービスを起動しているため。
JBoss をとめると最終的には動作した。
動作するまでに、いくつか ClassNotFoundException を解決する
必要があった。mx4j.jar はすべてを含んでいるわけではなく、
mx4j-remote.jar, mx4j-tools.jar もクラスパスに含める必要が
あった。
// Create an instance of MBeanServer
MBeanServer server = MBeanServerFactory.createMBeanServer();
// Create an ObjectName for the MBean
ObjectName name = new ObjectName(":mbean=helloworld");
// Create and register the MBean in the MBeanServer
server.createMBean("mx4j.examples.mbeans.helloworld.HelloWorld", name, null);
// Invoke a method on it
server.invoke(name, "reloadConfiguration", new Object[0], new String[0]);
///////////////////// Begin Additional Code
ObjectName namingName = ObjectName.getInstance("naming:type=rmiregistry");
server.createMBean("mx4j.tools.naming.NamingService", namingName, null);
server.invoke(namingName, "start", null, null);
int namingPort = ((Integer)server.getAttribute(namingName, "Port")).intValue();
// int namingPort = 1099;
String jndiPath = "/jmxconnector";
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://localhost/jndi/rmi://localhost:" + namingPort + jndiPath);
// Create and start the RMIConnectorServer
JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);
connectorServer.start();
System.out.println("namingPort="+namingPort);
///////////////////// End Additionall Code
// Invoke an attribute on it
Integer times = (Integer)server.getAttribute(name, "HowManyTimes");
System.out.println("The configuration was reloaded " + times + " times.");
try { Thread.sleep(1000*1000); } catch (Exception e) {}
MC4J 1.2 beta 9 で接続を確認。コネクタタイプは JSR160 で属性は次のとおり
| Auto Connecte | No |
| classPathEntries | [] |
| Connection Name | Hello |
| Credentials | <blank> |
| Initial Context Factory | com.sun.jndi.rmi.registry.RetistryContext |
| JNDI Name | <blank> |
| libraryRUI | null |
| Live Tree | No |
| Principal | <blank> |
| Server URL | service:jmx:rmi:///jndi/rmi://localhost:1099/jmxconnector |
| Connection Type | <no property editor> |