grails / grails-core

The Grails Web Application Framework
http://grails.org
Apache License 2.0
2.78k stars 951 forks source link

Prepare Grails 3 Internals for Webflow Plugin #601

Open dtamm opened 9 years ago

dtamm commented 9 years ago

Due to platform refactoring, the whole internals of grails 3 have been reworked. With this step, the internals, which made the webflow plugin work, were removed. To get the webflow plugin to work, the internals like "isFlowAction()" have to be restored.

dtamm commented 9 years ago

will try myself on tuesday, when i am back in the office. also thnking of getting all the internals into the plugin aswell... will post update later

graemerocher commented 9 years ago

Any update?

dtamm commented 9 years ago

Not yet, will do it on the next weekend (work occupied me alot!), will give feedback on saturday!

dtamm commented 9 years ago

Hmpf, just tried myself with it, took the notes from the upgrading guide... and with "grails compile" i get that the "SpringWebDataBinder" is missing... even getting the code into the same application doesn't work for me... any hints?

dtamm commented 9 years ago

Ups, forgot the stacktrace:

General error during conversion: java.lang.NoClassDefFoundError: org/codehaus/gr
oovy/grails/web/binding/spring/SpringWebDataBinder

java.lang.RuntimeException: java.lang.NoClassDefFoundError: org/codehaus/groovy/grails/web/binding/spring/SpringWebDataBinder
        at org.codehaus.groovy.control.CompilationUnit.convertUncaughtExceptionToCompilationError(CompilationUnit.java:1083)
        at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1061)
        at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:583)
        at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:561)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:538)
        at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:517)
        at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:122)
        at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:47)
        at org.gradle.api.internal.tasks.compile.daemon.CompilerDaemonServer.execute(CompilerDaemonServer.java:53)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360)
        at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.NoClassDefFoundError: org/codehaus/groovy/grails/web/binding/spring/SpringWebDataBinder
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
        at org.gradle.internal.classloader.TransformingClassLoader.findClass(TransformingClassLoader.java:50)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:412)
        at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:655)
        at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:523)
        at org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:183)
        at org.codehaus.groovy.control.ClassNodeResolver.findClassNode(ClassNodeResolver.java:168)
        at org.codehaus.groovy.control.ClassNodeResolver.resolveName(ClassNodeResolver.java:124)
        at org.codehaus.groovy.control.ResolveVisitor.resolveToOuter(ResolveVisitor.java:617)
        at org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:269)
        at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1159)
        at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:142)
        at org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit$1.call(JavaAwareCompilationUnit.java:67)
        at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1047)
        ... 18 more
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.grails.web.binding.spring.SpringWebDataBinder
        at org.gradle.internal.classloader.TransformingClassLoader.findClass(TransformingClassLoader.java:41)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        ... 35 more
graemerocher commented 9 years ago

SpringWebDataBinder was removed and replaced with Grails' implementation

dtamm commented 9 years ago

okay thought so, but i cant see and reference to the SpringWebDataBinder in any source code file? strange!

dtamm commented 9 years ago

