How to debug the MT's java code
To modify the existing migration code or to do a bugfix yourself you should use Eclipse.
After installing Eclipse you should run this short debugging test to see if everything is in place.
1) Start Eclipse.
2) Open the project found in [installdir]\java ^*
3) Open BaseJava.java from the com.mysql.grt.modules package.
4) Set a breakpoint in public static String engineVersion() on the return statement (with Ctrl+Shift+B)
4a) If the breakpoint is displayed as a small red square, select Project > Clean and clean all projects. After the rebuild is complete the breakpoint should be visualized with a blue dot.
6) Start the GRT shell with grtsh -verbose -debug
7) In Eclipse now select Run > Debug ... from the main menu. Select Remote Java Application and press [New]. Choose Connection Type: Standard (Socket Attach), Host: localhost, Port: 8000
8) Click the [Debug] button.
9) Now the blue breakpoint should have an additional checkmark, notifying that Eclipse will actually hold there.
10) Back in the GRT shell, execute \ > print(BaseJava:engineVersion())
11) If everything is configured correctly, Eclipse will ask to switch to the Debugging perspective. After doing so the line with the breakpoint will be highlighted.
12) Press F8 to continue. The GRT shell should print information about the Java engine.
^* The current release ships with an outdated [installdir]\java\.classpath file. The <classpathentry> to path="lib/mysql-connector-java-3.1.6-bin.jar" needs to be updated to path="lib/mysql-connector-java-3.1.10-bin.jar" and the entry for path="lib/ojdbc14.jar" needs to be removed before opening the project in Eclipse. This is now fixed and will be in the next release, thanks to Thorbjørn Weidemann for pointing this out.
After you have completed this simple test, you can start the Migration Toolkit with the -debug option. You can set breakpoints in all other modules like ReverseEngineeringOracle or MigrationOracle and step through the code with F5 (step in) and F6 (step over).
To inspect a variable, place the cursor on it and press Ctrl+Shift+I. For more information please read the Eclipse documentation.
In the Migration Toolkit you can select Tools > GRT Environment Shell or press F4 to get the X GRT shell. The GRT Globals Tree gives you access to the application's data. We are working on more documentation about the GRT Environment to make it easier to customize the Migration Toolkit.
Mike
Michael Zinner, Team Lead, Developer Tools
MySQL AB, www.mysql.com
Are you MySQL certified? www.mysql.com/certification
Subject
Written By
Posted
How to debug the MT's java code
August 06, 2005 06:17AM
September 07, 2006 02:04PM
September 08, 2006 03:46PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.