<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions in java.jmx</title>
<link>https://ask.clojure.org/index.php/questions/contrib-libs/java-jmx</link>
<description></description>
<item>
<title>&quot;jmx/with-connection&quot; function throws NullPointerException if provided &quot;{:url nil}&quot;</title>
<link>https://ask.clojure.org/index.php/7212/connection-function-throws-nullpointerexception-provided</link>
<description>According to the java.jmx doc:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-------------------------&lt;br /&gt;
clojure.java.jmx/with-connection&lt;br /&gt;
([opts &amp;amp; body])&lt;br /&gt;
Macro&lt;br /&gt;
&amp;nbsp;&amp;nbsp;Execute body with a JMX connection created based on opts. opts can include [default]:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;:protocol &amp;nbsp;&amp;nbsp;&amp;nbsp;The protocol to use [rmi:///jndi/rmi]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;:host &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The host to connect to [localhost]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;:port &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The port to connect to [3000]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;:jndi-path &amp;nbsp;&amp;nbsp;The jndi-path to use [jmxuri]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;:url &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;The full url (as a String) to use instead of generating a rmi url from&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;the above options [nil]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;:environment A map representing the environment used for the connection.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;See JMXConnectorFactory/connect for details [{}]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The description indicates :url is by default 'nil', and when it is not, it will be used instead of options above.&lt;br /&gt;
&lt;br /&gt;
However, if I called the function with :url=nil and other options, it will use the nil url anyway, and ignore other options.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=&amp;gt; (jmx/with-connection {:url nil :host &amp;quot;localhost&amp;quot;} (jmx/mbean-names &amp;quot;*:*&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
NullPointerException &amp;nbsp;&amp;nbsp;javax.management.remote.JMXServiceURL.&amp;lt;init&amp;gt; (JMXServiceURL.java:142)&lt;br /&gt;
=&amp;gt; (jmx/with-connection {:host &amp;quot;localhost&amp;quot;} (jmx/mbean-names &amp;quot;*:*&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
ConnectException Connection refused (Connection refused) &amp;nbsp;java.net.PlainSocketImpl.socketConnect (PlainSocketImpl.java:-2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I checked the code: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
(JMXServiceURL. (:url opts# (jmx-url opts#)))&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I believe the intention here is to fallback to (jmx-url opts#) when either there's no :url key or :url is nil (as said in doc also)&lt;br /&gt;
&lt;br /&gt;
But the actual behavior is not falling back, if opts# contains :url =&amp;gt; nil.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=&amp;gt; (:url {:url nil :foo &amp;quot;bar&amp;quot;} &amp;quot;fallback&amp;quot;)&lt;br /&gt;
nil&lt;br /&gt;
=&amp;gt; (:url {:foo &amp;quot;bar&amp;quot;} &amp;quot;fallback&amp;quot;)&lt;br /&gt;
&amp;quot;fallback&amp;quot;&lt;br /&gt;
</description>
<category>java.jmx</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7212/connection-function-throws-nullpointerexception-provided</guid>
<pubDate>Tue, 18 Dec 2018 02:55:11 +0000</pubDate>
</item>
<item>
<title>Allow writable jmx beans attributes</title>
<link>https://ask.clojure.org/index.php/7207/allow-writable-jmx-beans-attributes</link>
<description>&lt;p&gt;This is the follow up to &lt;a rel=&quot;nofollow&quot; href=&quot;https://dev.clojure.org/jira/browse/JMX-16&quot;&gt;https://dev.clojure.org/jira/browse/JMX-16&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For the attribute to be writable via JMX it has to be set as writable - see (link: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/java.jmx/blob/master/src/main/clojure/clojure/java/jmx.clj#L171&quot;&gt;https://github.com/clojure/java.jmx/blob/master/src/main/clojure/clojure/java/jmx.clj#L171&lt;/a&gt; text: build-attribute-info).&lt;br&gt;
That is, Bean deftype implements setAttribute, but implementation of getMBeanInfo calls 2-arity version of map-&amp;gt;attribute-infos without an option to set an attribute as writable.&lt;/p&gt;
</description>
<category>java.jmx</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7207/allow-writable-jmx-beans-attributes</guid>
<pubDate>Mon, 27 Nov 2017 22:34:32 +0000</pubDate>
</item>
<item>
<title>Throw exception when overloaded operation is ambiguous</title>
<link>https://ask.clojure.org/index.php/7209/throw-exception-when-overloaded-operation-is-ambiguous</link>
<description>&lt;p&gt;The {{clojure.java.jmx/invoke}} function invokes the first method it finds with a matching name, even if that method's signature does not match the type or number of arguments passed to {{invoke}}.&lt;/p&gt;
&lt;p&gt;The correct usage is to call {{invoke-signature}}, explicitly specifying which method signature to call.&lt;/p&gt;
&lt;p&gt;{{invoke}} could theoretically examine its arguments and guess the correct signature to call. But without that, it is better to have it throw an exception when the method overloading is ambiguous, instead of just taking the first signature.&lt;/p&gt;
</description>
<category>java.jmx</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7209/throw-exception-when-overloaded-operation-is-ambiguous</guid>
<pubDate>Tue, 26 Nov 2013 19:40:11 +0000</pubDate>
</item>
<item>
<title>Eliminate several uses of reflection in java.jmx</title>
<link>https://ask.clojure.org/index.php/7210/eliminate-several-uses-of-reflection-in-java-jmx</link>
<description>&lt;p&gt;There are a fair number of occurrences of reflection in java.jmx that can be eliminated with the addition of suitable type hints.&lt;/p&gt;
</description>
<category>java.jmx</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7210/eliminate-several-uses-of-reflection-in-java-jmx</guid>
<pubDate>Mon, 29 Oct 2012 05:49:17 +0000</pubDate>
</item>
<item>
<title>Extend java.jmx to support exposing operations in created beans</title>
<link>https://ask.clojure.org/index.php/7211/extend-java-jmx-support-exposing-operations-created-beans</link>
<description>&lt;p&gt;The attached patch extends java.jmx to support creating beans that expose invokable operations.  Operation function definitions are supplied after the state-ref in the create-bean form in a syntax similar to protocol method implementations.  Type signatures, descriptions, and impact constants are harvested from metadata on the operation definitions.  Nontrivial argument type binders (rest arguments, destructuring, etc) in operations are not supported.&lt;/p&gt;
&lt;p&gt;I am sure this patch could be improved in many ways; the operation method parser in create-bean feels unnecessarily hairy and yet limited at the same time, because my macro-fu is not yet strong.  The documentation examples are not yet updated, though I am happy to do this if the feature is reviewed and accepted.&lt;/p&gt;
</description>
<category>java.jmx</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7211/extend-java-jmx-support-exposing-operations-created-beans</guid>
<pubDate>Fri, 31 Aug 2012 21:43:37 +0000</pubDate>
</item>
<item>
<title>Timeout support</title>
<link>https://ask.clojure.org/index.php/7208/timeout-support</link>
<description>&lt;p&gt;In the current java.jmx code there is no way to explicitly setup connection timeout when is used with-connection macro. This option can be quite useful, especially when client is trying to connect to unreliable jmx host or on location where client doesn't know jmx is enabled.&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;http://weblogs.java.net/blog/emcmanus/archive/2007/05/making_a_jmx_co.html&quot;&gt;http://weblogs.java.net/blog/emcmanus/archive/2007/05/making_a_jmx_co.html&lt;/a&gt; can be used as starting point.&lt;/p&gt;
</description>
<category>java.jmx</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/7208/timeout-support</guid>
<pubDate>Wed, 07 Mar 2012 11:29:59 +0000</pubDate>
</item>
</channel>
</rss>