Announcement Announcement Module
Collapse
No announcement yet.
Spring, JMX and Tomcat 5.5 + MC4J 1.2b9 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring, JMX and Tomcat 5.5 + MC4J 1.2b9

    Hi,

    I am trying to make a simple working JMX example with Tomcat 5.5, MC4J 1.2b9.

    I have put a simple Spring applicationContext file with this taken from the Spring JMX tutorial (with the proper contextLoader in web.xml):



    >>>>
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>

    <!-- MBean Server IF NOT RUNNING IN TOMCAT -->

    <!-- bean id="mbeanServer"
    class="org.springframework.jmx.support.MBeanServer FactoryBean" /-->

    <!--
    this bean needs to be eagerly pre-instantiated in order for the exporting to occur;
    this means that it must not be marked as lazily initialized
    -->


    <bean id="exporter"
    class="org.springframework.jmx.export.MBeanExporte r">

    <property name="autodetect" value="true" />
    <!-- property name="server" ref="mbeanServer" /-->

    <property name="beans">
    <map>
    <entry key="bean:name=testBean1" value-ref="testBean" />
    </map>
    </property>
    </bean>

    <bean id="testBean" class="jmx.JmxTestBean">
    <property name="name" value="TEST" />
    <property name="age" value="100" />
    </bean>

    </beans>
    <<<<

    and my console server log is :

    >>>>
    8-Jan-2007 1:37:24 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
    INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.5.0_06\bin;.;C:\WINDOWS\system32;C :\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOW S\System32\Wbem
    8-Jan-2007 1:37:24 PM org.apache.coyote.http11.Http11BaseProtocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8080
    8-Jan-2007 1:37:24 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 844 ms
    8-Jan-2007 1:37:24 PM org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    8-Jan-2007 1:37:24 PM org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/5.5.17
    8-Jan-2007 1:37:24 PM org.apache.catalina.core.StandardHost start
    INFO: XML validation disabled
    8-Jan-2007 1:37:25 PM org.springframework.web.context.ContextLoader initWebApplicationContext
    INFO: Root WebApplicationContext: initialization started
    8-Jan-2007 1:37:25 PM org.apache.catalina.core.ApplicationContext log
    INFO: Loading Spring root WebApplicationContext
    8-Jan-2007 1:37:25 PM org.springframework.core.CollectionFactory <clinit>
    INFO: JDK 1.4+ collections available
    8-Jan-2007 1:37:25 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
    8-Jan-2007 1:37:25 PM org.springframework.context.support.AbstractRefres hableApplicationContext refreshBeanFactory
    INFO: Bean factory for application context [Root WebApplicationContext]: org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [exporter,testBean]; root of BeanFactory hierarchy
    8-Jan-2007 1:37:25 PM org.springframework.context.support.AbstractApplic ationContext refresh
    INFO: 2 beans defined in application context [Root WebApplicationContext]
    8-Jan-2007 1:37:25 PM org.springframework.context.support.AbstractApplic ationContext initMessageSource
    INFO: Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMess ageSource@6279d]
    8-Jan-2007 1:37:25 PM org.springframework.context.support.AbstractApplic ationContext initApplicationEventMulticaster
    INFO: Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicatio nEventMulticaster@1455cf0]
    8-Jan-2007 1:37:25 PM org.springframework.ui.context.support.UiApplicati onContextUtils initThemeSource
    INFO: Unable to locate ThemeSource with name 'themeSource': using default [org.springframework.ui.context.support.ResourceBun dleThemeSource@c135d6]
    8-Jan-2007 1:37:25 PM org.springframework.beans.factory.support.DefaultL istableBeanFactory preInstantiateSingletons
    INFO: Pre-instantiating singletons in factory [org.springframework.beans.factory.support.DefaultL istableBeanFactory defining beans [exporter,testBean]; root of BeanFactory hierarchy]
    8-Jan-2007 1:37:25 PM org.springframework.jmx.export.MBeanExporter afterPropertiesSet
    INFO: Registering beans for JMX exposure on startup
    8-Jan-2007 1:37:25 PM org.springframework.web.context.ContextLoader initWebApplicationContext
    INFO: Using context class [org.springframework.web.context.support.XmlWebAppl icationContext] for root WebApplicationContext
    8-Jan-2007 1:37:25 PM org.springframework.web.context.ContextLoader initWebApplicationContext
    INFO: Root WebApplicationContext: initialization completed in 719 ms
    8-Jan-2007 1:37:26 PM org.apache.catalina.core.ApplicationContext log
    INFO: org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRul e: Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterR ule: Target param name: paramName / Target param value: paramValue / Redirect URL: http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingR ule: Redirect URL: http://jakarta.apache.org]]
    8-Jan-2007 1:37:26 PM org.apache.catalina.core.ApplicationContext log
    INFO: ContextListener: contextInitialized()
    8-Jan-2007 1:37:26 PM org.apache.catalina.core.ApplicationContext log
    INFO: SessionListener: contextInitialized()
    8-Jan-2007 1:37:26 PM org.apache.catalina.core.ApplicationContext log
    INFO: ContextListener: contextInitialized()
    8-Jan-2007 1:37:26 PM org.apache.catalina.core.ApplicationContext log
    INFO: SessionListener: contextInitialized()
    8-Jan-2007 1:37:26 PM org.apache.coyote.http11.Http11BaseProtocol start
    INFO: Starting Coyote HTTP/1.1 on http-8080
    8-Jan-2007 1:37:27 PM org.apache.jk.common.ChannelSocket init
    INFO: JK: ajp13 listening on /0.0.0.0:8009
    8-Jan-2007 1:37:27 PM org.apache.jk.server.JkMain start
    INFO: Jk running ID=0 time=0/62 config=null
    8-Jan-2007 1:37:27 PM org.apache.catalina.storeconfig.StoreLoader load
    INFO: Find registry server-registry.xml at classpath resource
    8-Jan-2007 1:37:27 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 3391 ms
    <<<<

    So it seems that the server started correctly? But where did the JMX Server started? Tomcat 5.5 is supposed to have a JMX server included? But when I start the MC4J console (using the default tutorial) I have this error:

    >>>>
    java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
    java.net.ConnectException: Connection refused: connect]
    at javax.management.remote.rmi.RMIConnector.connect(R MIConnector.java:317)
    at javax.management.remote.JMXConnectorFactory.connec t(JMXConnectorFactory.java:248)
    at org.mc4j.console.connection.JSR160ConnectionNode.c onnect(JSR160ConnectionNode.java:132)
    at org.mc4j.console.connection.ConnectionNodeChildren .exposeDomains(ConnectionNodeChildren.java:56)
    at org.mc4j.console.connection.ConnectionNodeChildren $1.run(ConnectionNodeChildren.java:44)
    at java.lang.Thread.run(Thread.java:595)
    Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
    java.net.ConnectException: Connection refused: connect]
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(R egistryContext.java:97)
    at com.sun.jndi.toolkit.url.GenericURLContext.lookup( GenericURLContext.java:185)
    at javax.naming.InitialContext.lookup(InitialContext. java:351)
    at javax.management.remote.rmi.RMIConnector.findRMISe rverJNDI(RMIConnector.java:1807)
    at javax.management.remote.rmi.RMIConnector.findRMISe rver(RMIConnector.java:1777)
    at javax.management.remote.rmi.RMIConnector.connect(R MIConnector.java:259)
    ... 5 more
    Caused by: java.rmi.ConnectException: Connection refused to host: localhost; nested exception is:
    java.net.ConnectException: Connection refused: connect
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEnd point.java:574)
    at sun.rmi.transport.tcp.TCPChannel.createConnection( TCPChannel.java:185)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCP Channel.java:171)
    at sun.rmi.server.UnicastRef.newCall(UnicastRef.java: 306)
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(R egistryContext.java:93)
    ... 10 more
    Caused by: java.net.ConnectException: Connection refused: connect
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.che ckConnector(RMIMasterSocketFactory.java:309)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.cre ateSocket(RMIMasterSocketFactory.java:174)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEnd point.java:569)
    [catch] ... 15 more
    <<<<

    Does anyone could help me here? I am pretty sure I am doing some trivial thing wrong (like the RMI registry is not running, or MC4J is not working well?). I have try to run explicitly the JMX server (comment in the spring context file), but it doesn't work either.

    Thanks if you can help me.

    ETienne.

  • #2
    OK found my mistake.

    I have made it work, i have put the need -D in the Tomcat Eclipse starter (Sysdeo) under the Tomcat JVM parameter (not in the catalinastart.bat as I thaught).

    -Dcom.sun.management.jmxremote.port=8999
    -Dcom.sun.management.jmxremote.authenticate=false
    -Dcom.sun.management.jmxremote.ssl=false

    Now I see everything in the MC4J console.

    Tks for following...

    Etienne.

    Comment

    Working...
    X