11

Hoping a kindred soul can assist with this odd windows problem

I am attempting to run a grails app on windows and am unable to get grails to start.

I have both downloaded the 2.0.3 distro from grails.org and pulled and built the source off of github.

The error I receive is as follows:

Error: Could not find or load main class 
       org.codehaus.groovy.grails.cli.support.GrailsStarter

The searching I've done to find solutions to this problem (which some people have had) have yielded no help: All I've found is suggestions that my environment variables are improperly set up. (e.g. here)

I felt I was quite careful in setting up my variables though. I have the following configured, all under System Variables:

JAVA_HOME C:\java\jdk7
GRAILS_HOME C:\grails\2.0.3  // also set it to C:\grails\source\grails-core when dlded from source
GROOVY_HOME C:\groovy\1.8.6
PATH %JAVA_HOME%\bin;%GRAILS_HOME%\bin;%GROOVY_HOME%\bin;$PATH

I've tried things both before and after downloading groovy and setting that environment variable, and I'm afraid I'm quite lost at this point. Groovy starts just fine, java starts just fine, but grails is unable to start.

Is anyone else in Windows having this issue with the latest grails version?

Will Buck
  • 1,500
  • 16
  • 25

7 Answers7

17

I feel like a fool for not trying this, but...

Grails is working as a command from the Windows DOS prompt (cmd). It is NOT working from the bash I've been using on windows (git bash, out of convenience and familiarity with the linux cmds).

For those of you that find yourselves in this situation, Make SURE you try this in the Windows cmd prompt as well. (Those with any insight into why this is working in the DOS prompt but not in a custom linux-like bash please weigh in, I will update this answer with any findings I come across!)

Will Buck
  • 1,500
  • 16
  • 25
  • 5
    has anybody settled up grails on win to succesfull run @ msysgit shell? (it works fine when i run it from win cmd.exe, but it would be much better to be able to run grails from msysgit :) ) – Łukasz Siwiński Feb 23 '13 at 22:44
  • 1
    See my comment below -- if you apply the changes from http://jira.grails.org/browse/GRAILS-8271 to your startGrails script you can get this to work. – sfitts Feb 24 '14 at 22:44
7

I ran into this error message in the DOS CMD shell. Turned out, I had my GRAILS_HOME set to 2.2.0 but my PATH was pointed to Grails-2.2.1\bin. Once I fixed this mismatch, the error went away and things worked fine. Suggest using "set" in your CMD shell to see what your environment is actually set to.

SunilJ
  • 101
  • 1
  • 3
3

I faced the same issue in the msysgit console and could solve this by setting the environment variable $GRAILS_HOME to the unix format:

export GRAILS_HOME=/c/grails/2.0.3

This fixed the above error but leads to a new one when executing "grails run-app":

$ grails run-app
Error opening zip file or JAR manifest missing : /d/Programme/grails-2.2.4/lib/org.springsource.springloaded/springloaded-core/jars/springloaded-core-1.1.3.jar
Error occurred during initialization of VM
agent library failed to init: instrument

The jar can be found under logged path, so i dont know why it doesnt work. I'm still trying to solve this error.

I hope the above solution could help anybody.

  • This is caused by the fact that although msys converts most path arguments to Windows form it fails to do so for the -javaagent parameter. Given this you need to add special handling of this to the startGrails script. See http://jira.grails.org/browse/GRAILS-8271. It appears that this hasn't made a Grails release yet, but I've applied the change manually and it seems to work as expected. – sfitts Feb 24 '14 at 22:43
3

Grails 2.3.7, Win7, Java7, msysgit:

By default grails is failed to start from msysgit.

To fix copy cygpath.exe from cygwin to msysgit/bin. And modify startGrails

In the section # For Cygwin, ensure paths are in UNIX format before anything is touched

Replace

    if $cygwin ; then

with

    if [ $cygwin -o $mingw ] ; then

or just set GRAILS_HOME in grails/bin/startGrails in unix style, for example

$GRAILS_HOME=/c/program/grails-2.3.7

ps

useful link about cygpath.exe

Community
  • 1
  • 1
1

Your set up should work as-is afaict. I would verify that my grails installation is not corrupt.

Luis Muñiz
  • 4,649
  • 1
  • 27
  • 43
  • That's something I have not tried, I will try checking out the checksums (though the fact that I built it from source and got the same results gives me slight doubt to that theory). Thanks for the encouragement though! Is it worth noting that this is a virtual windows install, perhaps? – Will Buck Apr 22 '12 at 15:50
  • No, this is really basic stuff, out of many many grails installs I have never had trouble installing it into the system path. And most of these were on virtual machines. By the way you need not set up GROOVY_HOME to start grails. It comes with its own version of groovy. – Luis Muñiz Apr 22 '12 at 17:06
  • Right, I was fairly certain of that but you know how it goes when the rational answers start to fail you; have to start exploring the irrational. I have had no trouble installing grails and getting started in linux and mac environments half a dozen times now, so its frustrating to be running into roadblocks this early in the process :/ – Will Buck Apr 23 '12 at 14:51
  • try to modify the grails starter to launch java in -verbose mode. This will hopefully show enough information about the class loading so that you can figure out what's wrong. – Luis Muñiz Apr 23 '12 at 21:04
  • Not sure where you mean by 'modify grails starter', but that will likely be a help. Also I could not find a checksum for the zip on the grails.org website! So I'm not sure how to check the integrity, however... – Will Buck Apr 24 '12 at 00:42
  • You can add -verbose to startgrails.bat in %GRAILS_HOME%\bin or maybe try set JAVA_OPTIONS=-verbose in the command line, before executing run-app – Luis Muñiz Apr 24 '12 at 07:51
0

I had this problem and I realized that I had groovy 2.1.7 in the path. I removed this groovy from path and Grails worked.

Anderson Lopes
  • 639
  • 7
  • 10
0

As user 'sfitts' pointed out in his comments (which I cannot yet append to), the problem was addressed/fixed at http://jira.grails.org/browse/GRAILS-8271 . This fix was already incorporated in my Grails 2.3.11 installation.

However I additionally had to undefine my GRAILS_HOME environment variable in Windows for this to work (the startup script automatically detects and sets this variable).

codecodewut
  • 63
  • 1
  • 4