Hello Atlassian Team,
I am unmarshaling a json string element containing the following fully qualified class name:
com.atlassian.jira.workflow.function.issue.UpdateIssueStatusFunction
I am trying to obtain the Class object for this class using the following line of code
Class.forName("com.atlassian.jira.workflow.function.issue.UpdateIssueStatusFunction");
When I run this code, I am getting ClassNotFoundException. We then realized that the class was not getting loaded. In order to load the class, I had to run the following lines of code:
log.warn(String.valueOf(UpdateIssueStatusFunction.class));
Class.forName("com.atlassian.jira.workflow.function.issue.UpdateIssueStatusFunction");
This line loaded the class and then I was able to obtain the Class object that I needed.
Now coming to the question.
Could you please tell me how to load the class using a classLoader (or something similar) when I want to generalize the above line of code as following:
Class.forName(name); // name is a string which receives a value at runtime.
?
Hello Jobin,
Thank you for your solutions. I was able to figure out the class in JIRA core API that can dynamically load classes given the name of the class as a string. The following code was able to load the class that I needed dynamically.
ClassLoaderUtils.loadClass(name, <this-class-name>.class.getClassLoader());
Hello Jobin,
Thank you for your solutions and support. I have found a class that can load classes that I need given the classname. The following code was able to load the classes that I need.
ClassLoaderUtils.loadClass(name, this.getClass().getClassLoader())
Where name is fully qualified classname as a string, this.getClass().getClassLoader() returns the class loader of the calling class.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you trying to do this in a plugin? To make the core classes available, use the following maven dependency in the pom.
<dependency> <groupId>com.atlassian.jira</groupId> <artifactId>jira-core</artifactId> <version>${jira.version}</version> <scope>provided</scope> </dependency>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Still not seeeing it? Make sure you clean up the project and recreate it. And then refresh the IDE.
For ecllipse:
mvn elicpse:clean eclipse:eclipse
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.