Bug 1293352

Summary: Data Calc Job fails to complete when RHQ Server is set to DEBUG mode
Product: [Other] RHQ Project Reporter: bkramer <bkramer>
Component: Core ServerAssignee: Nobody <nobody>
Status: NEW --- QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.12CC: hrupp
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1293350    

Description bkramer 2015-12-21 14:11:09 UTC
Description of problem:

Every hour, when RHQ server is set in DEBUG mode, the following is logged in the server.log file:
*************************************************************
18:00:08,613 ERROR [org.jboss.as.ejb3.invocation] (RHQScheduler_Worker-1) JBAS014134: EJB Invocation failed on component MeasurementOOBManagerBean for method public abstract void org.rhq.enterprise.server.measurement.MeasurementOOBManagerLocal.computeOOBsForLastHour(org.rhq.core.domain.auth.Subject,java.lang.Iterable): javax.ejb.EJBException: java.lang.RuntimeException: javax.ejb.EJBException: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
...
	at org.rhq.enterprise.server.measurement.MeasurementOOBManagerLocal$$$view160.computeOOBsForLastHour(Unknown Source) [rhq-server.jar:4.12.0.JON330GA-redhat-4]
	at org.rhq.enterprise.server.scheduler.jobs.DataCalcJob.calculateOOBs(DataCalcJob.java:150) [rhq-server.jar:4.12.0.JON330GA-redhat-4]
	at org.rhq.enterprise.server.scheduler.jobs.DataCalcJob.executeJobCode(DataCalcJob.java:85) [rhq-server.jar:4.12.0.JON330GA-redhat-4]
	at org.rhq.enterprise.server.scheduler.jobs.AbstractStatefulJob.execute(AbstractStatefulJob.java:48) [rhq-server.jar:4.12.0.JON330GA-redhat-4]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz-1.6.5.jar:1.6.5]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525) [quartz-1.6.5.jar:1.6.5]
Caused by: java.lang.RuntimeException: javax.ejb.EJBException: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
	at org.rhq.enterprise.server.measurement.MeasurementOOBManagerBean.computeOOBsForLastHour(MeasurementOOBManagerBean.java:253) [rhq-server.jar:4.12.0.JON330GA-redhat-4]
...
	... 29 more
Caused by: javax.ejb.EJBException: org.hibernate.LazyInitializationException: could not initialize proxy - no Session

...

18:00:08,621 ERROR [org.rhq.enterprise.server.scheduler.jobs.DataCalcJob] (RHQScheduler_Worker-1) Data Calc Job FAILED TO COMPLETE. Cause: javax.ejb.EJBException: java.lang.RuntimeException: javax.ejb.EJBException: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
18:00:08,621 INFO  [org.rhq.enterprise.server.scheduler.jobs.DataCalcJob] (RHQScheduler_Worker-1) Data Calc Job FINISHED [8591]ms
*************************************************************


Version-Release number of selected component (if applicable):
RHQ 4.12

How reproducible:
Always

Steps to Reproduce:
1. Set RHQ Server into DEBUG mode
2.
3.

Actual results:
Data Calc Job fails to complete with message "could not initialize proxy - no Session"

Expected results:
Data Calc Job finishes with success and no error message is logged.

Additional info:

Jay Shaughnessy already had a look and here is his comment:
***********************************************************
It's a failure of the DataCalcJob which, as you probably know, is a scheduled job that runs to generate baselines and OOBs and stuff like that.  Having said that, this is not a good failure.  I did some research and it looks to me like this is found in both of the logs because both logs were likely performing debug logging.  The exception is actually generated in a debug logging statement (ugh).

I've fixed this issue in the master branch, I would suggest we cherry-pick this to the 3.3.x branch as well, it will benefit future 3.x releases.

Master commit 772b6cdb80f20a9e6e3a7552f2ea185a352c8218
 Author: Jay Shaughnessy <jshaughn>
 Date:   Fri Dec 18 10:19:41 2015 -0500
 
     Never use a lazy loaded variable in toString() impl. This blew up in
     DEBUG mode if the MeasurementBaseline was not a managed entity.
***********************************************************