Bug 536393 (RHQ-747)

Summary: ClassCastException when defining GroupDefinition
Product: [Other] RHQ Project Reporter: Van Halbert <vhalbert>
Component: ConfigurationAssignee: Joseph Marques <jmarques>
Status: CLOSED NEXTRELEASE QA Contact: Jeff Weiss <jweiss>
Severity: medium Docs Contact:
Priority: medium    
Version: 1.1preCC: dajohnso
Target Milestone: ---Keywords: SubBug
Target Release: ---   
Hardware: All   
OS: All   
URL: http://jira.rhq-project.org/browse/RHQ-747
Whiteboard:
Fixed In Version: 1.1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Windows Server
Last Closed: Type: ---
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: 536002    

Description Van Halbert 2008-08-21 15:10:00 UTC
Defining in the DynaGroup Expression builder:
Resource = Resource
ExpressionType = Resource
Definiing Plugin = MetaMatrixPlugin
ResourceType = MetaMatrix Process
PropertyNames = id
Comparison Type = '='
resource.id.startsWith = MetaMatrix System

Select Calculate groups and the message displays:  There was a problem calculating the results: java.lang.ClassCastException: java.lang.String

In the server log, the following stack trace:

2008-08-21 09:25:41,557 INFO  [org.hibernate.type.IntegerType] could not bind value 'MetaMatrix System%' to parameter: 1; java.lang.String

2008-08-21 09:25:41,557 ERROR [org.rhq.enterprise.gui.definition.group.EditGroupDefinitionGeneralPropertiesUIBean] There was a problem calculating the results: 
javax.ejb.EJBException: java.lang.ClassCastException: java.lang.String
	at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
	at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
	at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
	at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:106)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
	at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:214)
	at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:184)
	at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:81)
	at $Proxy245.calculateGroupMembership(Unknown Source)
	at org.rhq.enterprise.gui.definition.group.EditGroupDefinitionGeneralPropertiesUIBean.createGroups(EditGroupDefinitionGeneralPropertiesUIBean.java:156)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


Comment 1 Charles Crouch 2008-08-21 20:57:22 UTC
I don't know if this is it but 
"Definiing Plugin = MetaMatrixPlugin" doesnt look right, try

"Defining Plugin = MetaMatrixPlugin"

Comment 2 Joseph Marques 2008-08-28 04:58:12 UTC
van, i notice that the expression builder created an expression of "resource.id.startsWith = MetaMatrix System"

however, resource.id as an integer field, and you're trying to compare it to a non-integer value of "MetaMatrix System".  

you should notice that when you choose "Resource" as the expression type, that the defining plugin and resource type are grayed out.  that's because they aren't relevant for that particular expression type.

id is an integer type and so only the '=' operation is valid.  startswith, endswith, and contains are string methods that will only match on string expressions.  i'm accepting this, but only as a way to track the need to display a better error message instead of blowing up with a stack trace.

Comment 3 Joseph Marques 2008-08-28 05:19:19 UTC
rev1303 - show a much more specific and relevant error when fields are compared to values of incompatible type, or when string functions are used on non-string fields; 

Comment 4 Jeff Weiss 2008-09-09 19:31:27 UTC
rev1385, i tried the expression:

resource.id.startsWith = MetaMatrix System

and when i clicked "Calculate Groups", i got an errorblock

"Probable syntax error: this is likely due to comparing an integer property of resource (such as id) to a non-numeric, or using a string function (startswith, endswith, or contains) on an integer property"

which is more than sufficient to tell the user what they did wrong.

Comment 5 Red Hat Bugzilla 2009-11-10 21:16:08 UTC
This bug was previously known as http://jira.rhq-project.org/browse/RHQ-747