Repetitive method name/signature for method compilation error when using #I18nFields - grails

I get repetitive method name/Signature compilation failure when i try to use i18nFields in my domain class to support multiple languages.
Grails Version : 2.3.7 ( I tried with 2.3.4 and got the same issue and upgraded)
Documentation from Grails followed for this was http://grails.org/plugin/i18n-fields
My Domain class looks like
package com.sampleapp.domain
import i18nfields.I18nFields;
#I18nFields
class Products {
def name
static constraints = {}
static i18nFields = ['name']
}
My Config.groovy has the below line included to specify the locale
// internationalization support - testing
i18nFields {
locales = ['en','es']
}
BuildConfig.groovy plugin definition
plugins {
// plugins for the build system only
build ":tomcat:7.0.47"
// plugins for the compile step
compile ":scaffolding:2.0.1"
compile ':cache:1.1.1'
// plugins needed at runtime but not for compilation
runtime ":hibernate:3.6.10.6" // or":hibernate4:4.1.11"//
runtime ":database-migration:1.3.8"
runtime ":jquery:1.10.2.2"
// compile ":jquery-ui:1.10.2.2"
runtime ":resources:1.2.1"
// Uncomment these (or add new ones) to enable additional resources capabilities
runtime ":zipped-resources:1.0.1"
runtime ":cached-resources:1.1"
//runtime ":yui-minify-resources:0.1.5"
compile ':platform-core:1.0.RC6'
compile ":cache-headers:1.1.5"
runtime ':spring-security-core:2.0-RC2'
// internationalization
compile ":i18n-fields:0.8.1"
}
The compilation error is
grails-workspace\Test\grails-app\domain\com\sampleapp\domain\Products.groovy: -1: Repetitive method name/signature for method 'void setName_es(java.lang.String)' in class 'com.sampleapp.domain.Products'.
# line -1, column -1.
The Error is repeated for the name property for both en and es locales twice.
There is no error if i remove the i18nFields annotation and the sample app worked fine before this. I verified GGTS repetitive method name/signature error in controllers post for similar error in controller. I have also verified to ensure that groovy version is correct and in my case it is 2.1
Can somebody please give me any pointers on where i should look to resolve this issue.

This problem shows up when you are trying to use Java > v7 with any version of Grails < 2.3.7. Either downgrade your jvm or upgrade your grails.

Thanks for trying (and for making me know via github ;) )
The issue was known but hadn't been tackled yet.
The previous answer (commenting out methods) is not exact, event though it follows the right track, because the problem comes from new changes in Grails that will cause a collision in getters and setters.
The solution I've found is to separately create the property and the getter/setter, and it seems to work.
I'm releasing a new version as soon as it can be fully tested in a project, but code is already available in https://github.com/jorgeuriarte/grails-i18n-fields-plugin/tree/redis_integration (version 0.9-redis-SNAPSHOT) in case you want to use it.

Probably it has something to do with the new Binding mechanism in grails 2.3. Maybe the getters and setters are set automatic now?
When I comment out these two lines in ClassI18nalizator.groovy the error disappears. It seems to work at least partly. I can use the fields in scaffolding. It's not a real solution but maybe a hint for someone who understands grails better than me.
private def getSetterMethod(field) {
// setter should return void. that's why the return statement.
//return new AstBuilder().buildFromString("i18nfields.I18nFieldsHelper.setValue(this, '${field}', value); return;").pop();
}
private def getGetterMethod(field) {
//new AstBuilder().buildFromString("i18nfields.I18nFieldsHelper.getValueOrDefault(this, '${field[0..-7]}', '${field[-5..-1]}')").pop();
}
After that I run into a second issue:
No signature of method: groovy.util.ConfigObject.contain() is
applicable for argument types: (java.lang.String) values: [en_US]
I solved it by adding redisLocale to Config.groovy
i18nFields {
locales = ['de_DE', 'en_US']
defaultLocale = "en_US"
redisLocales = ['de_DE', 'en_US']
}

Related

grails.plugin.springsecurity.annotation problem - secured plugin is not resolving

I used grails 3.1.X in NetBeans 8.1.
Secured plugin is not resolving wen a used annotation. Code below:
package securityplugintest
//import grails.plugins.springsecurity.Secured
import grails.plugin.springsecurity.annotation.Secured //not esolved
#Secured(['ROLE_USER']) //not resolved
class ProductAnnouncementController {
def index() {
def announcements = ProductAnnouncement.createCriteria().list {
order("dateCreated", "desc")
maxResults(1)
}
render announcements.first()?.message
//render announcements.any()?.meassage
}
}
In NetBeans I have configured Grails 3.1.11, and spring-security plugin as
dependencies {
compile 'org.grails.plugins:spring-security-core:3.0.3'
}
I am following this manual and getting error for the last step.
Well First thing you should add plugin compile 'org.grails.plugins:spring-security-core:3.1.1 under the build.gradle .
I have just given you the different plugin version than that of you are using nothing more.
Second thing you should compile your project after adding the plugin.
This should do the trick for you.
But as you have stated that you are getting the red line under the import grails.plugin.springsecurity.annotation.Secured after above steps.
Please follow the below step :
As stated in the Grails 3 docs ->
To use annotations, specify securityConfigType="Annotation" , or
leave it unspecified because it’s the default:
Specifying securityConfigType as “Annotation”
grails.plugin.springsecurity.securityConfigType = "Annotation"
In your case please try to specify it.
And before running the app please clean -> compile -> run your app.
Can you please change your plugin to compile 'org.grails.plugins:spring-security-core:3.1.1' and compile it once added. – Prakash Thete

