grails-console icon indicating copy to clipboard operation
grails-console copied to clipboard

Its possible to use console plugin in a grails 3 rest-api profile?

Open ilmoralito opened this issue 9 years ago • 8 comments

I am trying to use console plugin in a grails 3 rest-api profile. When i try http://localhost:8080/console i get the following error in the console

ERROR org.grails.web.errors.GrailsExceptionResolver - MissingMethodException occurred when processing request: [GET] /console
No signature of method: org.grails.plugins.console.ConsoleController.createLink() is applicable for argument types: (java.util.LinkedHashMap) values: [[action:index, absolute:true]]. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: groovy.lang.MissingMethodException: No signature of method: org.grails.plugins.console.ConsoleController.createLink() is applicable for argument types: (java.util.LinkedHashMap) values: [[action:index, absolute:true]]
    at grails.artefact.gsp.TagLibraryInvoker$Trait$Helper.methodMissing(TagLibraryInvoker.groovy:92)
    ... 3 common frames omitted

I am using grails 3.1.8 and grails-console 2.0.6

I tried the plug in with a grails 3 web profile and it is working as excepted

ilmoralito avatar Jun 27 '16 20:06 ilmoralito

This is because there's no view layer in the rest-api profile. It would be possible to create a version of the plugin that only includes the server-side components and you're on your own for the UI. I tried this in a Spring Boot app using Sublime for the UI with a little plugin to POST the contents to the server and show the results in a separate pane. The Sublime side mostly worked, but Groovy and Java 8 syntax don't get along, so it kind of didn't.

Here's the start of the Sublime side in case anyone wanted to pick this up and run with it: https://gist.github.com/davidkuster/634f286d24d7654b7232934ea3911262

davidkuster avatar Jun 27 '16 23:06 davidkuster

Thanks for the information. A sublime plug in sound amazing.

ilmoralito avatar Jun 30 '16 22:06 ilmoralito

I just hit this today, I tried to use httpie to directly hit /console/execute, but some problems with CSRF tokens appeared, anyway I worked around the problem this way: I created my own controller method that uses consoleService from this plugin and returns stuff from Evaluation object in some JSON form. Works for me perfectly.

AleksanderGrzybowski avatar Oct 20 '16 19:10 AleksanderGrzybowski

fyi - you can disable the CSRF protection with grails.plugin.console.csrfProtection.enabled = false

sheehan avatar Oct 20 '16 19:10 sheehan

Wow, I've spent half an hour looking all around grails docs for this! Should have looked here first. Thanks, will try it.

AleksanderGrzybowski avatar Oct 20 '16 19:10 AleksanderGrzybowski

Hi all,

Not sure if I understand your question correctly. I have added this line to enable gsp support and the console is running smoothly under rest-api profile.

``compile 'org.grails:grails-plugin-gsp'

sctse999 avatar Apr 12 '17 02:04 sctse999

In Grails 3.3.8 with console 2.1.1:

Add apply plugin:"org.grails.grails-gsp" to build.gradle

and in dependencies block: compile "org.grails.plugins:gsp"

aretche avatar Nov 21 '18 14:11 aretche

For a Grails 5.0.1 app with rest-api profile you need to edit your build.gradle (following @aretche answer to Grails 3.3.8 https://github.com/sheehan/grails-console/issues/53#issuecomment-440691934):

apply plugin:"org.grails.grails-gsp"

dependencies block:

implementation "org.grails.plugins:gsp" implementation 'org.grails.plugins:grails-console:2.1.1'

luizcantoni avatar Nov 11 '21 01:11 luizcantoni