Search code examples
scalatra

Scalatra will not run on Windows


I have been working on a Scalatra project on a Linux environment and would now like to switch to a Windows environment. I've transferred the project folder to my Windows directory. Using Cygwyn, I cd to the Scalatra project and type

./sbt
> jetty:start

Nothing happens at this point. I have waited 10 minutes but nothing is printed to the console. I am having a hard time thinking of what might be the cause, since the exact same project works fine on Linux. Anyone have a Scalatra project working on Windows and remember whether there were any Windows-specific steps to set it up?


Solution

  • I did this on a fresh Windows 10 Professional VM in virtual box. I only allocated 1 CPU and 4 GB RAM, which may have made things unnecessarily slow. I was logged in as administrative user testvm

    I always started new command prompts after modifying environment variables. All of my command prompts were run as administrator... I don't know whether that was necessary.

    In general, these instructions were a good start: How to Install conscript in Windows, followed by http://scalatra.org/getting-started/first-project.html

    • installed the java developers kit, by visiting this page
    • added the JDK's bin folder (C:\Program Files\Java\jdk1.8.0_131\bin) to the end of the PATH system variable
    • started a new command prompt and ran set to review the PATH environment variable, and ran javac –version as an additional sanity check
    • downloaded and installed sbt for windows. Didn't make any manual changes to the PATH at this point.
    • conscript (or giter8?) requires bash (and/or git?), so I installed git for windows. I did a default install, except I specified that git and "optional Linux components" should all be accessible form the windows prompt. I also added C:\Program Files\Git\bin to the PATH environment variable. I’m not sure if either or both of those tweaks are required.
    • downloaded the latest conscript jar. I got a warning that the download might not be safe and accepted anyway.
    • double clicked the conscript jar to run it. A nice graphical dialogue box came up and eventually told me that a cs.bat script had been created in C:\Users\testvm\.conscript\bin\cs.bat. 100% CPU use continued for several minutes after this and eventually I clicked the close button (X) in the upper right of the conscript installer dialogue.
      • When I installed conscript in another system more recently, it went quickly but I got a warning that cs.bat might not be on the system path.
    • ran conscript to obtain giter8. I have found that giter8 v 0.8 fails to build the skeleton project with an error like "parameters cannot contain '.'", so I specifically asked for v 0.7.2: C:\Users\testvm\.conscript\bin\cs.bat foundweekends/giter8/0.7.2
    • ran giter8 to install the skeleton scalatra project: C:\Users\testvm\.conscript\bin\g8.bat scalatra/scalatra-sbt
    • accepted all of the default parameters
    • turned off the windows firewall, the defender real-time protection, and started a new cmd prompt as administrator. I don’t know if any of those are necessary
    • ran sbt: c:\Users\testvm\my-scalatra-web-app\sbt
      • Going through this more recently, my-scalatra-web-app was installed into c:\Windows\System32\my-scalatra-web-app, but I was able to copy it to the top of C:\. cd'ing in there and running just sbt gave an error message, because there's a sbt file in that folder, but it's not a windows executable. So I entered "c:\Program Files (x86)\sbt\bin\sbt.bat". Subsequently, that directory was added to my PATH environment variable, so I could just enter sbt.bat
    • waited as components downloaded, installed and compiled
    • when the sbt > prompt reappeared, entered jetty:start and waited some more
    • eventually, the following appeared:

      2017-05-09 07:31:15.101:INFO:oejs.ServerConnector:main: Started ServerConnector@bffcb98{HTTP/1.1}{0.0.0.0:8080} 2017-05-09 07:31:15.101:INFO:oejs.Server:main: Started @8698ms

    • Opened http://localhost:8080 in a web browser and saw Hello, world!