Error with spring security plugin in grails 2.4.0.M1

i'm running into a compilation issue, using grails 2.4.0.M1 and spring-security-core:2.0-RC2
this is the error:
..../target/work/plugins/spring-security-core-2.0-RC2/src/groovy/grails/plugin/springsecurity/ReflectionUtils.groovy:
205: Apparent variable 'org' was found in a static scope but doesn't
refer to a local variable, static field or class. Possible causes:
You attempted to reference a variable in the binding or an instance
variable from a static context. You misspelled a classname or
statically imported field. Please check the spelling. You attempted
to use a method 'org' but left out brackets in a place not allowed by
the grammar. # line 205, column 18.
application = org.codehaus.groovy.grails.commons.ApplicationHolder.application
^
the problem seems to be around this method
private static GrailsApplication getApplication() {
if (!application) {
application = org.codehaus.groovy.grails.commons.ApplicationHolder.application
}
application
}
on the class ReflectionUtils.groovy,
does anyone else as ran into something like this? if so how do you fixed it?
I fixed this today - https://github.com/grails-plugins/grails-spring-security-core/commit/ef3aab05bfb0eb2f2cbb2c5945f4fc9ca2f0697d
You can make the change that #Bubuntux showed as a temporary workaround, and I'll be releasing 2.0 final in a couple of weeks with this fixed. Hopefully you're not planning on using a Grails M1 release in production, so the delay shouldn't be too much of an issue.
Seems like the ApplicationHolder class was deprecated a long time ago, and now removed on grals 2.4
so i just change the line
application = org.codehaus.groovy.grails.commons.ApplicationHolder.application
to
application = Holders.grailsApplication

Grails startup error message

When I start my Grails-application I get the following error:
WARNING: Configurational method [checksums] in grails-app/conf/BuildConfig.groovy doesn't exist. Ignoring..
WARNING: Configurational method [inherits] in grails-app/conf/BuildConfig.groovy doesn't exist. Ignoring..
In my BuildConfig.groovy I have the following:
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
checksums true // Whether to verify checksums on resolve
And later in the file:
repositories {
inherits true // Whether to inherit repository definitions from plugins
Perhaps some kind soul can shed some light on the message and how I can get rid of it.
Thanks!
Those properties were added in 2.0, so it looks like you've copy/pasted some 2.0 project code into a 1.3.x project, or possibly upgraded and then downgraded? Either way, delete both lines and you'll get past this issue, although there may be other copy/paste issues still lurking.

Error PayPal plugin on grails 2.0.0.RC3

I use grails 2.0.0.rc3, when I install PayPal plugin I have this error:
Error Compilation error: startup failed:
/Users/sartre/.grails/2.0.0.M1/projects/testapp/plugins/paypal-0.6.4/grails-app/controllers/org/grails/paypal/PaypalController.groovy: -1: The return type of java.lang.Object notify() in org.grails.paypal.PaypalController is incompatible with void notify() in java.lang.Object
. At [-1:-1] # line -1, column -1.
1 error
How can I fix it?
Many thanks for any idea
Incompatibility change in grails 2.0!!
It seems that it is related to a small change in grails 2.0.
It is now possible to define controller actions as methods instead of using closures as in previous versions of Grails. (from official doc : http://grails.org/doc/2.0.x/guide/introduction.html#webFeatures)
It behaves like the closure notify in PaypalController overrides the Object.notify method.
If you rename notify in notifyPaypal, it should work.

Is there a groovyws.jar with all his dependences?

I'm using Grails and want to use groovyws to call an web-service.
But my groovyws.jar (0.5.2) have MANY dependences that I can't solve.
Is there any jar with all dependences included?
Note: I tried put in BuildConfig.groovy, this
dependencies {
'org.codehaus.groovy.modules:groovyws:0.5.2'
}
but I'm getting error:
Error executing script Compile: loader constraint violation: when
resolving overridden method
"org.apache.xerces.jaxp.SAXParserImpl.getParser()Lorg/xml/sax/Parser;"
the class loader (instance of
org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the
current class, org/apache/xerces/jaxp/SAXParserImpl, and its
superclass loader (instance of ), have different Class
objects for the type org/xml/sax/Parser used in the signature
You can manually exclude xerces by:
dependencies {
runtime('org.codehaus.groovy.modules:groovyws:0.5.2') {
exclude: 'xerces'
}
}
GroovyWS pulls inn CXF, which again pulls in a lot of dependencies, some of them conflicting with classes already present in Java 6. You need to exclude all these dependencies if using Java 6, to avoid errors like the one you mention.
Here's my exclude list:
compile("org.codehaus.groovy.modules:groovyws:0.5.2") {
excludes 'geronimo-servlet_2.5_spec', 'servlet-api', 'jaxb-xjc', 'jaxb-impl', 'xml-apis', 'saaj-impl', 'junit', 'slf4j-jdk14', 'xmlParserAPIs', 'jaxb-api', 'saaj-api', 'xmlbeans', 'jaxen', 'geronimo-stax-api_1.0_spec', 'geronimo-activation_1.0.2_spec', 'abdera-client', 'geronimo-activation_1.1_spec'
}
Note that on Ubuntu you need jaxb-xjc and jaxb-impl after all, don't know why.
I found:
http://docs.codehaus.org/dosearchsite.action?queryString=groovyws+standalone
Tks a lot!
(search for "groovyws standalone")
Note: I saw this tip here.

Resources