This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
I have a test class with its own main method. The class name is Test_Assert. If I right click on the class in the projects pane and select "run file" it runs without problems. When I right click and select "profile file" I get the following: Profiler Agent: Waiting for connection on port 5140, timeout 10 seconds (Protocol version: 9) Profiler Agent: Established local connection with the tool java.lang.NoClassDefFoundError: com/spectra/util/Test_Assert Caused by: java.lang.ClassNotFoundException: com.spectra.util.Test_Assert at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) Could not find the main class: com.spectra.util.Test_Assert. Program will exit. Profiler Agent: Initializing... Profiler Agent: Connection with agent closed Profiler Agent: Options: >D:\apps\NetBeans6.8\profiler3\lib,5140,10< Profiler Agent: Connection with agent closed Profiler Agent: Initialized succesfully Exception in thread "main" Java Result: 1 BUILD SUCCESSFUL (total time: 3 seconds)
Can you please provide a small project with a test class, where we can reproduce it? Thanks.
Any class with a main in the "Test Packages" will have this problem. But here are step by step directions to reproduce it: File->New Project select Java Application Type "ProfilerBug" as the project name uncheck "Create Main Class" Under the ProfilerBug project right click on the "Test Packages" and select "New class" Type in "Test_Me" for the class name and click finish In class Test_Me add this method: public static void main(String[] args) { System.out.println("Hello world"); } save the file In the project pane right click on "Test_Me.java" and select "Run File" confirm that the string "hello world" is seen in the output window Now go to the project pane and right click on "Test_Me.java" and select "Profile file" click OK on the dialog about modifying the project click run on the analyze performance dialog. You will get this output: java.lang.NoClassDefFoundError: Test_Me Caused by: java.lang.ClassNotFoundException: Test_Me at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) Could not find the main class: Test_Me. Program will exit. NOTE: This fails only with a main in a class in the test packages directory. There is definately a CLASSPATH problem where the profiler is not looking in the test directory to pick up classes.
Thanks. I am able to reproduce it.
One possible solution would be to construct the "profile" macro in the project's build-impl.xml such that it accepts "${run.test.classpath}" property as a path in the classpath provided to the JVM being started. I would defer this change after the patch for #189151 has been integrated. However, this will not solve the situation with "Compile on save" turned on - in this particular situation the ant is completely bypassed and "org.netbeans.api.java.project.runner.JavaRunner", which knows nothing about profiler, is used instead. A non-trivial change in the profiler integration will be required to provide profiler support in such cases.
Given the current implementation of the profiler IDE integration the solution to this problem would be rather hackish. Postponing to the next version where we will, hopefully, rewrite the profiler actions to be fully compatible with run/debug.
Should be fixed by http://hg.netbeans.org/profiler-main/rev/cf681524d222