Groovy: Unexpected token “:”

I have this auto generated lines of codes:

EPRole validator: { EPRole r, EPUserEPRole ur -> if (ur.EPUser == null) return boolean existing = false EPUserEPRole.withNewSession { existing = EPUserEPRole.exists(ur.EPUser.id, r.id) } if (existing) { return 'userRole.exists' } }

When I try to compile the code I get 82: unexpected token: validator @ line 82, column 10.

I am new in groovy so any help is appreciated.


You should add your properties with the proper type and name to the class. First letter uppercase is for classes (or types in general). So there should be in your EPUserEPRole a property like this:

EPRole epRole

Then add the validator for epRole. Pay attention to the case.

Above code would confuse the groovy parser into defining a property validator of type EPRole followed by a :, hence the error (or else it would try to call the method EPRole with the map, depending on context).


  • Convert Future[List[String]] to List[String]
  • QAbstractListModel insertRows not working properly
  • QTableWidget find a row through userdata
  • Printing binary values in Java
  • Android Studio - MonkeyTalk Integration - Issues
  • Error while running “ jekyll serve ” command
  • Java programming task efficiency [duplicate]
  • Core plot- prevent zooming/scaling of plot to show full axes range
  • Keras summation Layer acting weird, summing over training set
  • EntityDataSource query inner join
  • Azure deployment continually recycling since upgrading the June 2012 SDK 1.7
  • os.system not working, but typing the same thing into the command prompt works
  • Number of ways to partition a number in Python
  • Can cPickle save reshaped numpy object reference?
  • Fatal error on Windows XP when compiled with XP Targeting in Visual Studio 2015
  • Grails Transactions and the Session
  • How to extract a plane from a 3D variable in FiPy (3D to 2D)
  • How to make nicEditor snaplet? (Several questions)
  • How to turn (A, B, C) into (AB, AC, BC) with Pig?
  • apply a javascript function to draggable copy
  • Cannot save model when using ember render helper
  • Android changing fragment order inside FragmentPagerAdapter
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Create DicomImage from scratch using Dcmtk
  • How to create a file in java without a extension
  • How to access EntityManager inside Entity class in EJB3
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Read text file and split every line in MSBuild
  • How reduce the height of an mschart by breaking up the y-axis
  • MySQL WHERE-condition in procedure ignored
  • Perl system calls when running as another user using sudo
  • How to delete a row from a dynamic generate table using jquery?
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • How to stop GridView from loading again when I press back button?
  • Qt: Run a script BEFORE make
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs