{"id":75810,"date":"2020-01-20T12:14:53","date_gmt":"2020-01-20T06:44:53","guid":{"rendered":"https:\/\/www.vskills.in\/certification\/tutorial\/?p=75810"},"modified":"2024-04-12T14:33:58","modified_gmt":"2024-04-12T09:03:58","slug":"manage-tomcat-with-jmx-remote-ant-tasks","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/","title":{"rendered":"Manage Tomcat with JMX remote Ant Tasks"},"content":{"rendered":"<p>To simplify JMX usage with Ant 1.6.x, a set of tasks is provided that may be used with antlib.<\/p>\n<p><strong>antlib:<\/strong> Copy your catalina-ant.jar from $CATALINA_HOME\/lib to $ANT_HOME\/lib.<\/p>\n<p>The following example shows the JMX Accessor usage:<\/p>\n<p>Note: The name attribute value was wrapped here to be more readable. It has to be all on the same line, without spaces.<\/p>\n<p>&lt;project name=&#8221;Catalina Ant JMX&#8221;<\/p>\n<p>xmlns:jmx=&#8221;antlib:org.apache.catalina.ant.jmx&#8221;<\/p>\n<p>default=&#8221;state&#8221;<\/p>\n<p>basedir=&#8221;.&#8221;&gt;<\/p>\n<p>&lt;property name=&#8221;jmx.server.name&#8221; value=&#8221;localhost&#8221; \/&gt;<\/p>\n<p>&lt;property name=&#8221;jmx.server.port&#8221; value=&#8221;9012&#8243; \/&gt;<\/p>\n<p>&lt;property name=&#8221;cluster.server.address&#8221; value=&#8221;192.168.1.75&#8243; \/&gt;<\/p>\n<p>&lt;property name=&#8221;cluster.server.port&#8221; value=&#8221;9025&#8243; \/&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;target name=&#8221;state&#8221; description=&#8221;Show JMX Cluster state&#8221;&gt;<\/p>\n<p>&lt;jmx:open<\/p>\n<p>host=&#8221;${jmx.server.name}&#8221;<\/p>\n<p>port=&#8221;${jmx.server.port}&#8221;<\/p>\n<p>username=&#8221;controlRole&#8221;<\/p>\n<p>password=&#8221;tomcat&#8221;\/&gt;<\/p>\n<p>&lt;jmx:get<\/p>\n<p>name=<\/p>\n<p>&#8220;Catalina:type=IDataSender,host=localhost,<\/p>\n<p>senderAddress=${cluster.server.address},senderPort=${cluster.server.port}&#8221;<\/p>\n<p>attribute=&#8221;connected&#8221;<\/p>\n<p>resultproperty=&#8221;IDataSender.backup.connected&#8221;<\/p>\n<p>echo=&#8221;false&#8221;<\/p>\n<p>\/&gt;<\/p>\n<p>&lt;jmx:get<\/p>\n<p>name=&#8221;Catalina:type=ClusterSender,host=localhost&#8221;<\/p>\n<p>attribute=&#8221;senderObjectNames&#8221;<\/p>\n<p>resultproperty=&#8221;senderObjectNames&#8221;<\/p>\n<p>echo=&#8221;false&#8221;<\/p>\n<p>\/&gt;<\/p>\n<p>&lt;!&#8211; get current maxActiveSession from ClusterTest application<\/p>\n<p>echo it to Ant output and store at<\/p>\n<p>property &lt;em&gt;clustertest.maxActiveSessions.orginal&lt;\/em&gt;<\/p>\n<p>&#8211;&gt;<\/p>\n<p>&lt;jmx:get<\/p>\n<p>name=&#8221;Catalina:type=Manager,context=\/ClusterTest,host=localhost&#8221;<\/p>\n<p>attribute=&#8221;maxActiveSessions&#8221;<\/p>\n<p>resultproperty=&#8221;clustertest.maxActiveSessions.orginal&#8221;<\/p>\n<p>echo=&#8221;true&#8221;<\/p>\n<p>\/&gt;<\/p>\n<p>&lt;!&#8211; set maxActiveSession to 100<\/p>\n<p>&#8211;&gt;<\/p>\n<p>&lt;jmx:set<\/p>\n<p>name=&#8221;Catalina:type=Manager,context=\/ClusterTest,host=localhost&#8221;<\/p>\n<p>attribute=&#8221;maxActiveSessions&#8221;<\/p>\n<p>value=&#8221;100&#8243;<\/p>\n<p>type=&#8221;int&#8221;<\/p>\n<p>\/&gt;<\/p>\n<p>&lt;!&#8211; get all sessions and split result as delimiter &lt;em&gt;SPACE&lt;\/em&gt; for easy<\/p>\n<p>access all session ids directly with Ant property sessions.[0..n].<\/p>\n<p>&#8211;&gt;<\/p>\n<p>&lt;jmx:invoke<\/p>\n<p>name=&#8221;Catalina:type=Manager,context=\/ClusterTest,host=localhost&#8221;<\/p>\n<p>operation=&#8221;listSessionIds&#8221;<\/p>\n<p>resultproperty=&#8221;sessions&#8221;<\/p>\n<p>echo=&#8221;false&#8221;<\/p>\n<p>delimiter=&#8221; &#8221;<\/p>\n<p>\/&gt;<\/p>\n<p>&lt;!&#8211; Access session attribute &lt;em&gt;Hello&lt;\/em&gt; from first session.<\/p>\n<p>&#8211;&gt;<\/p>\n<p>&lt;jmx:invoke<\/p>\n<p>name=&#8221;Catalina:type=Manager,context=\/ClusterTest,host=localhost&#8221;<\/p>\n<p>operation=&#8221;getSessionAttribute&#8221;<\/p>\n<p>resultproperty=&#8221;Hello&#8221;<\/p>\n<p>echo=&#8221;false&#8221;<\/p>\n<p>&gt;<\/p>\n<p>&lt;arg value=&#8221;${sessions.0}&#8221;\/&gt;<\/p>\n<p>&lt;arg value=&#8221;Hello&#8221;\/&gt;<\/p>\n<p>&lt;\/jmx:invoke&gt;<\/p>\n<p>&lt;!&#8211; Query for all application manager.of the server from all hosts<\/p>\n<p>and bind all attributes from all found manager MBeans.<\/p>\n<p>&#8211;&gt;<\/p>\n<p>&lt;jmx:query<\/p>\n<p>name=&#8221;Catalina:type=Manager,*&#8221;<\/p>\n<p>resultproperty=&#8221;manager&#8221;<\/p>\n<p>echo=&#8221;true&#8221;<\/p>\n<p>attributebinding=&#8221;true&#8221;<\/p>\n<p>\/&gt;<\/p>\n<p>&lt;!&#8211; echo the create properties &#8211;&gt;<\/p>\n<p>&lt;echo&gt;<\/p>\n<p>senderObjectNames: ${senderObjectNames.0}<\/p>\n<p>&nbsp;<\/p>\n<p>IDataSender.backup.connected: ${IDataSender.backup.connected}<\/p>\n<p>session: ${sessions.0}<\/p>\n<p>manager.length: ${manager.length}<\/p>\n<p>manager.0.name: ${manager.0.name}<\/p>\n<p>manager.1.name: ${manager.1.name}<\/p>\n<p>hello: ${Hello}<\/p>\n<p>manager.ClusterTest.0.name: ${manager.ClusterTest.0.name}<\/p>\n<p>manager.ClusterTest.0.activeSessions: ${manager.ClusterTest.0.activeSessions}<\/p>\n<p>manager.ClusterTest.0.counterSend_EVT_SESSION_EXPIRED:<\/p>\n<p>${manager.ClusterTest.0.counterSend_EVT_SESSION_EXPIRED}<\/p>\n<p>manager.ClusterTest.0.counterSend_EVT_GET_ALL_SESSIONS:<\/p>\n<p>${manager.ClusterTest.0.counterSend_EVT_GET_ALL_SESSIONS}<\/p>\n<p>&lt;\/echo&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;\/target&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;\/project&gt;<\/p>\n<p><strong>import:<\/strong>Import the JMX Accessor Project with &lt;import file=&#8221;${CATALINA.HOME}\/bin\/catalina-tasks.xml&#8221; \/&gt; and reference the tasks with jmxOpen, jmxSet, jmxGet, jmxQuery, jmxInvoke, jmxEquals and jmxCondition.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To simplify JMX usage with Ant 1.6.x, a set of tasks is provided that may be used with antlib. antlib: Copy your catalina-ant.jar from $CATALINA_HOME\/lib to $ANT_HOME\/lib. The following example shows the JMX Accessor usage: Note: The name attribute value was wrapped here to be more readable. It has to be all on the same&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[8678],"tags":[8819],"class_list":["post-75810","page","type-page","status-publish","hentry","category-tomcat","tag-manage-tomcat-with-jmx-remote-ant-tasks"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Manage Tomcat with JMX remote Ant Tasks - Tutorial<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Manage Tomcat with JMX remote Ant Tasks - Tutorial\" \/>\n<meta property=\"og:description\" content=\"To simplify JMX usage with Ant 1.6.x, a set of tasks is provided that may be used with antlib. antlib: Copy your catalina-ant.jar from $CATALINA_HOME\/lib to $ANT_HOME\/lib. The following example shows the JMX Accessor usage: Note: The name attribute value was wrapped here to be more readable. It has to be all on the same...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T09:03:58+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/\",\"name\":\"Manage Tomcat with JMX remote Ant Tasks - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2020-01-20T06:44:53+00:00\",\"dateModified\":\"2024-04-12T09:03:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Manage Tomcat with JMX remote Ant Tasks\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Manage Tomcat with JMX remote Ant Tasks - Tutorial","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/","og_locale":"en_US","og_type":"article","og_title":"Manage Tomcat with JMX remote Ant Tasks - Tutorial","og_description":"To simplify JMX usage with Ant 1.6.x, a set of tasks is provided that may be used with antlib. antlib: Copy your catalina-ant.jar from $CATALINA_HOME\/lib to $ANT_HOME\/lib. The following example shows the JMX Accessor usage: Note: The name attribute value was wrapped here to be more readable. It has to be all on the same...","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T09:03:58+00:00","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/","name":"Manage Tomcat with JMX remote Ant Tasks - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2020-01-20T06:44:53+00:00","dateModified":"2024-04-12T09:03:58+00:00","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/manage-tomcat-with-jmx-remote-ant-tasks\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Manage Tomcat with JMX remote Ant Tasks"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/75810","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=75810"}],"version-history":[{"count":3,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/75810\/revisions"}],"predecessor-version":[{"id":76502,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/75810\/revisions\/76502"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=75810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=75810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=75810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}