Bug 965342

Summary: Alert updates; Hibernate lazy load exception for Numeric Type
Product: [Other] RHQ Project Reporter: Elias Ross <genman>
Component: AlertsAssignee: Heiko W. Rupp <hrupp>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.5CC: hrupp
Target Milestone: ---   
Target Release: RHQ 4.8   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-09-11 09:53:10 UTC 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:

Description Elias Ross 2013-05-21 00:56:32 UTC
2013-05-21 00:45:07,106 WARN  [org.rhq.enterprise.gui.coregui.server.gwt.AlertTemplateGWTServiceImpl] Sending exception to client: [1369097107106] 
org.rhq.enterprise.server.alert.AlertDefinitionUpdateException: Failed to update child AlertDefinitions [15555, 15556, 15557, 15558, 15559, 15560, 15561, 1556
2, 15563, 15564, 15565, 15566, 15567, 15568, 15569, 15570, 15571, 15572]; 
        at org.rhq.enterprise.server.alert.AlertTemplateManagerBean.updateAlertTemplate(AlertTemplateManagerBean.java:307)

...

Caused by: org.hibernate.LazyInitializationException: could not initialize proxy - no Session
        at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:57)
        at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
        at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:166)
        at org.rhq.core.domain.measurement.MeasurementDefinition_$$_javassist_36.getNumericType(MeasurementDefinition_$$_javassist_36.java)

The bug is probably fixed with this:

diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/m
index 0b3ff87..84c9872 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
@@ -650,9 +650,9 @@ private void checkAlertDefinition(Subject subject, AlertDefinition persistedAler
             if (alertConditionCategory == AlertConditionCategory.BASELINE) {
 
                 MeasurementDefinition def = alertCondition.getMeasurementDefinition();
+                def = entityManager.getReference(MeasurementDefinition.class, def.getId());
                 NumericType numType = def.getNumericType();
                 if (numType == null) {
-                    def = entityManager.getReference(MeasurementDefinition.class, def.getId());
                     numType = def.getNumericType();
                 }
                 if (numType != NumericType.DYNAMIC) {

Comment 1 Heiko W. Rupp 2013-06-18 15:21:05 UTC
To reproduce:

create an alert template with a Baseline.
save it.
Then edit the template and edit the baseline condition. Save.

Comment 2 Heiko W. Rupp 2013-06-18 15:36:33 UTC
master 26b1b5e27

Comment 3 Heiko W. Rupp 2013-09-11 09:53:10 UTC
Bulk closing of old issues now that HRQ 4.9 is in front of the door.

If you think the issue has not been solved, then please open a new bug and mention this one in the description.