Classcast exception: ProjectComponent to GenericValue

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 14, 2017

In JIRA AMPS Version 6.2.11, I am getting classcastexception when I try to assign  ProjectComponent object to GenericValue. It was working before but giving issues with JIRA 7.5. Any suggestions please?

Here is the code and error

for (Iterator<ProjectComponent> compIterator = compCollection.iterator(); compIterator.hasNext();){

GenericValue component = (GenericValue) compIterator.next();

}

java.lang.ClassCastException: com.atlassian.jira.bc.project.component.ProjectComponentImpl cannot be cast to org.ofbiz.core.entity.GenericValue

1 answer

0 votes
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 15, 2017

Hello Srinivas,

Why are you trying to cast "ProjectComponent" to GenericValue bean?

Since all over the APIs this approach seems to have been deprecated and it's mentioned not to use "GenericValue" rather use the "ProjectComponent" bean

convertToGenericValue(ProjectComponent projectComponent)Deprecated. don't use GenericValue use the ProjectComponent instead.

https://docs.atlassian.com/jira/server/com/atlassian/jira/bc/project/component/ProjectComponentManager.html

getGenericValue()This method is deprecated. use this object instead

srinivasp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 16, 2017

GenericValue was used in some plugins that were developed long back and we are trying to refactor the code using the latest sdk. I replaced the GenericValue with ProjectComponent and that compiled successfully but for some reason the functionality is not working so I am looking if other way to achieve.

Suggest an answer

Log in or Sign up to answer