Running OpenGrok on Windows

I’ve needed to setup a local OpenGrok server on Windows to do some testing. It’s not that straightforward as one might expect but not that hard either. My setup is not secure nor tested whatsoever so don’t rely on it, but it can be used if you need to quickly setup some OpenGrok server on your Windows workstation. So here’s what you have to do:

  1. Download OpenGrok binary. Just go to OpenGrok Home and download 0.10 binary
  2. Download ctags. Just go to ctags, download windows zip file and extract it somewhere.
  3. Edit web.xml. You need to extract lib/source.war somewhere and modify WEB-INF/web.xml slightly. I’ve modified CONFIGURATION param to point to my generated configuration.xml file(more about it later) and added SRC_ROOT and DATA_ROOT to point to folder with sources to index and folder that OpenGrok should keep it’s data in (I’m not sure if these two are needed if you pass in configuration.xml)

    <context-param>
        <param-name>CONFIGURATION</param-name>
        <param-value>D:/GrokTest/configuration.xml</param-value>
        <description>Full path to the configuration file where OpenGrok can read it's configuration</description>
      </context-param>
      
      <context-param>
        <param-name>SRC_ROOT</param-name>
        <param-value>D:/GrokTest/src</param-value>
      </context-param>
      
      <context-param>
        <param-name>DATA_ROOT</param-name>
        <param-value>D:/GrokTest/grokdata</param-value>
      </context-param>
    

  4. Deploy web app on Tomcat 6 (didn’t test it on any other servlet container, but docs state that it should also work on Glassfish and Tomcat later than 6). I’ve just copied source folder to PATH_TO_TOMCAT/webapps but you can zip them to war and deploy as single file.
  5. Index source/generate configuration.xml. OpenGrok has nice config generation tool. Just go to PATH_TO_OPENGROK/lib and launch:
    java -jar opengrok.jar -W D:\GrokTest\configuration.xml -c <<path_to_ctags>>\ctags.exe -P -S -v -s D:\GrokTest\src -d D:\GrokTest\grokdata
    

    You can omit -P if you don’t need projects (first level directories are considered projects with this option, not as source folders). This will index your source files and generate configuration.xml.

Now start Tomcat (PATH_TO_TOMCAT\bin\startup.bat) and go to http://localhost:8080/source and if I didn’t forget something 😉 you should see OpenGrok search page with your projects. Try to search, should work fine.

P.S. If you change source you have to re-index and overwrite configuration.xml if you added/removed projects.

Advertisements

10 Responses to Running OpenGrok on Windows

  1. Anonymous says:

    Thanks . It’s works …

  2. Bert says:

    Great demo. Filled in the gap required to index in windows. Thanks!

  3. Anonymous says:

    Excellent. It works. Thanks for great help.

  4. Pingback: Confluence: Core Services

  5. Anonymous says:

    Great Help !! It works pretty good 🙂 I think opengrok site should include this link

  6. Anonymous says:

    Hi this article is very nice.
    I followed each and every step as explained but still i got an error.
    “HTTP Status 500 – org.apache.jasper.JasperException: java.lang.NullPointerException”
    did I miss something?

    • Marek Piechut says:

      Hi. Could you post some more info from logs? I didn’t use my local grok installation for some time now and don’t think that I still have it, but maybe I can help.

  7. HIten says:

    Thanks for the good post .. it worked for me too ..
    I wonder if you can post on how to integrate opengrok with clearcase (dynamic views) on windows.

  8. Sohail Ahmed says:

    It worked! Thanks a lot for this straightforward article.

  9. Anonymous says:

    Great article, it works.

    Just to add, if the SRC_ROOT parameter is not necessary in the configuration.xml, if it is passed in the commandline for indexing. And also, opengrok is updated to 0.12, it works with tomcat 7 alright.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: