Dear Atlassian Community,
currently, I am developing a plugin for jira 6.1.
On Event "afterPropertiesSet" it defines own Issue Types and Customfields, as described here:
https://answers.atlassian.com/questions/43232/how-to-create-a-plugin-that-packages-custom-issue-types-to-add-to-jira-instance-is-it-possible
After I created my IssueTypes:
com.atlassian.jira.config.ConstantsManager constantsManager; constantsManager.insertIssueType(getName(), getSequencenumber(), getStyle(), getDescription(), getIconURL());
I want to add them as parameters to a new CustomField:
com.atlassian.jira.issue.CustomFieldManager customFieldManager; customFieldManager.createCustomField( getCustomFieldName(), getCustomFieldDescription(), customFieldManager.getCustomFieldType(getCustomFieldType()), customFieldManager.getCustomFieldSearcher(getCustomFieldSearcher()), getContexts(), getIssueTypes());
Thats why I want to retrieve the issueTypes from the customFieldManager again, before giving them as Arguments to the new created customField:
This Way it works (but its deprecated):
constantsManager.getConstantByName(constantsManager.ISSUE_TYPE_CONSTANT_TYPE, getName())
This Way it does not work (but it should be right from my point of view):
constantsManager.getConstantByNameIgnoreCase(constantsManager.ISSUE_TYPE_CONSTANT_TYPE, getName());
If I do it the right way, I am running into an internal class cast exception at "customFieldManager.createCustomField". It really wants the issueTypes-List as "org.ofbiz.core.entity.GenericValue" instead of "com.atlassian.jira.issue.IssueConstant".
Here is the Stacktrace:
[INFO] [talledLocalContainer] java.lang.ClassCastException: com.atlassian.jira.issue.issuetype.IssueTypeImpl cannot be cast to org.ofbiz.core.entity.GenericValue [INFO] [talledLocalContainer] at com.atlassian.jira.issue.fields.config.manager.FieldConfigSchemeManagerImpl.createDefaultScheme(FieldConfigSchemeManagerImpl.java:157) [INFO] [talledLocalContainer] at com.atlassian.jira.issue.managers.DefaultCustomFieldManager.associateCustomFieldContext(DefaultCustomFieldManager.java:213) [INFO] [talledLocalContainer] at com.atlassian.jira.issue.managers.DefaultCustomFieldManager.createCustomField(DefaultCustomFieldManager.java:195) [INFO] [talledLocalContainer] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [INFO] [talledLocalContainer] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [INFO] [talledLocalContainer] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [INFO] [talledLocalContainer] at java.lang.reflect.Method.invoke(Method.java:597) [INFO] [talledLocalContainer] at com.atlassian.plugin.osgi.hostcomponents.impl.DefaultComponentRegistrar$ContextClassLoaderSettingInvocationHandler.invoke(DefaultComponentRegistrar.java:129) [INFO] [talledLocalContainer] at com.sun.proxy.$Proxy225.createCustomField(Unknown Source) [INFO] [talledLocalContainer] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [INFO] [talledLocalContainer] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [INFO] [talledLocalContainer] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [INFO] [talledLocalContainer] at java.lang.reflect.Method.invoke(Method.java:597) [INFO] [talledLocalContainer] at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:154) [INFO] [talledLocalContainer] at com.sun.proxy.$Proxy225.createCustomField(Unknown Source) [INFO] [talledLocalContainer] at com.myplugin.service.WrapperCustomFieldService.persistOwnJiraObject(WrapperCustomFieldService.java:88) [INFO] [talledLocalContainer] at com.myplugin.testsuite.domain.CustomFieldFactory.createAllCustomFields(CustomFieldFactory.java:62) [INFO] [talledLocalContainer] at com.myplugin.testsuite.controller.Main.init(Main.java:62) [INFO] [talledLocalContainer] at com.myplugin.testsuite.lifecycle.PluginListener.afterPropertiesSet(PluginListener.java:45) [INFO] [talledLocalContainer] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369) [INFO] [talledLocalContainer] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335) [INFO] [talledLocalContainer] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) [INFO] [talledLocalContainer] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) [INFO] [talledLocalContainer] at java.security.AccessController.doPrivileged(Native Method) [INFO] [talledLocalContainer] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) [INFO] [talledLocalContainer] at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) [INFO] [talledLocalContainer] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) [INFO] [talledLocalContainer] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) [INFO] [talledLocalContainer] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) [INFO] [talledLocalContainer] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) [INFO] [talledLocalContainer] at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429) [INFO] [talledLocalContainer] at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) [INFO] [talledLocalContainer] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69) [INFO] [talledLocalContainer] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355) [INFO] [talledLocalContainer] at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85) [INFO] [talledLocalContainer] at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320) [INFO] [talledLocalContainer] at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132) [INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) [INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
My Question is: Do you know any smarter way instead of using a deprecated Method?
Community moderators have prevented the ability to post new answers.
I supose this is an useless answer for you now (2 months later), but i hope it will be useful if anybody (like me) reads this in the future.
I had the same problem. It seems that createCustomField just works with a GenericValue list (I use jira 6.1.4), but you can get the GenericValue from an IssueConstant with getGenericValue().
It works if you change your function:
public List<GenericValue> getIssueTypes() { ArrayList<GenericValue> its = new ArrayList<GenericValue>(); its.add(constantsManager.getConstantByNameIgnoreCase(constantsManager.ISSUE_TYPE_CONSTANT_TYPE, "myIssueType").getGenericValue()); return its; }
Your are right, the project has been finished but we will consider it in the future.
I will accept it untested for now so take the "Karma" and regards in advance ;)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think the createCustomField require a list of IssueTypes
how getIssueTypes method is written to get the list?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think the createCustomField require a list of IssueTypes
how getIssueTypes method is written to get the list?
Like I wrote before, simplified it works like this:
void myAddMethod() { customFieldManager.createCustomField( getCustomFieldName(), getCustomFieldDescription(), customFieldManager.getCustomFieldType(getCustomFieldType()), customFieldManager.getCustomFieldSearcher(getCustomFieldSearcher()), getContexts(), getIssueTypes()); } public List<GenericValue> getIssueTypes() { ArrayList<GenericValue> its = new ArrayList<GenericValue>(); its.add(constantsManager.getConstantByName(constantsManager.ISSUE_TYPE_CONSTANT_TYPE, "myIssueType")); return its; }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
public List<GenericValue> getIssueTypes() { ArrayList<GenericValue> its = new ArrayList<GenericValue>(); its.add(constantsManager.getConstantByName(constantsManager.ISSUE_TYPE_CONSTANT_TYPE, "myIssueType")); return its; }
public List<IssueConstant> getIssueTypes() { ArrayList<IssueConstant> its = new ArrayList<IssueConstant>(); its.add(constantsManager.getConstantByName(constantsManager.ISSUE_TYPE_CONSTANT_TYPE, "myIssueType")); return its; }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
after changing the return type of getIssueTypes() method i.e List<IssueConstant>, is getIssueConstantByName(...) throwing error?
public List<IssueConstant> getIssueTypes() { ArrayList<IssueConstant> its = new ArrayList<IssueConstant>(); its.add(ComponentAccessor.getConstantsManager().getIssueConstantByName(ComponentAccessor.getConstantsManager().ISSUE_TYPE_CONSTANT_TYPE, "myIssueType")); return its; }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The error is thrown at
customFieldManager.createCustomField( getCustomFieldName(), getCustomFieldDescription(), customFieldManager.getCustomFieldType(getCustomFieldType()), customFieldManager.getCustomFieldSearcher(getCustomFieldSearcher()), getContexts(), getIssueTypes());
If "getIssueTypes()" returns "List<IssueConstant>".
If "getIssueTypes()" returns "List<GenericValue>" everything is ok.
For the Stacktrace please read the description on top of this page.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you need to add try/catch or throws clause to createCustomField.
If you added and even getting error, then is it showing on method call itself? or at run time?
if at all runtime then could you paste the log error message?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
did you tried with this method
getIssueConstantByName(String constantType,String name)
check this doc
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.