Friday, December 28, 2012

Eclipse Plugins : MaintainJ

MaintainJ (http://www.maintainj.com/) is a tool that can be used to generate sequence digrams when you run the application. It's a great reverse engineering tool, but unfortunaly most of the options are not available in the free version. They allow a 7 day free trial of the full product, but I just used what is available for free.

My application is deployed in WebLogic and in order to use MaintainJ following things had to be done. (Official user guide http://www.maintainj.com/userGuide.jsp?param=install)

Step A: Install MaintainJ in WebLogic

Download MaintainJ.war from http://www.maintainj.com/updates/4.0.0/MaintainJ.war and deploy it in WebLogic

Once installed you can access the following console.



There is a very clear step by step demo here.


Step 1 and 2 are straightforward. In step 2 we need to give the package names that need to be instrumented.

Step 3 advised to start WebLogic using following wrapper script.

/.../Oracle/Middleware/user_projects/domains/commercerouter-domain/bin/startWebLogic_with_mnj.sh

Since my application had a custom ant target that starts WebLogic through it, I added what is there in the above script to my ant target as shown below.


        <wlserver>
            <classpath>
                ...                
                <pathelement location="${bea.home}/user_projects/domains/commercerouter-domain/maintainj"/>
                <pathelement location="${bea.home}/user_projects/domains/commercerouter-domain/maintainj/MaintainJAspect.jar"/>
            </classpath>
            ...
            <jvmarg value="-javaagent:${bea.home}/user_projects/domains/commercerouter-domain/maintainj/aspectjweaver.jar" />    
        </wlserver>

It's possible to add multiple javaagents. So no need to worry if it's already defined pointing to another jar.

Running my ant target started WebLogic and Step 4 in Wizard showd everything is fine.

Step 5 started call trace.

Ran a test case and stopped the trace. Trace files were generated.

Step B: Install MaintainJ plugin in Eclipse to view the trace files.


Installed plugin from update site http://www.maintainj.com/updates/4.0.0

Created a new MaintainJ project in eclipse and copy the trace files to it.

Diagrams were displayed as shown below.


No comments:

Post a Comment