Friday, June 11, 2010

[javac] Warning: MyClass.java modified in the future.

Uploaded my code to a server in a different timezone(I am UTC+xx. The server's UTX-yy).
So the file modification dates of my source files were later than the current time on the servers. (The server might be thinking these files came through a time machine from future)

What worked for me:
Used the linux "touch" command to set the source file modification dates to current time on server. Don't know the windows equivalent.

Thank you.

Custom Grails environment: Running Grails application in custom environment

grails -Dgrails.env= run-app

http://www.pubbs.net/201005/grails/7053-grails-user-unable-to-run-app-in-custom-environment.html

No Hibernate Session bound to thread: in a Grails artifact that's supposed to be having an injected session.

org.quartz.SchedulerException: JobListener 'sessionBinderListener' threw exception: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here [See nested exception:
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here]
    at org.quartz.core.QuartzScheduler.notifyJobListenersWasExecuted(QuartzScheduler.java:1912)
    at org.quartz.core.JobRunShell.notifyJobListenersComplete(JobRunShell.java:355)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:226)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)

Occurred in a Grails application with Quartz-plugin-0.4.1 installed. It was running a cron job. This exception occurred after the last line of code in the Job class executed successfully. It looks like there was a job completion notification that led to a session.flush() call in one of the hibernate classes, where it failed to retrieve the session.

Solution that worked for me:
Upgraded Quartz-plugin to version 0.4.2


Thank you.

Monday, May 24, 2010

Grails war default dependencies list location

http://jira.codehaus.org/browse/GRAILS-5971: says
3. Grails dependencies are no longer in War.groovy ("DEFAULT_DEPS" and "DEFAULT_J5_DEPS" variables). Look at
GRAILS_HOME/src/java/org/codehaus/groovy/grails/resolve/IvyDependencyManager.groovy, getDefaultDependencies(String grailsVersion).

Eclipse build problem: The type java.lang.Object cannot be resolved. It is indirectly referenced from the required .class files

http://forums.sun.com/thread.jspa?threadID=688073: says


 nepaliSun
Posts:1
Registered: 1/7/06
Re: The type java.lang.Object cannot be resolved   
Jan 7, 2006 3:38 PM (reply 6 of 34)  (In reply to original post ) 
Click to email this message


 
In Eclipse, the cause of this problem is that You somehow deleted the SYSTEM JRE LIBRARY associated with your project.

Simple fix in Eclipse:
-Right Click Project you are working on from Package Explorer
-Go to Properties
-Go to Java Build Path from the right tree structure
-Go to Libraries Tab
-Choose Add Library Button
-Select JRE System Library
-Hit Next, the Radio button will prompt the Workspace default JRE, and let it be that way
-Hit Finish

Things should work now
Cheers,
-Ram S. Khanal


It worked for me.

Sunday, May 16, 2010

TortoiseGit with Pageant - unable to open file

What I did:
Using TortoiseGit and MsysGit
Created key pair using puttygen.
Set the public key in my unfuddle account. (My code is in a git repository on unfuddle)
Loaded the private key into Pageant.
Tried to clone the git repository. It says "unable to open file"

What worked for me:
Checked the TortoiseGit Settings- Network tab.
SSH client is set to ssh.exe. Changed it to pageant. Still doesn't work.
Left it BLANK. It worked.
Ref: http://dev-heaven.net/boards/22/topics/show/356

Tuesday, May 4, 2010

Hibernate exception in Grails-1.2.1 when working with services and quartz cron jobs

Happens when we instantiate a service using new operator.

grails ERROR [PatchedDefaultFlushEventListener][] Could not synchronize database state with sessionorg.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

http://jira.codehaus.org/browse/GRAILSPLUGINS-1776?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel#issue-tabs : syas that it happens when making changes to unsaved domain object in a background thread

http://jira.codehaus.org/browse/GRAILSPLUGINS-1807
http://jira.codehaus.org/browse/GRAILSPLUGINS-1808? page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel#issue-tabs

What worked for me:
Within the service' method being called inject hibernate SessionFactory as follows

http://stackoverflow.com/questions/1898684/in-grails-how-do-i-access-the-hibernate-session-inside-of-a-domain-class-static-m

import org.codehaus.groovy.grails.commons.ApplicationHolder as AH
class BlahService{
 blahMethod(){
  def ctx = AH.application.mainContext
  def sessionFactory = ctx.sessionFactory
  def session = sessionFactory.currentSession

  blah blah blah code containing GORM usage

  session.flush()
  session.clear() //optional
 }
}