Why does Spring Security Core RC4 require Grails 2.3? - grails

On the Spring Security Core plugin GitHub repo, I see that Graeme on May 21st upped the required version of Grails from 2.0 to 2.3 before the RC4 version was released a couple of months later, but I don't see any explanation for why. Was it mismatched dependencies, bug reports, etc?
I run a 2.2.4 app, and I would prefer not to upgrade at this point just to get the latest RC of spring security core. I understand if the upgrade to 3.2.0.RELEASE of spring security caused mismatched dependencies with older versions of Grails since I've run into the same issues before.
This originally came up due to a pull request on the spring security OAuth2 provider plugin that I maintain. The pull request upped the required version to 2.3, and the requester pointed me to the RC4 release of core as the reason.
Thanks for the good works as always!

It's pure speculation on my part, but as far as I can tell, it has to do with the getNamespace() method introduced in the UrlMappingInfo interface in Grails 2.3.
The Spring Security Core plugin's class AnnotationFilterInvocationDefinition does check if it's dealing with Grails 2.3 or higher before it attempts to call getNamespace(), but in its current state it causes a compilation error (due to the missing method).
I suppose the class could resort to using the reflection API to get around this, making it possible to lower the requirement to Grails 2.2.0 (or keep it at 2.0.0)
String namespace = null;
try {
Method m = mapping.getClass().getDeclaredMethod("getNamespace", null);
namespace = (String)m.invoke();
} catch(NoSuchMethodException e) { ... }

Related

Is it possible to have different gorm versions in plugins within a grails 3 application?

I have a grails 3 application that makes heavy use of plugins. Some of these plugins provide domain classes. My application will not start unless every plugin has the same gorm version. This is an annoyance for locally developed plugins, but can be a significant problem for using third-party plugins.
There are more details in the stacktrace, but the relevant parts appear to be:
Caused by: org.grails.core.exceptions.GrailsRuntimeException: Failed to introspect class: class (my class name)
at grails.core.ArtefactHandlerAdapter.isArtefact(ArtefactHandlerAdapter.java:129)
at grails.core.DefaultGrailsApplication.addOverridableArtefact(DefaultGrailsApplication.java:772)
at org.grails.plugins.AbstractGrailsPluginManager.registerProvidedArtefacts(AbstractGrailsPluginManager.java:310)
I am currently using Grails 3.2.8 with GORM 6.1.3.RELEASE, but this happens with other non-matching versions for gorm as well.
If there is a better way to accomplish the bigger-picture goal, my big-picture goal is to use the grails ehcache plugin (currently at 3.0.0.M1) which requires gorm 6.1.x as a minimum. Per conversations on that plugin github site, there is no problem using gorm 6.1 with grails 3.2.x, though this is not the default.
Is there any way to run a grails 3 application, using plugins which provide domain objects, in which these plugins have different minor versions of gorm?
In case anyone else comes across this, the answer was basically "no".
The longer answer is "not as long as the groovy version is changing in non-backwards-compatible ways", and apparently that happens a lot.
There are some comments from Graeme here: https://github.com/grails/grails-core/issues/10693 but to summarize: you have to use the same version of gorm across plugins, and also make sure any third-party plugins you rely on are on the same version. This is only required for plugins that provide domain objects, at least!

Grails 3 and Spring Security Plugin

