4

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.

Community
  • 1
  • 1
mzuba
  • 1,226
  • 1
  • 16
  • 33

3 Answers3

2

Perhaps an even easier fix, that solved the issue when I was running into it:

Regardless of whether you have already installed it by other means, run:

grails install-plugin shiro

While this might tell you that the plugin is already installed, this will also sort out the pathing for you, which should fix the issue.

Simon Piel
  • 93
  • 6
2

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.

Julian
  • 994
  • 1
  • 9
  • 19
0

I found that making sure you have done the following worked

Inserted compile ":shiro:1.2.1" into BuildConfig.groovy

Run the command grails compile

right click in the project > grails tools > refresh dependencies

andy mccullough
  • 9,070
  • 6
  • 32
  • 55