Search code examples
eclipsegrailsimportshiro

Grails problem with shiro-quick-start: imports cannot be resolved (by Eclipse)


On my fresh new grails project, I installed shiro (grails install-plugin shiro) and the quick setup grails shiro-quick-start. This generated new files as described in the shiro documentation.

However, in one of those files, controllers/(default package)AuthController.groovy there are eight problem marked by eclipse (SpringSource Tools Suite). Five of those problems address the five imports respectively:

 Groovy:unable to resolve class org.apache.shiro.authc.AuthenticationException
 …

Specifying the correct package and moving the file to that package doesn’t solve the problem. The three other problem markers are:

 Groovy:Catch statement parameter type is not a subclass of Throwable.

(x3) I suppose this problem might be related to the failed imports and might thus vanish once the previous problem is resolved.

Now, I could set up shiro myself without the quick start, but tbh I’d prefer to stick with the quick start and expand on that, as described in the guide.

(obvious) Question 1: Does anybody have an idea as to why Eclipse gives me those error messages? Did I miss a step in the installation process?

(not so important) Question 2: I tried to apply the fix to the (default package) issue, only to find that there is already a reference to the package path at the relevant part of _ShiroInternal.groovy. Why does it still install to default directory? Might this be related to my problem?

Additional oddity: There is another file, realm/ShiroDbRealm.groovy, that includes imports of org.apache.shiro resources. There is no package declaration and there are no error markers in Eclipse. Once I add the correct package declaration of my project and move the file to that package, imports cannot be resolved anymore. This might be a clue to what is happening here.


Solution

  • You have to add the shiro library jars to the eclipse project build path. The librarys (in my case) are by default installed to the grails project plugin directory in my home folder.