Hi,
I try to profile my Client application but the client
crashes with the following NullpointerException.
I use the Eclipse 3.2 Compiler to generate the classes
and JDK 1.5_07 to run the client.
I have overwritten the classloader to load some jars
dynamically and do some very nasty things there.
Perhaps this is the root of the problem.
Here the console dump:
-------------------------------------
C:\Program Files\AMOSng_devel>"C:\Program
Files\AMOSng_devel\jre\bin\java.exe" -
cp classes;stdclasses -javaagent:"C:\Program
Files\Devel\Profiler4J\agent.jar" -
Xmx500M amos.client.Client
[PROFILER4J:0] +---------------------------------------+
[PROFILER4J:0] | Profiler4j 1.0-beta2 (build 27) |
[PROFILER4J:0] | Copyright 2006 Antonio S. R. Gomes |
[PROFILER4J:0] | See LICENSE-2.0.txt for more details |
[PROFILER4J:0] +---------------------------------------+
[PROFILER4J:0] Listening on port 7890...
[PROFILER4J:0] JVM waiting connection from Profiler4j
Console...
[PROFILER4J:0] Serving connection from /127.0.0.1:1214
Adding extension: alloy.jar
Adding extension: fleet_scenario.jar
Adding extension: HTMLEditorEnterprise.jar
Adding extension: itext-1.4.1.jar
Adding extension: jai_imageio.jar
Adding extension: jh.jar
[PROFILER4J:1] Transforming class
com.incors.plaf.alloy.AlloyLookAndFeel
[PROFILER4J:1] Transforming class
amos.share.AmosTimeZoneFacade
[PROFILER4J:1] Transforming class
amos.share.multiLanguage.MultiLangToolTip
[PROFILER4J:1] Transforming class
amos.share.multiLanguage.MultiLanguage
[PROFILER4J:1] Transforming class
amos.share.multiLanguage.MultiLangText
[PROFILER4J:1] Transforming class
amos.share.multiLanguage.Translateable
[PROFILER4J:1] Transforming class
amos.share.multiLanguage.TextStorage
[PROFILER4J:1] Transforming class
amos.share.multiLanguage.ToolTipStorage
Skipping preemptive look&feel switch:
java.lang.reflect.InvocationTargetExceptio
n
[PROFILER4J:1] Transforming class
amos.share.system.UserContext
Error running Client: java.lang.NullPointerException
java.lang.NullPointerException
at
net.sf.profiler4j.agent.ThreadProfiler.enter0(ThreadProfiler.java:246
)
at
net.sf.profiler4j.agent.ThreadProfiler.enterMethod(ThreadProfiler.jav
a:139)
at
amos.share.system.UserContext.getInstance(UserContext.java)
at
amos.client.system.Main.initializeUserContext(Main.java:123)
at amos.client.system.Main.<init>(Main.java:82)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
Source)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Sou
rce)
at
java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at
amos.client.SplashScreen.run(SplashScreen.java:94)
at java.lang.Thread.run(Unknown Source)
[PROFILER4J:0] Profiler stopped
---------------------------
This is no high priority. I just tested you tool as it
looks very nice and ran into this. When I install an
filter to exclude the class it will crash on the next
one. Perhaps this gives you some hints to wipe out some
more bugs.
Thanks for your great tool anyway.
- Bernd Rosstauscher
Logged In: YES
user_id=486433
It would be nice if you could provide details on how this
classloader works.
Logged In: YES
user_id=1006443
Hi there,
It is a rather complex thing and don't ask why we do it this
way, has some historical reasons ;-)
It look something like this (only example code)
public static void main(String args[]) {
loader = new Client(); // <-- Our Classloader
Thread.currentThread().setContextClassLoader(loader);
...
try {
Class l =
loader.loadClass("amos.client.SplashScreen");
client = (Frame)l.newInstance();
new Thread((Runnable)client).start();
}
}
Our Client class inherits from URLClassLoader and is capable
of loading jar files dynamically and can also load some
classes from a server as needed.
SplashScreen is then opening the main frame of the
application. As we load the SplashScreen class dynamically
it is loaded with the new installed class loader and
therefore all following classes created by it are loaded
that way to.
The Client loader first asks the class loader chain to load
the class and if not found searches in some additional jars
and if activated tries to load missing classes per http from
a server but this feature was not active during testing.
Hope this helps,
- Bernd Rosstauscher