Wednesday, February 13, 2013

Grails Quartz tables are not found on new database

I ran an existing Grails project on a new database and encountered the below error:

ERROR context.GrailsContextLoader  -

Error executing bootstraps:
Error creating bean with name 'quartzScheduler':
Invocation of init method failed; nested exception is org.quartz.SchedulerConfigException:

Failure occured during job recovery.
[See nested exception: org.quartz.impl.jdbcjobstore.LockException: Failure obtaining db row lock: Table 'schema.qrtz_locks' doesn't exist
[See nested exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'schema.qrtz_locks' doesn't exist]]

A Jira has already been raised for this issue [1].

The underlying reason is that Grails does not handle the order of plugin execution.  One particular resolution is to use the database-migration plugin [2].  A tutorial can be found here [3].  If the plugin is installed and you have created a schema, you can use the dbm-update command [4].

After you migrate the tables over with no data, upon running the application you will be encountered the below error:


ERROR context.GrailsContextLoader  -
Error executing bootstraps:
Error creating bean with name 'quartzScheduler':
Invocation of init method failed; nested exception is org.quartz.SchedulerConfigException: Failure occured during job recovery.
[See nested exception: org.quartz.impl.jdbcjobstore.LockException:
Failure obtaining db row lock: No row exists in table QRTZ_LOCKS for lock named: TRIGGER_ACCESS
[See nested exception: java.sql.SQLException: No row exists in table QRTZ_LOCKS for lock named: TRIGGER_ACCESS]]

To solve that problem, you need to insert the following rows into the qrtz_locks table:
INSERT INTO qrtz_locks values('TRIGGER_ACCESS'); INSERT INTO qrtz_locks values('JOB_ACCESS'); INSERT INTO qrtz_locks values('CALENDAR_ACCESS'); INSERT INTO qrtz_locks values('STATE_ACCESS'); INSERT INTO qrtz_locks values('MISFIRE_ACCESS');



[1] http://jira.grails.org/browse/GPDATABASEMIGRATION-58?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
[2] http://grails.org/plugin/database-migration
[3] http://wpgreenway.com/posts/grails-db-migration-tutorial/
[4] http://grails-plugins.github.com/grails-database-migration/docs/manual/ref/Update%20Scripts/dbm-update.html

Saturday, February 9, 2013

Find email by attachment type in Gmail

Recently, I needed to find a spreadsheet in Gmail from one particular person who I had 100s of emails with.  The advanced search allows you to filter emails that have attachment but that is it.  Fortunately, Gmail has different search keywords that the advanced filter GUI does not have listed.  To find a spreadsheet in gmail from bob@gmail.com you would search for:
filename:xls from:bob@gmail.com
Gmail has a listing of other helpful advanced search techniques found here http://support.google.com/mail/bin/answer.py?hl=en&answer=7190

Tuesday, January 15, 2013

Allowing remote users on MySQL

Recently I needed to add a user account that could access a MySQL database remotely. Listed below are the steps to create a user named bob who only has read only access.

Create the user account for bob if it doesn't already exist:
create user bob; 
Set the password test123* to bob's account:
set password for bob = password('test123*');
Grant privileges to bob to run the select statement from his home computer with the IP 210.22.2.123 for all tables on the schedule database:
grant select on schedule.* for 'bob'@'210.22.2.123' with grant option; 
The with grant option is required for remote access. This item tripped me up for several minutes.

Additionally, the mysqldump command issues the lock table command which is not granted with the above command.  Lock tables prevents rows from inserted or altered.  The --lock-tables=false flag prevents the lock tables command from being issue.

For further documentation check out the MySQL documentation on user accounts at http://dev.mysql.com/doc/refman/5.5/en//adding-users.html

Saturday, July 9, 2011

php script that generates a EXT JS grid for each table in a mysql database

I put together a script that generates a EXT JS grid for each table within a mysql database. A html, js and php file are created for each table.

It is barebones, but feel free to use as your own or push changes to github.

https://github.com/jonaldomo/php-ext_js-grid_creator/blob/master/php-ext_js-grid-creator.php

Instructions to use:
1. Assumes a web server is setup with PHP installed with network access to the mysql database.
2. Download and extract ExtJS 4 library from www.sencha.com
3. Download php-ext_js-grid-creator.php to web root on the webserver.
4. Edit lines 16-19 in the script with the mysql host, username, password and schema.
5. Edit lines 25-27 with the directory where ExtJS is housed in relation to the script. 26 is the SDK JS file and line 27 is the location of the CSS file.
6. Open a web browser and load the script in the address bar. Example: http://localhost/php-ext_js-grid-creator.php and load. Within seconds html, php and js will be generated. The grid will be viewable from the .html files.

Tuesday, June 21, 2011

first commit of perl-command-line-rss

perl-command-line-rss is a perl script that you run from the command prompt (I started it for use in Windows, will add Unix functionality later). Once the list of feeds is pulled back, you can select an article and view it using Lynx.

It is hosted over at GitHub, you can view it at https://github.com/jonaldomo/perl-command-line-rss

md5sum fciv for windows

Windows used to come with fciv.exe which is a File Checksum Integrity Verifier utility. More information is over at the Wikipedia entry md5sum.

The file itself is available from Microsoft Support. Usage is on the same page as the download.

In short it gives the user the opportunity to confirm that the file you are downloading is legit and has not been tampered with.

Monday, June 20, 2011

perl whois client

The below code snippet is a simple WHOIS client in Perl. I spent the majority of the time trying to find an easy syntax highlighter to use. I decided on https://gist.github.com It doesn't have line numbers, but it is only one line compared to SyntaxHighlighter or Google Code Prettify. Also Blogger doesn't allow LINK tags for external CSS.