LabKey development in Eclipse

LabKey Support Forum
LabKey development in Eclipse bront  2015-03-10 13:19
Status: Closed
 
hi,

Do you have any documentation or suggestions on importing LabKey source into Eclipse and launching it?

thanks,

bront
 
 
Andy Straw responded:  2015-03-10 13:41
I use Eclipse, and have created a set of .project and .classpath files for LabKey 14.3 source - at least for the server/api, server/internal, remoteapi, server/modules/experiment, and server/modules/study. I've attached those as a zip file. I've also attached the PDF version of two wiki pages I wrote that explain 1.) how to use the .project and .classpath files, and 2.) details of how those project and classpath files were created in the first place, in case you care.

I can't guarantee that these will work for you, but you can try them, and perhaps adjust them if they don't work quite right.

I ran into a couple of issues with the LabKey source in these Eclipse projects: 1.) there are two different LogPrintWriter.java files, one in server/api and one in server/internal and 2.) Eclipse gives a compile error for one return value that javac does NOT consider an error. I just ignore these - I don't use Eclipse to build the LabKey source, just to write code that uses it, like external Java apps that use remoteapi project and Java-based modules that use the server/* projects.

I'm happy to answer questions about these.

Andy Straw
University of Rochester
 
Andy Straw responded:  2015-03-10 13:54
Regarding debugging a running LabKey instance, that's pretty straightforward. I might miss a step here, so let me know if this doesn't work for you.

- Start your tomcat instance with the jpda command-line option. For example, I use this command line:

catalina.sh jpda start


- Tomcat will start up with its JVM listening to a configured port for debugging commands. I think the default is port 8000 - at least, that's the port I use.
- In Eclipse, create a new Debug Configuration. Make it a "Remote Java Application". Name it whatever you want. On the "Connect" tab of that configuration, enter the host (mine is "localhost") and the port that the tomcat JVM is listening on (8000 for me). Hit "Apply" to save that configuration. Then hit "Debug" to start debugging.
- You can set breakpoints in the LabKey source, or if you're writing your own Java modules, you can set breakpoints in your source.

That's it.

Andy
 
bront responded:  2015-03-10 14:00
Andy,

Thanks for such a quick response. I will pass your info on to our new developer and let you know if we have any other questions.

cheers,

bront
 
adam responded:  2015-03-14 11:11
Good stuff... thanks for sharing this with the community, Andy.

Josh removed the second LogPrintWriter a couple weeks ago on trunk (SVN commit 36901), which should eliminate that annoyance.

I'm curious about your comment "Eclipse gives a compile error for one return value that javac does NOT consider an error"... what return value is that?

Thanks,
Adam
 
jeckels responded:  2015-03-14 20:03
Eclipse had a different interpretation of the inferred generic type for the getNamePDs() method in server/modules/experiment/src/org/labkey/experiment/DerivedSamplePropertyHelper.java. While I consider javac to be the ultimate authority here, there was a reasonable (and arguably better) return type that cleared up the problem in Eclipse, which I made in revision 36901 in the trunk.

Thanks,
Josh
 
lewis j mcgibbney responded:  2015-03-16 11:42
Hi Folks,
I recently started working on Labkey and I think that having the documentation attached here would be extremely useful for Eclipse users.
Thanks to Andy for attaching this.
Lewis