I dont think i can get it working by myself :( dont have that much time in my office to work on it... is there any plan to upgrade the plugin by one of you guys?

lifeweaver commented 8 years ago

Any update on this issue?

handicapskater commented 8 years ago

I have a project that will need Grails 3 Webflow by May 1. FYI, I have installed Grails 3.0.10, Groovy 2.4.5, Gradle 2.7 and JVM 1.8.0_65 to start testing. I am committing to working on it in case anyone else wants to collaborate on getting it done.

dtamm commented 8 years ago

Afaik, the grails team will work on this one, but only if you purchase the plugin... thats my latest info. if there's a community solution, that would be nice :) i haven't managed it to get it working in may 2015 :(

handicapskater commented 8 years ago

Did they give you a purchase price or any other information on getting it working?

dtamm commented 8 years ago

I only know that there are a small number of interests for the purchase till now (me and my office included)... no other information till now

handicapskater commented 8 years ago

SpringWebDataBinder is an interface in grails-core-2.4.4 and not in grails-core.3.0.10. So, it is going to mean looking at the different distributions and figuring out what is needed from 2.4.4 in 3.0.10 and if there is a new mechanism to handle whatever is missing. It seems doable and would be nice if we had some pointers from the Grails team to understand their vision, but we have tests to validate that the webflow plugin is working correctly.

lifeweaver commented 8 years ago

I'm glad you guys are still interested, we're looking to upgrade to grails 3, but are using webflow. I'll also point out that vinithpillai reported an issue using JDK 1.8.0_60 and Grails 2.5.1 with the webflow plugin.

handicapskater commented 8 years ago

Thanx for the info. FYI, I believe that 2.4.3 is the last version that webflow technically supports, however I have 2.4.4 (using jdk 1.8.0_31-b13) working and 2.4.5 is where SpringWebDataBinder was removed. Hence, the reason I jumped to 3.0.10, which as a contractor, principals are mandating. So, I am currently developing under 2.4.4 and will move it to 3.0.10, once the webflow plugin tests are working under 3.0.10.

snimavat commented 8 years ago

+1 for getting webflow plugin working - cant upgrade to grails 3 without having web flow

kastone commented 8 years ago
osscontributor commented 8 years ago

@snimavat Just to be clear... You can use web flow in Grails 3. You just can't use features provided by the plugin unless the plugin is ported. WebFlow can be still be used the way non-Grails users use it. I am not arguing that a plugin wouldn't be useful for the folks who want to use WebFlow. I am just pointing out that the absence of a plugin isn't going to be show stopper for many projects.

snimavat commented 8 years ago

Yeah @jeffbrown - if the plugin isnt ported, the solution would be to to go bare springwebflow.

dtamm commented 8 years ago

Any tutorial on how to implement pure webflow in grails without the plugin?

hko19 commented 8 years ago

+1 for getting webflow plugin working. Can't upgrade to grails 3 without having web flow.

osscontributor commented 8 years ago

Can't upgrade to grails 3 without having web flow.

@hko19 Is that because you can't get it to work or you just don't want to use it without the syntax that the Grails 2 plugin provided? (or some other reason)

lifeweaver commented 8 years ago

The SpringWebDataBinder is being used in the GrailsDataBinder class in the grails-web-databinding-spring dependency. From my browsing of the grails-core history it looks like the functionality of the GrailsDataBinder was partially split into other classes.

For example the GrailsDataBinder.createBinder() calls the GrailsDataBinder.registerCustomEditor() which looks a lot like PropertyEditorRegistry.registerCustomEditor() in grails 3.1.

osscontributor commented 8 years ago

I am not sure what you are doing with the binder but it may be that you don't really need to interact with it directly. If whatever you are doing is in a controller you should be able to just invoke the bindData(...) method. If you need to access binding from elsewhere, consider implementing the grails.web.databinding.DataBinder trait.

lifeweaver commented 8 years ago

I've downloaded the source for the webflow plugin and found that the ClosureInvokingAction uses the GrailsDataBinder which I found in the grails-web-databinding-spring jar. The org.codehaus.groovy.grails.web.binding.GrailsDataBinder implements the org.codehaus.groovy.grails.web.binding.spring.SpringWebDataBinder, which dtamm and others have been getting a java.lang.NoClassDefFoundError when trying to build.

I had a hard time tracking down where the java.lang.NoClassDefFoundError was coming from and wanted to point out where I thought it was coming from.

So would you say implementing the grails.web.databinding.DataBinder trait might actually work/is preferable to trying to use grails.web.databinding.GrailsWebDataBinder in place of the original org.codehaus.groovy.grails.web.binding.GrailsDataBinder?

osscontributor commented 8 years ago

So would you say implementing the grails.web.databinding.DataBinder trait might actually work/is preferable to trying to use grails.web.databinding.GrailsWebDataBinder in place of the original org.codehaus.groovy.grails.web.binding.GrailsDataBinder?

I am not saying that because I don't know what the plugin is doing with the binder in whatever context you are referring. It is a possibility though. Another is that instead of using the trait directly, it might make sense to do what the trait is doing.

dtamm commented 8 years ago

@lifeweaver any news on progress or do you need any help?

handicapskater commented 8 years ago

I will be starting on it this week or next, then will let you know if you can help and any significant progress.

lifeweaver commented 8 years ago

@dtamm I did get it to compile, although not all the tests are passing so that may mean nothing.

I've not looked at it for weeks since then.

dtamm commented 8 years ago

@lifeweaver is there a chance to get the source code of your project? I may test it (with actual code of my office project) and help out with the failing tests :)

lifeweaver commented 8 years ago

@dtamm sure, I don't have access to it until Monday but I'll fork the webflow plugin and upload the changes.

dtamm commented 8 years ago

@lifeweaver perfect, i wont have Access Till monday aswell, so its absolutley okay :) just tell me when its ready

