AST Browser in Intellij - grails

Is there anyway I can open the AST Browser in Intellij for a Grails project? I am trying to figure out the compilation phases for various gorm objects and services.

I know it's not using the AST Browser in Intellij but the AST browser that comes with the Groovy console is quite handy.
Using the console command from your Grails application will launch the console with your Grails application fully setup and running. Within the console you can access all of your Grails application and the AST browser.
ctx within the console gives you a quick handle to the main application context so you can get a reference to any service/bean within your application. GORM and everything else is also available too.

Related

Configure Flogger with log4j2 backend

I try to use flogger with the log4j2 backend. Seems to work fine.
My problem is, how to configure output pattern, output level or appenders in general using log4j files (xml or properties).
If using this constellation without any configuration, only level error is logged.
OK, I missed to add log4j-web package, so everything was fine in a standalone app, but this package is needed in a web application

Grails application doesn't automatically start in browser with grails run-app

For some reason my grails application no longer starts a browser with the webpage displayed when doing a grails run-app. It always did before. There is no errors or anything, it just no longer auto-starts the application. I haven't changed any code unless git corrupted something. Anyone know what could cause this?
Grails does not start a browser - usually your IDE takes care of this.
On IntelliJ you can enable this behaviour (Launch Browser) under your Run Configuration.
Click on Edit Configurations… here
Enable Launch Browser

Order of Grails Bootstrap classes

On one of our feature branches of our project we have a strange issue with running our grails integration tests. In our application we have the base project and one plugin, which relies on data from the base application. The default data is created in the "Bootstrap" Classes of the project and the plugin.
since yesterday the bootstrap of the plugin is called before the base bootstrap, and fails, because of the missing data from the application. This happens only if we run the integration tests, and only on our buildserver (Windows Server 2012 with Atlassian Bamboo).
test-app -integration --stacktrace -non-interactive
how can we fix this problem?
Grails makes no guarantees about ordering of BootStrap classes so it isn't something that should be relied about in your application.
If you need to control ordering of logic that is run at startup there are better solutions, for example you could use the platform-core plugin's event model to trigger an event in your application that your plugin listens to once the data it needs is in place. See http://grails-plugins.github.io/grails-platform-core/guide/events.html

Which is the starting point of grails framework while executing.?

First I'm new to grails as well website development.I started grails project and studying.
I'm clear about grails concepts like Domain class, controller, view, agile development like this.
While executing grails run-app command, at which point does grails start execution in the framework and run (like main() method in Java)?
Which is the first entry place domain or controller or view or main.gsp in my project from where it is coming from grails framework?
When server starts up, Bootstrap.groovy is executed.
For listening to each request you probably would need to define your own filter.
However the very beginning of every request is the org.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet.
When a request comes in, grails determines the controller and the action (based on the URL and any UrlMappings you've specified) and calls it. So from your application code's point of view, the starting point is one of your actions.
For example:
If a user requests http://abc.com/book/list, where abc.com is your site, the method def list() in your BookController.groovy is the starting point.
Internally, grails calls each closure in AppFilters.groovy (and other filters defined by you or the plugins you are using) if any before calling your controller's action. If you are developing a very simple app, those wouldn't matter.
Grails incorporates the powerful build system Gant, which is a Groovy wrapper around Apache Ant.
When you run the command : Grails [commad-name],
Grails searches in the following directories for Gant scripts to execute:
USER_HOME/.grails/scripts
PROJECT_HOME/src/main/scripts/
PROJECT_HOME/plugins/*/scripts
GRAILS_HOME/scripts
When you execute Grails run-app command, It will execute the file RunApp.groovy file from above mentioned paths. These are groovy files, once you look into files, you will understand the code inside that.

Grails - Plugin view pages issue

I have a plugin with domain, controller and view pages. (Using grails 1.3.6)
I run the plugin as standalone, the views work fine. URL: http://localhost:8080/sample-plugin/gp/list. I am able to view the list page.
I installed the plugin into a main application i.e. plugin-test. Start as run-app within STS and browse to http://localhost:8080/plugin-test/gp/list. I am able to view the list page.
I bundle the application as war i.e. plugin-test.war and deploy to tomcat. When I browse to http://localhost:8181/plugin-test/gp/list I get a 404 error! I am not sure what I am doing wrong.
I have been trying to resolve it for quite sometime now and still no luck. The same main application works fine in STS but not in tomcat.
HTTP Status 404 - /plugin-test/WEB-INF/grails-app/views/gp/list.jsp
type Status report
message /plugin-test/WEB-INF/grails-app/views/gp/list.jsp
description The requested resource (/plugin-test/WEB-INF/grails-app/views/gp/list.jsp) is not available.
Please help.
Thank you.
Jay Chandran.
This sounds worryingly familiar, as I spent a while figuring out this (or a very similar) issue. I ended up raising this Grails bug report:
Plugin layout not found in war when installed from BuildConfig.groovy
Have you installed the plugin as using the new BuidConfig dependency technique? The JIRA documents my workaround.
Sharing some of my lessons learned after experiencing the same exact issue (1.3.7):
Double check your HTML source to make sure that your template really isn't being included. Mine was being included, but my CSS/image URLs were wrong (only while running as a war)...so I wrongly assumed that my template wasn't there.
Don't use the ui performance tags for referencing your static content...doesn't appear to work, even if the plugin attribute is specified.
Don't name your layout main.gsp. You're guaranteed to have conflicts.
Don't use absolute=true on your g:resource tags. This doesn't appear to append the pluginContextPath to the absolute url, even if you specify dir="${pluginContextPath}"
Don't use pluginContextPath, as it's no longer required: http://grails.org/doc/latest/guide/single.html#6.3%20Tag%20Libraries (search "Plugin Paths")
In your g:resource tags in your plugin layout, make sure you specify the plugin attribute. Set it to the name of your plugin.
Move your static images/css from your plugin to a web server. If each application using your plugin has its own copy, your users aren't going to benefit from caching when bouncing between apps.
Note that all of the above applies to the layout gsp in your plugin project, not your consuming application.

Resources