Announcement Announcement Module
No announcement yet.
Controlling log4j using Spring JMX and jmanage Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Controlling log4j using Spring JMX and jmanage

    I am trying to implement the jmx log4j control defined using jManage as a front end. I am also using weblogic 8.1 as my mbean server. JManage sees my log4j mbean but when I attempt to invoke the setLogger method through jManage, I get the following exception in the jManage log.

    SEVERE: Error executing operation setLogger on log4j:name=settings
    java.lang.RuntimeException: The target object class class
    ean.ModelMBeanOperationInfo could not be found
    at org.jmanage.core.modules.weblogic.WLServerConnecti on.invoke(
    at invoke(
    at MBeanOperation(
    at nAction.execute( 7)
    at org.jmanage.webui.actions.BaseAction.execute(BaseA
    at org.jmanage.webui.JManageRequestProcessor.processA ctionPerform(
    at org.apache.struts.action.RequestProcessor.process(
    at org.apache.struts.action.ActionServlet.process(Act
    at org.apache.struts.action.ActionServlet.doPost(Acti
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
    at org.mortbay.jetty.servlet.ServletHolder.handle(Ser
    at org.mortbay.jetty.servlet.WebApplicationHandler.di spatch(
    at org.mortbay.jetty.servlet.ServletHandler.handle(Se
    at org.mortbay.http.HttpContext.handle(HttpContext.ja va:1807)
    at org.mortbay.jetty.servlet.WebApplicationContext.ha ndle(
    at org.mortbay.http.HttpContext.handle(HttpContext.ja va:1757)
    at org.mortbay.http.HttpServer.service(HttpServer.jav a:879)
    at org.mortbay.http.HttpConnection.service(HttpConnec
    at org.mortbay.http.HttpConnection.handleNext(HttpCon
    at org.mortbay.http.HttpConnection.handle(HttpConnect
    at org.mortbay.http.SocketListener.handleConnection(S
    at org.mortbay.util.ThreadedServer.handle(ThreadedSer
    at org.mortbay.util.ThreadPool$
    Caused by: The target object class class
    rationInfo could not be found
    at weblogic.rjvm.BasicOutboundRequest.sendReceive(Bas
    at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicR
    at _814_WLStub.invoke(Unknown Source)
    at org.jmanage.core.modules.weblogic.WLServerConnecti on.invoke(
    ... 24 more

    I followed the jManage weblogic setup. Is there something additional i need to do for Spring? Also, are there any other alternative jmx consoles I can use? I am using j2se 1.4, so I think jconsole is out of the question.


    Last edited by robyn; May 14th, 2006, 06:14 PM.

  • #2
    There is mc4j ( plus a jmx servet console that you can find doing a google after jmx console (I found it on a site but I can't recall it's name). Note that I know of several problems with mc4j (beans which are not showned or failers in connecting).

    You can try also the following (I haven't):

    Check out also the mx4j site and mailing list - there have been several discussions about on this topic.


    • #3
      Thanks. I'll give those a try.


      • #4
        I tried mc4j and still ran into the same exception. This is leading me to believe that this is not a jmanage issue.

        I emailed my web application and source code to a developer from jmanage who ran into the same exception when deploying the application on weblogic 8.1 sp4. The following is a quote from the message he sent me:

        I spent some time on this issue, but couldn't resolve it. It is either an issue with the
        JMX remote API that weblogic provides, or with the spring framework.

        I also tried using MC4J (another JMX console), and it has the same issue.

        There is also something weird with spring JMX exporter. It exports the get
        method both as an attribute and as an operation. When attribute's value
        is queried, it doesn't returns nothing. This seems like a bug in spring.
        My application context looks like:

            <bean id="jmxExporter" class="org.springframework.jmx.export.MBeanExporter">
                <property name="beans">
                        <entry key="log4j&#58;name=settings" value-ref="log4jBean"/>
                <property name="server">
                    <ref bean="mbeanServer"/>
            <bean id="log4jBean" class="org.kbaum.log4j.Log4jConfig"/>
            <bean id="mbeanServer"
        My java code:

        public class Log4jConfig &#123;
        	public void setLogger&#40;String category, String level&#41; &#123;  
        	public String getLog4jProperties&#40;&#41; &#123;
        		StringWriter writer = new StringWriter&#40;&#41;;
        		PrintWriter printWriter = new PrintWriter&#40;writer&#41;;
        		new PropertyPrinter&#40;printWriter&#41;;
        		return writer.toString&#40;&#41;;

        public class WeblogicMBeanServerFactoryBean implements FactoryBean, InitializingBean &#123;
        	private MBeanServer server;
        	public Object getObject&#40;&#41; throws Exception &#123;
        		return server;
        	public Class getObjectType&#40;&#41; &#123;
        		return MBeanServer.class;
        	public boolean isSingleton&#40;&#41; &#123;
        		return true;
        	public void afterPropertiesSet&#40;&#41; throws Exception &#123;
        		MBeanHome mBeanHome = &#40;MBeanHome&#41; new JndiTemplate&#40;&#41;.lookup&#40;MBeanHome.LOCAL_JNDI_NAME&#41;; 
        		server = mBeanHome.getMBeanServer&#40;&#41;; 
        If there is anything in the above configuration and java code that looks wrong, please let me know.




        • #5
          The issue can easily be reproduced by deploying the war file available here to a weblogic 8.1 sp4 application server.

          The source code is available here.




          • #6
            Can you please raise an issue on JIRA - attach also the war for weblogic and make a link to this topic.


            • #7
              Jira issue has been raised here.

              Let me know if you need anything else.

              Thanks for your help!



              • #8

                I have this on my list of things to do tomorrow. There are some subtle issues related to classloading and JMX when operating on WLS 8.1 as I remember.

                To summarise the situation as I understand it right now:

                The issue has nothing to do with Spring exporting properties as both an MBean attribute and pair of operations. The JMX specification lays out the guidelines for exporting attributes using ModelMBeans on page 82 and requires that each attribute contains metadata for the get method and set method as appropriate (if not using a static value). The exact information contained in this metadata is *not* the name of java methods but rather the name of an exposed JMX operation corresponding to the getter/setter.

                The issue most likely lies in two places - classloading issues and settings for the caching descriptor. I'll take a look a both of these problems in the morning - most likely no fix will be required and the problem should be solvable with configuration.



                • #9
                  Thanks Rob!


                  • #10
                    Hi Rob/All,

                    I was able to invoke the mbean methods from jmanage by following the two steps you outlined in the jira issue comment. Because of a Weblogic limitation, one of these steps requires us to place many of our classes within the Weblogic system classpath. Unfortunately, this is not a change I can make to our current system.

                    Is there a way I can get around this limitation by creating my own MBeanServer using the MBeanServerFactoryBean. From the spring docs:

                    For this to work correctly, you must have a JMX implementation on your classpath.
                    I think the only jmx implementation I currently have in my classpath is weblogic's implementation. We already know there are limitations with that. What other implementations could I use?

                    Thanks again.



                    • #11

                      I don't think it is even possible to get this to work, I seem to recall trying this in the past and having some issues with it. Give it a try though:

                      1. Download MX4J. This is a decent open source JMX impl
                      2. Add this to your WAR lib directory
                      3. Use MBeanServerFactoryBean to configure an instance of the MBeanServer
                      4. Add the following to weblogic.xml:

                      Let me know how you go on.



                      • #12
                        Wich JMX-Implementation to use ?

                        Hi karl,

                        try out MX4J, itīs easy to set up and works fine.


                        • #13
                          Donīt see robs answer, sorry.

                          Sorry, didnīt see that karls question was answered on page 2 of this thread.


                          • #14
                            Posted an entry on how i got around the issue here.