Showing posts with label grails. Show all posts
Showing posts with label grails. Show all posts

Monday, August 28, 2023

Caused by java.io.IOException: CreateProcess error=206, The filename or extension is too long

While working on Java gradle project sometimes we might get the following error in Windows system: Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long This is due to when classpath for a Gradle JavaExec or Test task is long, Windows command executions give an error because of the limitation to command line length greater than 32K With a number of classpath...
Share:

Tuesday, August 16, 2022

Convert Date to Pretty Time in Grails and Groovy

In this tutorial, we will learn how to convert Java Date to pretty time like moments ago, 1 hour ago, 1 week ago, 1 month ago, 1 year ago, and so on in grails application. For this, we are using the prettytime plugin in our project. Load PrettyTime in Grails Gradle project: Add the following inside dependencies in the build.gradle file. dependencies { //other dependencies compile 'org.grails.plugins:grails-pretty-time:4.0.0' } PrettyTime...
Share:

Tuesday, July 26, 2022

Setup Http client for API using OkHttp in Java

In this tutorial, we will learn how to use OkHttp for HTTP requests while consuming APIs. OkHttp is an HTTP client which will do HTTP efficiently by loading faster and saving bandwidth. Using OkHttp is easy. Its request/response API is designed with fluent builders and immutability. It supports both synchronous blocking calls and async calls with callbacks. Setup the OkHttp dependency: If we are using...
Share:

Sunday, July 24, 2022

How to parse JSON string to Object and vice versa in Groovy Grails application

In this tutorial, we will learn how to parse or convert the object to JSON string and JSON string to object. Convert Object to JSON String: Let's look into the example, here we will parse the Map to JSON string. Map mapToConvert = [username : "Test", phonenumber : "+10656564"] List listToConvert = ["Test", "+10656564"] Now, let's convert to JSON string using JSON class import grails.converters.JSON ...
Share:

Thursday, July 7, 2022

How to use custom validation class in Grails Application

In this tutorial, we will learn how to add custom validation in the Grails application. Grails domain classes support the validation by default. So we can simply add the constrains for the domain classes fields as below class User { String username String password String email Integer age static constraints = { username blank: false, unique: true password...
Share:

Wednesday, July 6, 2022

How to enable CORS in Grails Application

In this tutorial, we are going to learn how to enable the cross-origin resources sharing CORS in a Grail Application. Introduction: Cross-origin resource sharing is the way to trust between the two web services or applications. So if the two web services don't satisfy then a CORS issue may arise. Cors is a mechanism for the web application that controls listening to certain request from other web...
Share:

Saturday, July 2, 2022

Error: Could not find or load main class org.grails.cli.GrailsCli

This is a quick tutorial on how we can resolve the issue on the Grails project. For grails application sometimes we might get the following error Error: Could not find or load main class org.grails.cli.GrailsCli This might be due to the removal of some dependencies or libraries from the application....
Share:

Wednesday, June 29, 2022

How to use SiftingAppender in Gradle Groovy project

 In this tutorial, we are going to set up the SiftingAppender in our Gradle Groovy project. Sifting Appender is useful when we want to separate the log files during runtime i.e if we want to separate the log files per thread or per user session basis. Unfortunately, in the Gradle Groovy project, SiftingAppender is no longer supported since version 1.0.12 as mentioned in Groovy Configuration. Let's...
Share:

Saturday, January 22, 2022

Grails 3 Download Saved Documnets/Files (.pdf, .txt, .docx and others) Example.

How to Download different types of files using Grails 3. If you want to use server-side file download for different types of files like pdf, txt, docx etc then there are different ways to do it. We can use ServletOutputStream object for it as below: def download(){ def filePath = "/opt/tomcat/webapps/savedFile/filename.pdf" //I am saving files on tomcat. def...
Share:

Securing Grails Application with Spring Security Rest | Rest API | Grails 3.x

How to Secure Grails Application with Spring Security Rest in Grails 3 Table of Contents - Introduction - Pre-requisites - Create Grails Application - Spring Security Core Plugin Configuration - Spring Security Rest Plugin Configuration - Testing Secured REST API Introduction: In this...
Share:

Friday, January 21, 2022

Splitting resources.groovy configuration in Grails applications

Splitting resources.groovy configuration in Grails applications Table Of Contents1. Introduction 2. How to split resources.groovy 3. Import external bean file 1. Introduction: In grails, when our resources.groovy file is growing then it is better to split some logical bean configuration with a separate file and import that file in resources.groovy.  For this, Grails provides a neat way to...
Share:

How to resolve grails-resolving-server-failed-to-start-for-port-8080-address-already-in-use

On Linux: step1: if your server port already running at port 8080 then, firstly we have to kill this process for this open your terminal and type lsof -w -n -i tcp:8080 which shows all the list of open file which is running at port 8080. if you type lsof -w -n -i tcp:9090 if your server is running with port 9090 which shows all the list of open file which are running at port 9090. Here, lsof...
Share:

Saturday, December 18, 2021

How to change Grails App server port in application.yml

This is a quick tutorial on how to set server port while running grails application. By default, grails will use the embedded tomcat server running on port 8080.Sometimes if another process is using port 8080 then we might get a port address already in use error.So, what we will do is to change the default port in the config. In grails 3.x version we can set up the custom port inside application.yml...
Share:

Sunday, November 21, 2021

Error occurred running Grails CLI: No profile found for name [web]. (Use --stacktrace to see the full trace)

In grails application, the error mentioned below might occur.  Error | Error occurred running Grails CLI: No profile found for name [web]. (Use --stacktrace to see the full trace) Process finished with exit code 1 This might be of different reason. Let's try to fix it by deleting the build folder under the application and re-run the application. This might work in most cases if this doesn't...
Share:

How to configure multiple database in Grails application

In this tutorial, we are going to learn how to configure multiple databases in the grails 3.x application. This is necessary when you are dealing with multiple databases from the same application especially when dealing with an existing remote database. We are using different MySql databases for testing.Let's create three MySql databases called db_default, db_one, db_two. Let's look into the application.yml...
Share:

Friday, January 1, 2021

How to use static content in app root directory in grails

In Grails latest version, it provides static assets management mechanism. You can use different files under the corresponding folders.All the images will go under the images directory, js files go under the javascripts directory and CSS goes under the stylesheets directory. These files will be accessed...
Share:

Tuesday, June 2, 2020

Hot reloading the resources file for changes in Grails.

How to hot reload the resources file when the changes happened in Grails. I was working on Grails 3.3.0 and hot reloading was not working while changing in the resources files. So, I found some workaround which is worth sharing here. There are the following steps to resolve the issue.Configure to watch the directory.Watch the directory for code changesReload spring resources configLoad from the...
Share:

Sunday, March 19, 2017

How to create facebook messenger bot part 2

Setup Welcome Screen For Greeting Text and Get Started Button  This will be the welcome screen for the new conversation. It will appear only for the first time. This will be similar like this. For this, we have to make the post request. I am using postman for the post request, you can simply...
Share:

Monday, March 6, 2017

How to create facebook messenger bot part 1

Facebook gives the large platform for the messenger. In this tutorial series, we are going to create our own facebook messenger bot.  Please refer facebook developer messenger platform here for the documentation. We are going to create simple messenger bot for shopping. (adsbygoogle...
Share: