lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Lucene-java Wiki] Update of "HowtoConfigureIntelliJ" by ErickErickson
Date Sat, 08 Dec 2012 05:12:28 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Lucene-java Wiki" for change notification.

The "HowtoConfigureIntelliJ" page has been changed by ErickErickson:
http://wiki.apache.org/lucene-java/HowtoConfigureIntelliJ?action=diff&rev1=22&rev2=23

Comment:
Added section on remote debugging

  
  The IntelliJ anonymous code style file is here: ([[http://people.apache.org/~erick/Intellij-Lucene-Codestyle.xml|Intellij-Lucene-Codestyle.xml]])
  
+ === Debugging ===
+ There are two main ways to debug Solr in IntelliJ.
+ 
+ First and easiest is to write/use one of the jUnit tests. Once IntelliJ is set up, it's
very easy to just set a breakpoint in a likely unit test and right-click on that test and
just start up the test in debug mode and you're on your way. This has the advantage of not
requiring a running Solr server. It has the disadvantage of it not always being obvious what
test to run to see the Solr/Lucene code path of interest. 
+ 
+ However, it is ''strongly'' recommended that when you develop new code you also create unit
tests, so if you're developing new code this is very often the easiest way to step through
code.
+ 
+ The second way is to create a "remote debug" session. To debug remotely, follow the instructions
above for setting up IntelliJ. Then, in the <solr_home>/solr directory, execute "ant
example". So far it's easy.
+ 
+ Next, in IntelliJ, create a remote debugging session. Do do this, there's a little click
the chicklet and then the "edit configurations" setting. Now, click the little plus sign and
click "remote". This will bring up a dialog and enter the host and port, usually "localhost"
and "some port", I use 5900.
+ 
+ When you do this, you should see something like this appear in the entry field above:
+ {{{
+ -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5900
+ }}}
+ 
+ You take that string and use it to start solr by going to the <solr home>/solr/example
and entering something like:
+ {{{
+ java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5900 -jar start.jar
+ }}}
+ 
+ Now go back into IntelliJ and execute the configuration you just created. At that point,
you'll be able to set breakpoints in Solr and all sorts of good stuff. One note here: setting
"suspend=y" in the above causes the Solr instance to wait around and do nothing until you
invoke the remote configuration in IntelliJ. If you set "suspend=n" in the above, then Solr
will start up and load all the configs etc. You can still attach the debugger and set breakpoints
which you'll hit when you execute the code path. This process seems more complex than it really
is, but at that it is far easier than starting up the servlet container within IntelliJ. The
downside is that to make code changes you need to re-build Solr after making changes and attach
again. Which is why jUnit tests are such a good idea.....
+ 

Mime
View raw message