Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with Grails Framework #11

Open
mradzinski opened this issue Sep 22, 2015 · 3 comments
Open

Usage with Grails Framework #11

mradzinski opened this issue Sep 22, 2015 · 3 comments

Comments

@mradzinski
Copy link

If I follow the usage examples on a Grails v2.3.11 application I always get a MissingMethodException like the one below:

groovy.lang.MissingMethodException: No signature of method: rx.Observable.subscribe() is applicable for argument types: (my.package.TestController$_show_closure1)

Seems like the Subscribe() method does not allow closures, but as per the examples it should allow them.

I configured my dependencies like:

dependencies {
    compile 'io.reactivex:rxjava:1.0.14'
    compile 'io.reactivex:rxjava-groovy:1.0.2'
}

Any idea why is this happening? You can use the Hello World example to try reproducing this (it's the one I'm using).

@mradzinski mradzinski changed the title Using with Grails Framework Usage with Grails Framework Sep 22, 2015
@mradzinski
Copy link
Author

Ok, there seems to be an issue with Grails framework and how it loads the Groovy ExtensionModules. Just add the below code to your BootStrap.init to make Grails load the ExtensionModules from your dependencies.

def loadGroovyExtensionModules() {
    Map<CachedClass, List<MetaMethod>> map = [:] 

    ClassLoader classLoader = Thread.currentThread().contextClassLoader 

    try { 
        Enumeration<URL> resources = classLoader.getResources(MetaClassRegistryImpl.MODULE_META_INF_FILE) 
        for (URL url in resources) {

            if (url.path.contains('groovy-all')) { 
             // already registered 
             continue 
            } 

            Properties properties = new Properties() 
            InputStream inStream 

            try { 
                inStream = url.openStream() 
                properties.load(inStream) 
                GroovySystem.metaClassRegistry.registerExtensionModuleFromProperties(properties, classLoader, map) 
            } catch (IOException e) { 
                throw new GroovyRuntimeException("Unable to load module META-INF descriptor", e) 
            } finally { 
                inStream?.close() 
            }

        } 
    } catch (IOException ignored) {} 

    map.each { CachedClass cls, List<MetaMethod> methods -> 
       cls.addNewMopMethods(methods)
    } 
}

@kevintanhongann
Copy link

What is the latest Gradle dependency to add into Grails for RxGroovy? Is this still valid?

@kevintanhongann
Copy link

kevintanhongann commented Mar 25, 2018

I got somethign like this for mine
Caused by: BUG! exception in phase 'canonicalization' in source unit '/.../Address.groovy' rx.lang.groovy.RxGroovyPropertiesModuleFactory cannot be cast to org.codehaus.groovy.runtime.m12n.PropertiesModuleFactory at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:174) at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:56) at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkerAdapter.execute(AbstractDaemonCompiler.java:73) at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkerAdapter.execute(AbstractDaemonCompiler.java:64) at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:29) at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerDaemonServer.execute(AbstractDaemonCompiler.java:91) at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:88) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:147) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:129) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404) ... 2 more Caused by: java.lang.ClassCastException: rx.lang.groovy.RxGroovyPropertiesModuleFactory cannot be cast to org.codehaus.groovy.runtime.m12n.PropertiesModuleFactory at org.grails.compiler.gorm.DirtyCheckingTransformer.addDirtyCheckingSetter(DirtyCheckingTransformer.groovy:299) at org.grails.compiler.gorm.DirtyCheckingTransformer.performInjectionOnAnnotatedClass(DirtyCheckingTransformer.groovy:225) at org.grails.compiler.gorm.GormEntityTransformation.visit(GormEntityTransformation.groovy:200) at org.grails.compiler.gorm.GormTransformer.performInjection(GormTransformer.java:70) at org.grails.compiler.gorm.GormTransformer.performInjectionOnAnnotatedClass(GormTransformer.java:75) at org.grails.compiler.injection.ArtefactTypeAstTransformation.performInjection(ArtefactTypeAstTransformation.java:180) at org.grails.compiler.injection.GlobalGrailsClassInjectorTransformation.visit(GlobalGrailsClassInjectorTransformation.groovy:126) ... 14 more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants