register
other register

Thursday, October 28, 2010

When Run (Ctrl+F11) gets stuck in Eclipse.

In Eclipse (or its derivative Spring STS 2.5.0) generically, Ctrl+F11 is Run and it is context aware. As if the cursor is in a Java class with a main method, it will run the run class; if the cursor is in a test class, it will run the test class; if the cursor is at the method line in a test class, it will run the test for this single method.

However, when a new Grails plugin is installed, or if you run "grails test-app -coverage" you will noticed from the console that: $app/web-app/WEB-INF/classes directory is deleted. And when you Ctrl+F11 to run again, it will have the following exceptions:


Class not found uk.ac.lse.LockerRegisterServiceUnitTests
java.lang.ClassNotFoundException: uk.ac.lse.LockerRegisterServiceUnitTests
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Because the Default output folder is $app/web-app/WEB-INF/classes, that's why the test or run(main method for java) can't be run. 

To get your favourite Ctrl+F11 come back work for you, do the following:

1. Delete the project without deleting the content from Eclipse.
2. Import your project into Eclipse. 

/***** The following approach DOES NOT work ********/

Or better (29/10/2010)

1. Right click your project.
2. Select Grails Tools -> Refresh Dependencies

Then you will find the classes are compiled in to $app/target/classes which is the place your test or main java classes will run from.





Monday, October 25, 2010

Lockers App is Launched.

Very excited, my Online Locker Booking System will be launched today. It was built using Grails in 3 months.

550+ lockers will be booked within 1 hour, then the waiting list is built up until it reaches its max limit.