Monday, October 13, 2014

Linux Command-SCP,example

Linux Command-SCP example

upload local file to remote server
scp -P 2222 /home/a5go.com.tar.gz root@a5go:/root/a5go.com.tar.gz


upload local folder to remote server
scp -P 2222 -r /home/a5go.com/ root@a5go:/root/a5go.com/


get remote server file to local
scp -P 2222 root@a5go:/root/a5go.com.tar.gz /home/a5go.com.tar.gz


get remote server folder to local
scp -P 2222 -r root@a5go:/root/a5go.com/ /home/a5go.com/



Linux Command-SCP,example

Monday, October 6, 2014

Grails Goodness Notebook

The Grails Goodness Notebook contains the blog posts about Grails. The posts are bundled and categorized into sections. Each section starts with the simpler features and ends with more advanced Grails features. The book is intended to browse through the subjects. You should be able to just open the book at a random page and learn more about Grails. Maybe pick it up once in a while and learn a bit more about known and lesser known features of Grails.


The book categorizes the posts in the following sections:


Configuration

The Command LIne

Grails Object Relational Mapping (GORM)

Validation

Controllers

Groovy Server Pages (GSP)

REST

The Service Layer

Grails and Spring

Internationalization (i18n)

IDE


Grails Goodness Notebook is updated with the following posts:

Using Bintray JCenter as Repository

Use Spring Java Configuration

Conditonally Load Beans in Java Configuration Based on Grails Environment

Using Converter Named Configurations with Default Renderers

Custom Controller Class with Resource Annotation

Change Response Formats in RestfulController

Enable Accept Header for User Agent Requests

Exception Methods in Controllers

Run Groovy Scripts in Grails Context

Using Aliases as Command Shortcuts

Generate Default .gitignore Or .hgignore File

Extending IntegrateWith Command


Visit Grails Goodness Notebook!



Grails Goodness Notebook

Saturday, October 4, 2014

Grails,How to use enum

Grails,How to use enum


Example:

Groovy Code


package com.test

public enum MessageStatus
PENDING(0),SUCCESS(1),FALSE(2)

private final Integer value

MessageStatus(Integer value)
this.value = value


Integer getId()
value


Grails Domain call this groovy method


import com.test.MessageStatus

class MessageDetails
MessageStatus status


Grails,How to use enum

Friday, October 3, 2014

Grails mail config

1. add plugin

runtime “:mail:1.0.7″

runtime “:email-confirmation:1.0.5″

2.Edit Config.groovy

gmail

grails 
 mail 
 host = "smtp.gmail.com" 
 port = 587 
 username = "a5go.com@gmail.com" 
 password = "password" 
 props = ["mail.debug": "true", 
 "mail.smtp.protocol": "smtps", 
 "mail.smtp.auth": "true", 
 "mail.smtp.starttls.enable": "true", 
 "mail.smtp.host": "smtp.gmail.com", 
 "mail.smtp.user": "a5go.com@gmail.com", 
 "mail.smtp.password": "password"] 
 

hotmail

grails 
 mail 
 host = "smtp.live.com"
 port = 587
 username = "a5go.com@live.com"
 password = "password"
 props = ["mail.smtp.starttls.enable":"true",
 "mail.smtp.port":"587"]
 


Grails mail config

Wednesday, October 1, 2014

issue:[Fatal Error] :55983:45: XML document structures must start and end within the same entity.

issue:[Fatal Error] :55983:45: XML document structures must start and end within the same entity.

status:pending


Sometimes, when running my application in development mode, I receive the following error:


Configuring Shiro ...

Configuring Shiro ...


Shiro Configured

Shiro Configured

| Server running. Browse to http://localhost:8080/bank

[Fatal Error] :55983:45: XML document structures must start and end within the same entity.


The application seems to run ok, What does this error mean?

I am running grails 2.3.7 in a JDK6,WIN7 environment.



issue:[Fatal Error] :55983:45: XML document structures must start and end within the same entity.

Getting Started with Grails and MySQL

Getting Started with Grails and MySQL

1. Create a database in MySQL.


mysql> CREATE DATABASE bank_dev;
mysql> CREATE DATABASE bank_test;
mysql> CREATE DATABASE bank_prod;

2.Add the MySQL driver to project.

Download the jar file(i am using mysql-connector-java-5.0.4-bin.jar) and put it in your $project/lib directory


3.change DataSource.groovy

The complete code should look like this


dataSource 
// pooled = true
// jmxExport = true
// driverClassName = "org.h2.Driver"
// username = "sa"
// password = ""
pooled = true
jmxExport = true
driverClassName = "com.mysql.jdbc.Driver"
username = "root"
password = ""
dialect = org.hibernate.dialect.MySQL5InnoDBDialect

hibernate
cache.use_second_level_cache = true
cache.use_query_cache = false
cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
// cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode


// environment specific settings
environments
development
dataSource
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
// url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
url = "jdbc:mysql://localhost:3306/ncbank_dev?useUnicode=true&characterEncoding=UTF-8"


test
dataSource
dbCreate = "update"
// url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
url = "jdbc:mysql://localhost:3306/ncbank_test?useUnicode=true&characterEncoding=UTF-8"


production
dataSource
dbCreate = "update"
// url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
url = "jdbc:mysql://localhost:3306/ncbank_prod?useUnicode=true&characterEncoding=UTF-8"
properties
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED





Getting Started with Grails and MySQL

Error Error executing script ShiroQuickStart: groovy.lang.MissingMethodException: No signature of method

Error Error executing script ShiroQuickStart: groovy.lang.MissingMethodException: No signature of method


|Loading Grails 2.3.7
|Configuring classpath
> grails shiro-quick-start --prefix=com.test.
.
|Environment set to development
................................
|Packaging Grails application
.
|Uninstalled plugin [spring-security-core]
..
|Compiling 10 source files

..
|Compiling 578 source files
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
.......
|Compiling 12 source files
...............................................................................................
Configuring Shiro ...

Shiro Configured
Error |
Error executing script Shell: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'uk.co.desirableobjects.oauth.scribe.OauthController': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'oauthService': Invocation of init method failed; nested exception is java.lang.IllegalStateException: No oauth configuration found. Please configure the oauth scribe plugin (Use --stacktrace to see the full trace)

Process finished with exit code 1

How to fix it:


grails shiro-quick-start "--prefix=com.test" --stacktrace

or


grails shiro-quick-start


Error Error executing script ShiroQuickStart: groovy.lang.MissingMethodException: No signature of method