Thursday, June 23, 2016

Tomcat log4j

logging.properties is configuration for java.util.logging. The java.util.logging API is still available, for those web applications that use it directly. The${catalina.base}/conf/logging.properties file is still referenced by Tomcat startup scripts.

  1. Globally  ${catalina.base}/conf/logging.properties.  
    adds several FileHandlers that write to files
  2. If 1) is not readable, fall back to the fault in JRE ${java.home}/lib/logging.properties file in the JRE. specifies a ConsoleHandler that routes logging to System.err. 
  3. In the web application. The file will be WEB-INF/classes/logging.properties

log4j.properties is for log4j.  $CATALINA_BASE/lib/log4j.properties

  • If log4j.jar exisit under catalina.base/lib, means using log4j. This exposes log4j libraries to the web applications through the Common classloader. Because of that, the web applications and libraries using Apache Commons Logging library are likely to automatically choose log4j as the underlying logging implementation.
  • Your web applications should certainly use their own log4j configuration. This is valid with the above configuration. You would place a similar log4j.properties file in your web application's WEB-INF/classes directory


Friday, June 17, 2016

Reset Git to a commit

1) set local to a certain commit
git reset --hard 3a10bf5

2) push to remote develop branch.
git push -f origin develop

Wednesday, December 9, 2015

Debug grails in Eclipse

You can start a Grails app (one that has an Eclipse Grails nature, i.e. it was created in STS or was converted via Configure | Convert to Grails Project) in STS in debug mode using Run | Debug As | Grails Command (run-app)
You can also attach to any app that you start from the commandline via "grails-debug run-app" by creating a Debug Configuration. Go to Run | Debug Configurations and select Remote Java Application. Click the 'New' button or right-click the Remote Java Application node and select New. Select the project that you're debugging and give the configuration a meaningful name (I usually call them "attach "). Change the port from 8000 to 5005, and I always check the "Allow termination of remote VM" checkbox so I can kill the app from the IDE, but that's optional. Click Debug and it'll attach. Note that this will work for any Grails project that's in your workspace, not just ones that have a Grails nature.

Thursday, October 8, 2015

Grails Codenarc Cobertura GMetrics Plugin

grails codenarc

report(s) generated: [target/test-reports/CodeNarc-Report.xml, target/test-reports/CodeNarc-Report.html]


grails gmetics


generate target/GMetrcsReport.html


Grails Code coverage plugin

This plugin will generate code coverage report using cobertura, in target/test-reports/cobertura

Dependency: 
test ":code-coverage:2.0.3-3

To run:

grails test-app -coverage

By default, the script will create HTML reports and place them in the tests/report/cobertura directory. If you would prefer XML reports (e.g for a Continuous Integration server), specify the -xml flag like this:
grails test-app -coverage -xml


Monday, July 6, 2015

Works with grails project in IntelliJ



  1. Setup MongoDB

    1. download MongoDB (64bit 2008R2)
    2. Install MongoDB, run the msi
    3. Create data folder for Mongodb c:/mongodb/data
    4. Run Mongo: mongod.exe --dbpath c:/mongodb/data
    5. Download RoboMongo http://robomongo.org/
    6. Connect to localhost:27017
  2. Import into IntelliJ
    1. git checkout iat projectc:\develop\iat
    2. cd c:\develop\iat\src
    3. Run  this to generate .idea project file.
    4. grails integrate-with --intellij
    5. Launch IDEA, select open project, select src project from c:\develop\iat\src folder.
    6. Configure Platform JDK: File->Project Settings->SDKs
    7. Configure Project JDK: File->Project Structure->Project Settings->Project
    8. Set Grails SDK: Tools->Grails->Change SDK version
    9. Run the application: Run-> Run 'Grails:src'

IntelliJ Tips
  • Switch to grails view: View->Tool Windows->Grails View
  • Enable: View->Tool Button to quickly switch to Grails View
  • Configure Platform JDK: File->Project Settings->SDKs
  • Configure Project JDK: File->Project Structure->Project Settings->Project
  • Change Project name: File->Project Structure->Project Settings->Project
  • Set Groovy SDK: Right click project -> Add Frameworks Support -> Check Groovy -> Create
  • Set Grails SDK: Tools->Grails->Change SDK version
  • Grails ships with the version of Groovy that it works with. lib/org.codehaus.groovy/groovy-all/jars/groovy-all-xxx.jar
  • To run any grails command: Tools->Grails->Run target, Type in Command.

Hotkey:

  • Find text:                                          Ctrl-H
  • Call hierarchy:                                 Ctrl-Alt-H

Remote debug Grails App

Setup


  • Cygwin .bashrc 

alias setDebug='export JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"'
setDebug
  • Windows 
set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
  • IntelliJ: run->edit configuration -> Default->remote , all default value, save.

Run


  • Cygwin: grails run-app
  • IntelliJ debug "localhost:5005"  (Alt-Shift-D)

Monday, April 28, 2014

Import Maven Projects from Github



  1. Checkout the source from github
    1. Switch to the Git Repository Exploring perspective in Eclipse.
    2. Click Clone a Git Repository and type the URI 
  2. Importing existing source into Eclipse
    1. Under the menu option File → Import, browse to the Maven→ Existing Maven Projects
    2. Enter the Root directory of the source tree and then select all the projects of interest:

    Monday, November 25, 2013

    Import Grails project from GitHub into Eclipse

    1. File -> Import -> Git -> Projects From Git > URI
    2. Enter the github repository URL. 
      You can get https URL from github repository page -> sidebar
    3. Select the branch you want to clone
    4. Select the local storage location for your new project
    5. Create a new groovy project. It will prompt you if you want to convert to grails project. Select yes.
      The location should be $ProjectRoot/src, the directroy that is the parent directory of grails-app!