Bug 667896 - Calculating Dynamic Group with more than one trait in Group Definition Condition causes Hibernate Exception
Summary: Calculating Dynamic Group with more than one trait in Group Definition Condit...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: RHQ Project
Classification: Other
Component: Core UI
Version: unspecified
Hardware: All
OS: All
high
high
Target Milestone: ---
: RHQ 4.5.0
Assignee: John Sanda
QA Contact: Mike Foley
URL:
Whiteboard:
: 835955 (view as bug list)
Depends On:
Blocks: 826716 837078
TreeView+ depends on / blocked
 
Reported: 2011-01-07 07:16 UTC by Myee Riri
Modified: 2013-09-01 10:03 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 826716 (view as bug list)
Environment:
Last Closed: 2013-09-01 10:03:08 UTC
Embargoed:


Attachments (Terms of Use)
log snippet (10.23 KB, application/octet-stream)
2011-01-07 07:16 UTC, Myee Riri
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 835955 0 unspecified CLOSED dynagroup definition cannot contain both plugin configuration and resource configuration expressions 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 837078 0 high CLOSED Calculating Dynamic Group with more than one trait in Group Definition fails with QueryParameterException: could not loc... 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 837113 0 unspecified NEW Localize dynagroup expression error messages 2022-03-31 04:27:31 UTC

Internal Links: 835955 837078 837113

Description Myee Riri 2011-01-07 07:16:49 UTC
Created attachment 472190 [details]
log snippet

Description of problem:

When calculating a dynamic group definition with more than one trait in the conditions a hibernate exception occurs. No group members are found.


Version-Release number of selected component (if applicable):
JON 2.4
EAP Plugins
SOAP Plugins
EWS Plugins
JDK 1.6 U23

Steps to Reproduce:
1. Create a new Group Definition
2. Enter the following as the conditions

resource.grandParent.trait[Trait.hostname].contains = stage
resource.parent.type.plugin = JBossAS5
resource.type.name = Web Application (WAR)
resource.trait[contextRoot] = jmx-console

Note: just using the jmx-console as an example, it won't matter what the context root is (unless it is blank because / as context root is not handled and throws the following syntax error:

Syntax error in your group definition: Expression must be in one of the follow forms: 'groupBy condition', 'condition = value', 'empty condition', 'not empty condition 

)

3. Save group
4. Calculate group members
  
Actual results:
In the UI:
There was a problem calculating the results: java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: could not locate named parameter [arg2] 

In the Log: 
ERROR [org.rhq.enterprise.server.resource.group.definition.GroupDefinitionManagerBean] Error recalculating DynaGroups for GroupDefinition[id=10011]
javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.QueryParameterException: could not locate named parameter [arg2]

see attached for relevant stack trace


Expected results:
Find all deployed jmx-console Web Applications for JBossAS 5 profiles on servers with "stage" in the hostname

Additional info:
It will find all Web Applications for JBossAS 5 profiles on servers with "stage" in the hostname if I remove the last line - so I think the condition is valid.

This also occurs when other group definitions with more than one trait in the conditions.

Comment 2 John Sanda 2012-06-22 19:51:28 UTC
After some investigation it looks like the expression parsing code was implementing in a way that never supported multiple traits; furthermore, this does not appear to be limited just to traits. For example, I generate the same exception with,

resource.type.plugin = RHQAgent
resource.type.name = Plugin Container
resource.type.plugin = RHQAgent
resource.type.name = Garbage Collector

I need to do some more investigation, but at this point I think we can treat this in one of two ways. Either treat as an RFE to support multiple conditions of the same type, or we say that these expressions are invalid and we need better error reporting to indicate as such.

Comment 3 John Sanda 2012-06-25 21:29:29 UTC
I have done some more investigation and have come to the conclusion that there would be a substantial amount of effort required to support these enhancements. First we would need to understand and identify what new types of JPQL queries would have to be generated. Based on my investigation and discussions with Jay Shaughnessy, I am not clear what those queries would look like. Next we would have to figure out how to implement the new functionality. ExpressionEvaluator is the primary class involved. It is designed across the board to only handle one resource expression for each type of supported expression. The supported types include:

* resource.id 
* resource.name 
* resource.version 
* resource.type.plugin 
* resource.type.name 
* resource.type.category 
* resource.availability
* resource.pluginConfiguration[<property-name>] 
* resource.resourceConfiguration[<property-name>] 
* resource.trait[<property-name>]

Lastly, a substantial amount of testing would be required to make sure that the new functionality behaves as expected and more importantly, to ensure no regressions are introduced. We also would need to take into consider the performance impact of the changes as the queries would likely be expensive operations.

I will proceed with changes for improved error handling. I will also open a docs bug to make sure we documented expressions that are and are not supported. If we do want to make these enhancements, I would prefer to track that effort under a separate RFE bug.

Comment 4 John Sanda 2012-06-26 15:06:01 UTC
The supported types listed in comment 3 did not include all the different resource context combinations which include,

* resource.child
* resource.parent
* resource.grandParent
* resource.greatGrandParent
* resource.greatGreatGrandParent

Comment 5 John Sanda 2012-06-27 15:59:24 UTC
While writing unit tests for the code involved, I discovered another scenario that is not supported. You can only have one plugin configuration expression or one resource configuration expression but not both. For example, the following will result in an exception similar to the one in the original description,

resource.pluginConfiguration[x] = foo
resource.resourceConfiguration[y] = bar

The reason for this is that the same alias is used for both plugin config and resource config properties in the generated JPQL query. Since this is a slightly different issue, I will open a separate bug to track this. This is something that could and should be fixed independent of this bug.

Comment 6 John Sanda 2012-07-02 15:47:48 UTC
I have added unit tests that cover all of the different resource expression combinations to verify that an exception is thrown. I have also updated the UI to provide better error reporting. Since this an exception that can be handled, we no longer propagate a stack trace to the UI. We instead report an error message like, "You cannot specify multiple trait expressions." Changes have been pushed to master.

commit hashes:
* 3442a828a
* 95a0bf5b8be
* c97c6b90b7
* 25b62b50ad

Comment 7 John Sanda 2012-07-02 17:24:32 UTC
*** Bug 835955 has been marked as a duplicate of this bug. ***

Comment 8 John Sanda 2012-07-02 17:28:50 UTC
Part of what I said in comment 5 is not entirely accurate. While it is a slightly separate issue since it involves different expression types, the problems are still the because plugin configuration and resource configuration expressions result in querying the same set of tables.

Comment 9 John Sanda 2012-07-08 18:29:06 UTC
I opened bug 837078 as a docs bug to make more clear that multiple expressions of the same type are illegal. The issue described in comment 5 involving resource and plugin config expressions was logged as bug 835955; however, I wound up closing 835955 since it is the same root issue as this bug. While it involves different expression types, it involves the same entities and tables.

Comment 10 Heiko W. Rupp 2013-09-01 10:03:08 UTC
Bulk closing of items that are on_qa and in old RHQ releases, which are out for a long time and where the issue has not been re-opened since.


Note You need to log in before you can comment on or make changes to this bug.