Grails Spring Core Security Plugin - Unable to Resolve Classes - spring

I'm using Grails 2.2.2 and I've already installed spring-security-core-2.0-RC2, by adding the below lines in my BuildConfig.groovy file:
Under the plugins:
compile ':spring-security-core:2.0-RC2'
Under Repositories:
mavenRepo 'http://repo.spring.io/milestone'
The plugin was installed successfully and I've created the security Domains and Controllers using s2-quickstart script.
Now, I've updated one of my controllers with the below code:
import grails.plugins.springsecurity.Secured
#Secured(['ROLE_ADMIN'])
However when I try to run the application I get the below error:
| Error Compilation error: startup failed: C:\workspace\SW
Development\Production\MyGrailsApp\safami\grails-app\controllers\safami\InfoPageAdminController.groovy:
4: unable to resolve class grails.plugins.springsecurity.Secured #
line 4, column 1. import grails.plugins.springsecurity.Secured
I'm new to Grails and I need your detailed solution.

The annotation was moved to a different package - change
import grails.plugins.springsecurity.Secured
to
import grails.plugin.springsecurity.annotation.Secured

Related

Upgraded to grails 3 and now get unable to resolve class org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap

unable to resolve class org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap
# line 4, column 1.
import org.codehaus.groovy.grails.web.servlet.mvc.GrailsParameterMap
This happened when I upgraded grails from 2.2.4 to 3.1.3.
Is there some new place I need to import this too? Or is there a dependency I need to add to my gradle build file?
See step 5 on this page, https://docs.grails.org/3.0.x/guide/upgrading.html
Step 5 - Modify Package Imports In Grails 3.x all internal APIs can be
found in the org.grails package and public facing APIs in the grails
package. The org.codehaus.groovy.grails package no longer exists.
All package declaration in sources should be modified for the new
location of the respective classes. Example
org.codehaus.groovy.grails.commons.GrailsApplication is now
grails.core.GrailsApplication.

Maven Project Library Not Found

I have maven project where i am adding the dependencies which are not resolvable as below.
My servlet is as follows:
LocaleUtil is getting resolve but its sub packages are throwing error when including.
I have tried invalidate cache and restart. But this didn't work for me.
Thanks,
The packages you are trying to import are internal, non-exported packages of the bundle com.adobe.granite.i18n. In fact, that bundle only exports the following packages:
Export-Package
com.adobe.granite.i18n {version=1.0, imported-as=[1.0.0,1.1)}
com.day.cq.i18n {version=5.4.0}
You should not attempt to use private packages of a library. Limit yourself to using only the exported API.

Spring Boot "unable to resolve class" with Groovy

I'm new to Groovy, Spring Boot, and Gradle (using gradle as well) and am trying to build a small test program.
I have a main class EvalMain and a InputObj class in a com.eval package.
#Controller
class EvalMain {
#RequestMapping("/")
#ResponseBody
public static String textTest() {
def iO = new InputObj("dsa", "dasdsa", "U1dBRw==");
return iO.xorString();
}
}
when running "spring run EvalMain.groovy" I get the following error:
startup failed:
file:<filepath>EvalMain.groovy: 14: unable to resolve class InputObj
# line 14, column 18.
def iO = new InputObj("dsa", "dasdsa", "U1dBRw==");
I tried throwing an import at the top but then spring boot complained about this too? What am I missing here? Any help would be much appreciated, thanks!
after adding the import:
import com.eval.InputObj;
I get this error:
file:/<filePath>/EvalMain.groovy: 2: unable to resolve class com.eval.InputObj
# line 2, column 1.
import com.eval.InputObj
^
1 error
Not sure if this is a good way to do it, but I was able to run it with "spring run .groovy .groovy" I wonder if there's the equivalent of a makefile?
Try to run spring run *.groovy.
Spring Boot CLI is for quick prototyping a single Groovy script. It tries to autoload all Spring Boot dependencies, but its your responsibility to include your additional dependencies
If you have just multiple source files you have to pass it to the CLI.
If it is an external dependency, include it with a #Grab, see here.
However, you have Gradle and more than one source file. Therefor it might be the time to switch from the Spring Boot CLI to a normal Gradle project.
Just go to the guides and choose "Build with Gradle". Then you will see an example Gradle build file. Also the Gradle Spring Boot plugin documentation provides samples.
You can start your application with gradlew bootRun.

Unable to import Spring Security #Secured Annotation into Grails 3

I am currently following the Spring Security 3.0.0.M1 plugin tutorial for Grails here and I appear to be stuck on Step 8. Using the statement import grails.plugin.springsecurity.annotation.Secured does not work because Grails cannot resolve the package name. I know that Spring Security for Grails 3 is in its infancy, but has anyone been able to get past this step yet? For reference, here is my SecureController class (with a another import that also does not work):
package ldaptest.controllers
import grails.plugin.springsecurity.annotation.Secured;
import org.springframework.security.access.annotation.Secured;
#Secured('ROLE_ADMIN')
class SecureController {
def index() {
render 'Secure access only'
}
}
I may found a solution:
Create a "lib" folder e.g. inside your "grails-app" directory.
Download the SpringSecurityCore JAR from here and move it into the lib directory
Add gradle dependency:
compile files('lib/spring-security-core-3.0.0.M1.jar')
Hope this helps.
Greetings
I had:3,1,1 the save problem with my application. I solved it by adding as a library to my project. However I had to change import package to make it work.
import org.springframework.security.access.annotation.Secured
I am using IntelliJ IDEA, I just has to search the maven repo for the spring-security-core:3.1.1.
In IntelliJ you do : File > Project Structure > Libraries > Add > From Maven Repository. Then do the search according to the version of "spring-security-core" you want to use.

Package org.springframework.aop.framework does not exist

I have installed grails and am trying to compile with the default version of cache:1.1.6 and I'm getting these errors within the plugin code.
Can any one help me with which dependency is broken in the repository - I havent even used the cache yet - just defined it in BuildConfig.groovy
I understand "By default, Grails will not only get the JARs and plugins that you declare, but it will also get their transitive dependencies" so why would I have to declare the dependencies?
Compilation error: startup failed:
Compile error during compilation with javac.
D:\Users\ve\.grails\2.4.0\projects\demo\plugins\cache-1.1.6\src\java\grails\plugin\cache\CustomCacheKeyGenerator.java:18: error: package org.springframework.aop.framework does not exist
import org.springframework.aop.framework.AopProxyUtils;
^
D:\Users\ve\.grails\2.4.0\projects\demo\plugins\cache-1.1.6\src\java\grails\plugin\cache\web\PageInfo.java:43: error: package org.springframework.aop does not exist
import org.springframework.aop.PointcutAdvisor;
^
D:\Users\ve\.grails\2.4.0\projects\demo\plugins\cache-1.1.6\src\java\grails\plugin\cache\web\PageInfo.java:44: error: package org.springframework.aop does not exist
import org.springframework.aop.TargetSource;
Odd this is with a new Grails application? It sounds like it could be a corrupt Maven cache issue. Try doing:
$ rm -rf ~/.m2/repository
Otherwise, to declare the dependency explicitly edit BuildConfig and add:
compile 'org.springframework:spring-aop:4.0.5.RELEASE'
To your dependencies block.

Resources