-
1. Re: Remote JMX connector for AS7
kabirkhan Oct 14, 2010 12:43 PM (in response to bosschaert)I am working on it
-
2. Re: Remote JMX connector for AS7
bosschaert Oct 15, 2010 4:01 AM (in response to kabirkhan)Excellent, Kabir! Let me know when you have something I can play with!
-
3. Re: Remote JMX connector for AS7
kabirkhan Oct 15, 2010 9:00 AM (in response to bosschaert)This has been added http://github.com/kabir/jboss-as/commit/83a220ef7abcab8b6e3701d8ba62b72317d29f6f awaiting merge into upstream/master.
To use it from the client, see JMXClientConnectionFactory.main() for an example
-
4. Re: Remote JMX connector for AS7
bosschaert Oct 18, 2010 6:44 AM (in response to kabirkhan)Hi Kabir,
The client side that I have connects using the JMXConnectorFactory.connect() API which I believe is the standard JSR 160 connection API. The URL that's used for it typically looks something like: service:jmx:rmi:///jndi/rmi://localhost:1234/server could you give me an example of how I could use this API to connect? The example that you mention uses a javax.management.remote.rmi.RMIConnector API...
BTW you can also enter a URL like this in JConsole in the 'Remote Process' field when creating a connection.
Thanks,
David
-
5. Re: Remote JMX connector for AS7
smarlow Oct 18, 2010 11:56 AM (in response to bosschaert)Can you try the example code http://community.jboss.org/wiki/WhichRemoteInterfaceShouldIUseForTheMBeanServer "in AS 6.0 M3 or greater".
If that doesn't work, I'll need to update the wiki page. :-)
-
6. Re: Remote JMX connector for AS7
smarlow Oct 18, 2010 12:03 PM (in response to smarlow)Oh, sorry, your trying to create your own jmx connector server. Why not use the one that we already created in AS?
-
7. Re: Remote JMX connector for AS7
kabirkhan Oct 18, 2010 12:09 PM (in response to smarlow)1 of 1 people found this helpfulThis is in AS 7: http://github.com/kabir/jboss-as/commit/83a220ef7abcab8b6e3701d8ba62b72317d29f6f
which is based on the AS 6 one: https://svn.jboss.org/repos/jbossas/trunk/system/src/main/java/org/jboss/system/server/jmx/JMXConnector.java
-
8. Re: Remote JMX connector for AS7
smarlow Oct 18, 2010 2:50 PM (in response to kabirkhan)Yes, but in the linked example code we use javax.management.remote.JMXConnector. I think that answers David's question above an example client.
Also, in the linked page, I mentioned that the example code would work with AS 6 or greater. If that is not true for AS 7, the wiki page should be updated. Since you based the code on the AS 6 code, it should remain true I hope.
-
9. Re: Remote JMX connector for AS7
jason.greene Oct 18, 2010 10:52 PM (in response to kabirkhan)1 of 1 people found this helpfulI committed a variant of Kabir's patch to upstream. It does not use a client socket factory which prevents the need for client code and allows jconsole to work out of the box. Unfortunately this also means that the server requires the java.rmi.server.hostname property to be set if the interface is not the one that matches the hostname. So the changes also add that.
So to connect to a JSR-160 service out of the box with no other code or libs you can do:
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.rmi.registry.RegistryContextFactory"); JMXServiceURL address = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:1090/jmxrmi"); JMXConnector cntor = JMXConnectorFactory.connect(address, env);
This is what jconsole does under the hood.
-
10. Re: Remote JMX connector for AS7
thomas.diesler Oct 19, 2010 5:48 AM (in response to jason.greene)We are still having a hard time to get this to work, which is a prerequisite for all remote OSGi testing (e.g. our Arquillian Hudson integration)
I modifid the JMXConnectorService such that it is more explicit in the URL and also setup a test case that checks the JSR160 connection
http://github.com/jbosgi/jboss-as/commit/78dc6049fd64389ff2e1a9a50e78e6edb213a0ea
[tdiesler@tdvaio jmx]$ mvn -Dtest=JMXConnectorTestCase test
Running org.jboss.as.jmx.JMXConnectorTestCase
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.278 secThe above sets up the JMXConnectorServer in @BeforeClass and checks whether the MBeanServer can be obtained through the connection.
However, in the remote schenario with AS running I get
[tdiesler@tdvaio jmx]$ mvn -Djmx.remote=true -Dtest=JMXConnectorTestCase test
java.rmi.ConnectException: Connection refused to host: 192.168.0.101; nested exception is:
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.list(Unknown Source)at org.jboss.as.jmx.JMXConnectorTestCase.beforeClass(JMXConnectorTestCase.java:71)
The issue seems to be that remote access of the RMI registry fails already.
// Check if the RMI registry is running. With AS started this should succeed.
Registry registry = LocateRegistry.getRegistry(host.getHostAddress(), rmiPort);
String[] objectNames = registry.list();
assertNotNull("Registered RMI objects", objectNames);Any idea, why a remote client cannot access the registry that AS exports?
-
11. Re: Remote JMX connector for AS7
thomas.diesler Oct 19, 2010 6:12 AM (in response to thomas.diesler)Maybe I should add that even with AS running the test succeeds in embedded mode, which means that it successfully can create and register the RMI registry on localhost:1090 which I expected to fail ?!?!
-
12. Re: Remote JMX connector for AS7
thomas.diesler Oct 19, 2010 10:32 AM (in response to bosschaert)Starting the server with -Djava.net.preferIPv4Stack=true seems to be needed on Fedora13
-
13. Re: Remote JMX connector for AS7
bosschaert Oct 19, 2010 10:41 AM (in response to thomas.diesler)Yep - that does the trick - thanks Thomas!
-
14. Re: Remote JMX connector for AS7
bosschaert Oct 29, 2010 5:41 AM (in response to jason.greene)In a similar context, I need to make a back connection from within AS to a VM that runs our test system. This VM exposes the following JMX url: service:jmx:rmi://192.168.153.133:1191/jndi/rmi://192.168.153.133:1190/arquillian-osgi-callback
I can connect to that URLwithout problem from JConsole and from a standalone application that I wrote as an experiment, but when I run the following code inside AS7 it gives me the exception below.
{code}Map<String, Object> env = new HashMap<String, Object>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.rmi.registry.RegistryContextFactory");
JMXServiceURL serviceURL = new JMXServiceURL("service:jmx:rmi://192.168.153.133:1191/jndi/rmi://192.168.153.133:1190/arquillian-osgi-callback");
JMXConnector connector = JMXConnectorFactory.connect(serviceURL, env);{code}
Anyone an idea why the above code doesn't work in AS7 (its the exact code that does work in my standalone app)? Why can't I connect to 192.168.153.133 from inside AS while it's no problem from a standalone application? BTW I did check this both with and without -Djava.net.preferIPv4Stack=true
{code}java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.153.133; nested exception is:
java.net.ConnectException: Connection refused]
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:338)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
at org.jboss.arquillian.osgi.internal.RemoteOSGiContainer.getMBeanServerConnection(RemoteOSGiContainer.java:73)
at org.jboss.arquillian.osgi.internal.AbstractOSGiContainer.getTestArchiveStream(AbstractOSGiContainer.java:165)
at org.jboss.arquillian.osgi.internal.AbstractOSGiContainer.getTestArchive(AbstractOSGiContainer.java:143)
at org.jboss.test.osgi.example.simple.SimpleArchiveProviderTestCase.testBundleInjection(SimpleArchiveProviderTestCase.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.jboss.arquillian.junit.Arquillian$6$1.invoke(Arquillian.java:251)
at org.jboss.arquillian.impl.handler.TestEventExecuter.callback(TestEventExecuter.java:44)
at org.jboss.arquillian.impl.handler.TestEventExecuter.callback(TestEventExecuter.java:34)
at org.jboss.arquillian.impl.event.MapEventManager.fire(MapEventManager.java:63)
at org.jboss.arquillian.impl.context.AbstractEventContext.fire(AbstractEventContext.java:115)
at org.jboss.arquillian.impl.EventTestRunnerAdaptor.test(EventTestRunnerAdaptor.java:160)
at org.jboss.arquillian.junit.Arquillian$6.evaluate(Arquillian.java:244)
at org.jboss.arquillian.junit.Arquillian$4.evaluate(Arquillian.java:207)
at org.jboss.arquillian.junit.Arquillian$5$1.evaluate(Arquillian.java:225)
at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:297)
at org.jboss.arquillian.junit.Arquillian$5.evaluate(Arquillian.java:221)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.jboss.arquillian.junit.Arquillian$2.evaluate(Arquillian.java:163)
at org.jboss.arquillian.junit.Arquillian$3$1.evaluate(Arquillian.java:186)
at org.jboss.arquillian.junit.Arquillian$MultiStatementExecutor.execute(Arquillian.java:297)
at org.jboss.arquillian.junit.Arquillian$3.evaluate(Arquillian.java:182)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.jboss.arquillian.junit.Arquillian.run(Arquillian.java:127)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
at org.jboss.arquillian.junit.JUnitTestRunner.execute(JUnitTestRunner.java:69)
at org.jboss.arquillian.osgi.internal.JUnitBundleTestRunner.execute(JUnitBundleTestRunner.java:35)
at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethodInternal(JMXTestRunner.java:135)
at org.jboss.arquillian.protocol.jmx.JMXTestRunner.runTestMethod(JMXTestRunner.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:93)
at com.sun.jmx.mbeanserver.StandardMBeanIntrospector.invokeM2(StandardMBeanIntrospector.java:27)
at com.sun.jmx.mbeanserver.MBeanIntrospector.invokeM(MBeanIntrospector.java:208)
at com.sun.jmx.mbeanserver.PerInterface.invoke(PerInterface.java:120)
at com.sun.jmx.mbeanserver.MBeanSupport.invoke(MBeanSupport.java:262)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:836)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:761)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1427)
at javax.management.remote.rmi.RMIConnectionImpl.access$200(RMIConnectionImpl.java:72)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1265)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1360)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:788)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.153.133; nested exception is:
java.net.ConnectException: Connection refused]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:101)
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:107)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1886)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1856)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
... 72 more
Caused by: java.rmi.ConnectException: Connection refused to host: 192.168.153.133; nested exception is:
java.net.ConnectException: Connection refused
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
... 77 more
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.<init>(Socket.java:375)
at java.net.Socket.<init>(Socket.java:189)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
... 82 more{code}