Thursday, January 2, 2014

Enable Eclipse verbose for troubleshooting

Have you ever wanted to trace what happens when you start an eclipse, or wanted to check what are the classes are loading during start up or while performing certain action.

Just to mention my use case, I was facing the below problem,

java.lang.LinkageError: loader constraint violation: when resolving method "com.kk.MUtils.logDebug(Lorg/apache/log4j/Logger;Ljava/lang/String;)V" the class loader (instance of java/net/FactoryURLClassLoader) of the current class, com/kk/common/KHttpServletRequestWrapper, and the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) for resolved class, com/kk/MUtils, have different Class objects for the type com.kk.MUtils.logDebug(Lorg/apache/log4j/Logger;Ljava/lang/String;)V used in the signature


From the above error, we can understand that Logger class is the issue, it was loaded multiple times by different class loaders and they could not link each other since both of them are loaded by different class loaders.

My call request involves multiples plug-ins, I wanted to check which of the plugins are loading Logger class to identify a root cause of the problem.

To get all that info, we can make use of java verbose vm parameter.

so how do we enable that ?

By default, eclipse launches with javaw.exe process, since it's a window thread so you will not be able to see any verbose messages.

Step 1:  Add below VM parameter in eclipse.ini file. By default, eclipse will have javaw.exe, modify it to java.exe
-vm
C:/KK/jdk1.6.0_32/bin/java.exe

Step 2: Pass verbose parameter during the eclipse launch.
> eclipse -verbose

This will open up a console window to display all log messages.

Write it to a file:
To write log messages to a file, use below command.
>eclipse -verbose  >mytracelog.txt

You can find this file in eclipse root directory.

You can also provide complete file system path, if required.
>eclipse -verbose  >C:\kk\logs\mytracelog.txt

You can also add verbose parameter in eclipse.ini vm parameters.
Example:
-vm
C:/KK/jdk1.6.0_32/bin/java.exe
-vmargs
-Xms128m
-Xmx512m
-verbose




No comments:

Post a Comment