I've just recently started working with Grails, and I'd like to test out the Spring Security Plugin. I'm using Grails v3.0.0RC2, and I'm finding it difficult to come across accurate documentation for it with a lot of things.
I'm looking at the Grails page for the Spring Security Plugin, located at http://grails.org/plugin/spring-security-core, and it tells me to add the following to grails-app/conf/BuildConfig
plugins {
…
compile ':spring-security-core:2.0-RC4'
…
}
Now, Grails 3 has done away with the BuildConfig, and moved over to using Gradle. So I figured I could just that compile line to my "dependencies" section in build.gradle and it would work, like so:
dependencies{
...
compile:":spring-security-core:2.0-RC4"
}
However, that did not work. I get the error "Could not find :spring-security-core:2.0-RC4...".
Then I figured, 'Hey, it's a plugin, let me try prefacing it with "org.grails.plugins" like I see elsewhere in the build.gradle file:
dependencies{
...
compile:"org.grails.plugins:spring-security-core:2.0-RC4"
}
And still no go.
I have gotten it to compile by adding the dependency found on search.maven.org, like so:
dependencies{
...
compile 'org.springframework.security:spring-security-core:4.0.0.RELEASE'
}
But I don't think thats the proper way to do, because Grails documentation says I should have access to the command
grails s2-quickstart
once the plugin is installed, which I do not when I do it using the Maven repo.
I'm sure there's a simple configuration error I'm making, as I'm very new to both Grails, Spring, and Gradle, so I appreciate any help that can be provided.
The Spring Secuirty core plugin for Grails is not Grails 3 compatible. However, since Grails 3 is based on Spring Boot you can use the Spring Security Starter for Spring Boot instead.
This has been discussed on the Grails developers mailing list and going forward many Grails plugins will not be moved to Grails 3 and instead will be replaced by pure Spring solutions.
Update
Since this question was originally asked there has been a Spring Security plugin created for Grails 3.x. It can be found here: https://bintray.com/grails/plugins/spring-security-core/view
The "Spring Security Starter for Spring Boot" is a good starting point, but if you want to save yourself some time trying to figure out how to get it to work with Grails, check out this helpful blog post.
I wrote the blog post #Jamie referenced in his answer and I added a new blog post describing how to use the Gorm domain classes from Spring-Security-Core plugin from Grails 2.
dependencies {
...
compile 'org.grails.plugins:spring-security-core:3.0.4'
...
}
This is what I used and it worked for me

Clustered cache in Grails 2.4.x

I need suggestions on cache clustering for Grails at the most recent version I can get.
I've been trying to set up Terracotta with Grails 2.4.4 but I can't manage to find a compatible version of its plugin (by the way, the Terracotta plugin page says it was last updated 6 years ago). Also I can't find any recent posts on cache clustering for grails.
I'm planning on using it also for session replication. I'm using Apache Shiro for authentication/authorization. But that shouldn't matter.
Ehcache has an embedded distributed solution based on RMI. I'm gonna give it a try but I'm not sure it'll work for web sessions in grails since the documentation says to use Terracotta.

Is Camel Spring ws compatible with spring ws 2.0.2.RELEASE?

The documentation says that camel-spring-ws(v2.7.1) officially supports spring-ws 1.5.9, but doesn't mention spring-ws 2.0.2.RELEASE. I'd like to stick with 2.0.2.RELEASE instead trying to retrofit 1.5.9 to work with Spring 3.0, but I'm hitting enough roadblocks to make me think that it's just not going to work.
Has anyone been successful with this?
Thanks,
Roy
There is a ticket to upgrade to use Spring 2.0.2. The was a bug in Spring WS 2.0.0 and 2.0.1 releases in terms of not working with OSGi. That should hopefully be fixed in Spring WS 2.0.2.
If you are not using OSGi you can most likely manually upgrade to Spring WS 2.0.x. But it requires a bit of work as some JARs have changed and whatnot.
Camel 2.8 should use the Spring WS 2.0.2 by default.
The ticket is here: https://issues.apache.org/jira/browse/CAMEL-3735

Grails + Gpars.memoize().. how to do memoization?

I can't seem to figure out how to do memoization in Grails. According to the GPars docs it should be as simple as
def c = { x -> x*2 }.memoize() or ... .gmemoize()
But all i seem to get is compilation errors and stacktraces thrown. Has anyone successfully used gpars with grails?
Grails up until 1.4.0m1 bundled an old version of gpars (0.9) that didn't include memoization. Since Grails preferes the bundled libs to the user-specified ones, you never get a chance to see the memoization methods.
To my best knowledge the Grails master branch has already fixed that and gives users the freedom to choose a GPars version they like.
We are currently successfully using GPars data flow concurrency in a Grails 1.3.7 application. GPars is defined as a basic jar dependency in BuildConfig.groovy, we are not using the GPars Grails plugin.

Resources