lifeweaver commented 8 years ago

@dtamm it's as ready as it's ever going to be, I made a lot of guesses.

davidbairdala commented 8 years ago

+1 on getting this plugin upgraded to 3.1+

dtamm commented 8 years ago

i so far have downloaded the source of from liveweaver, but have not yet had success with compiling it... i think i might copy the files from the zip file into a fresh grails 3 project and then test it again. i will post an update till monday.

handicapskater commented 8 years ago

Glad to see y'all interested. I have time and am focusing on it now. I have to be able to do a complete security audit on it, so have downloaded the source and integrated it into a Grails 3 plugin project. I am down to 2 errors, where controller isFlowAction() is missing (exists in grails-core 2.4.4 and not 3.1.6) and GrailsControllerHandlerMapping is missing. I am using 3.1.6 to limit any known bugs from slowing me down.

handicapskater commented 8 years ago

I have the plugin compiling in Grails 3.0.10 and integrated in a test-app, while comparing functionality to a running test-app integrated with the original source plugin in Grails 2.4.3. I am getting an error and have not seen anything obvious yet, where I get this stack trace in Grails 3.0.10:

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:117) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:689) at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) at grails.boot.GrailsApp.run(GrailsApp.groovy:51) at grails.boot.GrailsApp.run(GrailsApp.groovy:335) at grails.boot.GrailsApp.run(GrailsApp.groovy:324) at grails.boot.GrailsApp$run.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133) at test.webflow.Application.main(Application.groovy:16)

osscontributor commented 8 years ago

If those of you who are working on this would like a channel in our grails.slack.com to use for communicating, we can definitely set that up.

handicapskater commented 8 years ago

@jeffbrown Yes please, Thanx.

osscontributor commented 8 years ago

I have created #grails3-webflow-dev there.

handicapskater commented 8 years ago

Thank you sir.

senseyoung commented 8 years ago

Can anyone briefly describe how to use webflow without the plugin?

dtamm commented 8 years ago

So, i have managed it to get the plugin compiling. it can also be integrated in an grails 3 application. i've set up an own repository for this, feel free to check it out and work on it: https://github.com/dtamm/grails3-webflow-plugin

BUT: till now i cant get it to work, i set up an example application and tried to reach one of the flows, then getting the following error:

    Line | Method
->> 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run . . . in java.lang.Thread

Caused by MissingMethodException: No signature of method: webflowapp.TestController.entrance() is applicable for argument types: (webflowapp.TestController$_orderFlow_closure1) values: [webflowapp.TestController$_orderFlow_closure1@2426a06e]
->>   92 | methodMissing in grails.artefact.gsp.TagLibraryInvoker$Trait$Helper
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|      6 | bestellungFlow in TestController.groovy
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run . . . in java.lang.Thread
leleFc commented 7 years ago

Hi guys, is there any update about it?

tyagiakhilesh commented 7 years ago

In case, someone is still looking out for this, I have put together a small POC to demonstrate that how to directly use Spring-Webflow in your grails 3 app. Hope this helps someone. Here is the project.

seaniefs commented 7 years ago

Just a quick note to say that I've taken dtamm's code and forked it to get a little bit further in that I can get a very, very simple flow controller working - no more than that.

Sadly, I don't have time at the moment to progress it any more than that...

Please see the project here

However, please note that it is very, very, very rough indeed (kludges/hacks galore :( ) - you have been warned...

Some of the hackage is due to the fact that GrailsControllerClass in 2.x did some work which is no longer there in 3.x. That is mostly around identifying flow closures in Controllers and also detecting when an incoming URI matches a flow.

Being new to grails 3 I'm sure there's much more elegant ways of doing a lot of this...!

dtamm commented 7 years ago

@seaniefs nice, thanks for the work. i cant get it working though :( anything i need to have in mind for running the plugin in a grails 3 app?

seaniefs commented 7 years ago

Doesn't entirely surprise me - it is just at a "works for me" stage, and even then in a very limited set of circumstances.

Please note that at the moment you need to specify the controller and flow in the url - I.E. If you have a controller one with flow two, you need to use:

http://localhost:8080/one/two

If that's not the issue, then I'll try to upload my test flow to github in the coming days.

dtamm commented 7 years ago

@seaniefs oh yes please Upload your Sample app, i will Take a Look Info the whole Code at work tomorrow :)