Hi:
Added the following dependencies into pom.xml.
<dependency> <groupId>com.atlassian.jira</groupId> <artifactId>jira-api</artifactId> <version>${jira.version}</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.atlassian.jira</groupId> <artifactId>jira-core</artifactId> <version>${jira.version}</version> <scope>provided</scope> </dependency>
Added one line of code for getting workflow manager
package com.atlassian.plugins.enterprisetester.rest; import com.atlassian.plugins.rest.common.security.AnonymousAllowed; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.atlassian.jira.ComponentManager; import com.atlassian.jira.workflow.WorkflowManager; import com.atlassian.jira.workflow.JiraWorkflow; import com.atlassian.jira.issue.Issue; /** * A resource of message. */ @Path("/message") public class EnterpriseTesterRestResource { @GET @AnonymousAllowed @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response getMessage() { //Getting workflow manager WorkflowManager workflowManager = ComponentManager.getInstance().getWorkflowManager(); return Response.ok(new EnterpriseTesterRestResourceModel("Hello World")).build(); } }
I got the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5:compile (default-compile) on project RestService: Compilion failure [ERROR] /C:/JiraPlugin/RestService/src/main/java/com/atlassian/plugins/enterprisetester/rest/EnterpriseTesterRestResource.java:[28,81] cant find symbol [ERROR] symbol: method getWorkflowManager() [ERROR] location: class com.atlassian.jira.ComponentManager [ERROR] -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5:compile (default-compile) on project RestService: Compilation failure /C:/JiraPlugin/RestService/src/main/java/com/atlassian/plugins/enterprisetester/rest/EnterpriseTesterRestResource.java:[28,81] cannot find symbol symbol: method getWorkflowManager() location: class com.atlassian.jira.ComponentManager at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.MojoExecutor.executeForkedExecutions(MojoExecutor.java:364) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:198) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:108) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213) at org.apache.maven.cli.MavenCli.main(MavenCli.java:157) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure /C:/JiraPlugin/RestService/src/main/java/com/atlassian/plugins/enterprisetester/rest/EnterpriseTesterRestResource.java:[28,81] cannot find ymbol symbol: method getWorkflowManager() location: class com.atlassian.jira.ComponentManager at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:970) at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:133) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
I don't know why method getWorkflowManager() can't be resolved.
Cheers
Steven
Community moderators have prevented the ability to post new answers.
ComponentManager has been depriated since use ComponentAccessor instead. In your case:
WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
Hi Vasiliy:
I tried your code:
WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
I can compile the above code using atlas-compile.
After running it using atlas-run, I got the following error when access the resource
Found some internal errors about the "missing requirement [50.0] osgi.wiring.package;". I don't know what it is.
ERROR - 17:36:16,262 - com.atlassian.plugin.osgi.factory.OsgiPlugin - [localhost-startStop-1] - Detected an error (BundleException) enabling the plugin 'com.atlassian.plugins.enterprisetester.RestService' : Unresolved constraint in bundle com.atlassian.plugins.enterprisetester.RestService [50]: Unable to resolve 50.0: missing requirement [50.0] osgi.wiring.package; (osgi.wiring.package=com.atlassian.jira.component). This error usually occurs when your plugin imports a package from another bundle with a specific version constraint and either the bundle providing that package doesn't meet those version constraints, or there is no bundle available that provides the specified package. For more details on how to fix this, see https://developer.atlassian.com/x/mQAN WARN - 17:36:16,262 - com.atlassian.plugin.impl.AbstractPlugin - [localhost-startStop-1] - Unable to enable plugin 'com.atlassian.plugins.enterprisetester.RestService' WARN - 17:36:16,262 - com.atlassian.plugin.impl.AbstractPlugin - [localhost-startStop-1] - Because of this exception com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.atlassian.plugins.enterprisetester.RestService at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:418) at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:286) at com.atlassian.plugin.manager.PluginEnabler.actualEnable(PluginEnabler.java:130) at com.atlassian.plugin.manager.PluginEnabler.enable(PluginEnabler.java:107) at com.atlassian.plugin.manager.DefaultPluginManager.enableDependentPlugins(DefaultPluginManager.java:1212) at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1188) at com.atlassian.plugin.manager.DefaultPluginManager.earlyStartup(DefaultPluginManager.java:573) at com.atlassian.plugin.refimpl.ContainerManager.<init>(ContainerManager.java:312) at com.atlassian.plugin.refimpl.InitListener.contextInitialized(InitListener.java:19) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:919) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1704) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.atlassian.plugins.enterprisetester.RestService [50]: Unable to resolve 50.0: missing requirement [50.0] osgi.wiring.package; (osgi.wiring.package=com.atlassian.jira.component) at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974) at org.apache.felix.framework.Felix.startBundle(Felix.java:2037) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942) at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:399) ... 21 more ERROR - 17:36:16,262 - com.atlassian.plugin.manager.PluginEnabler - [localhost-startStop-1] - Unable to enable plugin com.atlassian.plugins.enterprisetester.RestService com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.atlassian.plugins.enterprisetester.RestService at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:418) at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:286) at com.atlassian.plugin.manager.PluginEnabler.actualEnable(PluginEnabler.java:130) at com.atlassian.plugin.manager.PluginEnabler.enable(PluginEnabler.java:107) at com.atlassian.plugin.manager.DefaultPluginManager.enableDependentPlugins(DefaultPluginManager.java:1212) at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1188) at com.atlassian.plugin.manager.DefaultPluginManager.earlyStartup(DefaultPluginManager.java:573) at com.atlassian.plugin.refimpl.ContainerManager.<init>(ContainerManager.java:312) at com.atlassian.plugin.refimpl.InitListener.contextInitialized(InitListener.java:19) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:919) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1704) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.atlassian.plugins.enterprisetester.RestService [50]: Unable to resolve 50.0: missing requirement [50.0] osgi.wiring.package; (osgi.wiring.package=com.atlassian.jira.component) at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974) at org.apache.felix.framework.Felix.startBundle(Felix.java:2037) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942) at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:399)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are 2 options:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Vasiliy:
The difference between working and non-working one is the line you told me to add:
WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager(); |
I've tried my code in Script Console, it works fine. The error I got is not a compilation error.
If you can have a look at the error log I attached, then you will have a cue. I don't want to paste the same error log again and again.
Cheers
Steven
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ERROR - 09:28:37,928 - com.atlassian.plugin.osgi.factory.OsgiPlugin - [localhost-startStop-1] -
Detected an error (BundleException) enabling the plugin 'com.atlassian.plugins.enterprisetester.RestService' :
Unresolved constraint in bundle com.atlassian.plugins.enterprisetester.RestService [50]: Unable to resolve 50.0: missing requirement [50.0] osgi.wiring.package;
(osgi.wiring.package=com.atlassian.jira.component). This error usually occurs when your plugin imports a package from another bundle with a specific version
constraint and either the bundle providing that package doesn't meet those version constraints, or there is no bundle available that provides the specified package.
For more details on how to fix this, see https://developer.atlassian.com/x/mQAN
ERROR - 17:36:16,262 - com.atlassian.plugin.osgi.factory.OsgiPlugin - [localhost-startStop-1] - Detected an error (BundleException) enabling the plugin 'com.atlassian.plugins.enterprisetester.RestService' : Unresolved constraint in bundle com.atlassian.plugins.enterprisetester.RestService [50]: Unable to resolve 50.0: missing requirement [50.0] osgi.wiring.package; (osgi.wiring.package=com.atlassian.jira.component). This error usually occurs when your plugin imports a package from another bundle with a specific version constraint and either the bundle providing that package doesn't meet those version constraints, or there is no bundle available that provides the specified package. For more details on how to fix this, see https://developer.atlassian.com/x/mQAN WARN - 17:36:16,262 - com.atlassian.plugin.impl.AbstractPlugin - [localhost-startStop-1] - Unable to enable plugin 'com.atlassian.plugins.enterprisetester.RestService' WARN - 17:36:16,262 - com.atlassian.plugin.impl.AbstractPlugin - [localhost-startStop-1] - Because of this exception com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.atlassian.plugins.enterprisetester.RestService at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:418) at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:286) at com.atlassian.plugin.manager.PluginEnabler.actualEnable(PluginEnabler.java:130) at com.atlassian.plugin.manager.PluginEnabler.enable(PluginEnabler.java:107) at com.atlassian.plugin.manager.DefaultPluginManager.enableDependentPlugins(DefaultPluginManager.java:1212) at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1188) at com.atlassian.plugin.manager.DefaultPluginManager.earlyStartup(DefaultPluginManager.java:573) at com.atlassian.plugin.refimpl.ContainerManager.<init>(ContainerManager.java:312) at com.atlassian.plugin.refimpl.InitListener.contextInitialized(InitListener.java:19) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:919) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1704) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.atlassian.plugins.enterprisetester.RestService [50]: Unable to resolve 50.0: missing requirement [50.0] osgi.wiring.package; (osgi.wiring.package=com.atlassian.jira.component) at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974) at org.apache.felix.framework.Felix.startBundle(Felix.java:2037) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942) at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:399) ... 21 more ERROR - 17:36:16,262 - com.atlassian.plugin.manager.PluginEnabler - [localhost-startStop-1] - Unable to enable plugin com.atlassian.plugins.enterprisetester.RestService com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.atlassian.plugins.enterprisetester.RestService at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:418) at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:286) at com.atlassian.plugin.manager.PluginEnabler.actualEnable(PluginEnabler.java:130) at com.atlassian.plugin.manager.PluginEnabler.enable(PluginEnabler.java:107) at com.atlassian.plugin.manager.DefaultPluginManager.enableDependentPlugins(DefaultPluginManager.java:1212) at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1188) at com.atlassian.plugin.manager.DefaultPluginManager.earlyStartup(DefaultPluginManager.java:573) at com.atlassian.plugin.refimpl.ContainerManager.<init>(ContainerManager.java:312) at com.atlassian.plugin.refimpl.InitListener.contextInitialized(InitListener.java:19) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:919) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1704) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.atlassian.plugins.enterprisetester.RestService [50]: Unable to resolve 50.0: missing requirement [50.0] osgi.wiring.package; (osgi.wiring.package=com.atlassian.jira.component) at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974) at org.apache.felix.framework.Felix.startBundle(Felix.java:2037) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942) at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:399)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Found some internal errors about the "missing requirement [50.0] osgi.wiring.package;". I don't know what it is.
ERROR - 17:36:16,262 - com.atlassian.plugin.osgi.factory.OsgiPlugin - [localhost-startStop-1] - Detected an error (BundleException) enabling the plugin 'com.atlassian.plugins.enterprisetester.RestService' : Unresolved constraint in bundle com.atlassian.plugins.enterprisetester.RestService [50]: Unable to resolve 50.0: missing requirement [50.0] osgi.wiring.package; (osgi.wiring.package=com.atlassian.jira.component). This error usually occurs when your plugin imports a package from another bundle with a specific version constraint and either the bundle providing that package doesn't meet those version constraints, or there is no bundle available that provides the specified package. For more details on how to fix this, see https://developer.atlassian.com/x/mQAN WARN - 17:36:16,262 - com.atlassian.plugin.impl.AbstractPlugin - [localhost-startStop-1] - Unable to enable plugin 'com.atlassian.plugins.enterprisetester.RestService' WARN - 17:36:16,262 - com.atlassian.plugin.impl.AbstractPlugin - [localhost-startStop-1] - Because of this exception com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.atlassian.plugins.enterprisetester.RestService at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:418) at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:286) at com.atlassian.plugin.manager.PluginEnabler.actualEnable(PluginEnabler.java:130) at com.atlassian.plugin.manager.PluginEnabler.enable(PluginEnabler.java:107) at com.atlassian.plugin.manager.DefaultPluginManager.enableDependentPlugins(DefaultPluginManager.java:1212) at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1188) at com.atlassian.plugin.manager.DefaultPluginManager.earlyStartup(DefaultPluginManager.java:573) at com.atlassian.plugin.refimpl.ContainerManager.<init>(ContainerManager.java:312) at com.atlassian.plugin.refimpl.InitListener.contextInitialized(InitListener.java:19) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:919) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1704) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.atlassian.plugins.enterprisetester.RestService [50]: Unable to resolve 50.0: missing requirement [50.0] osgi.wiring.package; (osgi.wiring.package=com.atlassian.jira.component) at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974) at org.apache.felix.framework.Felix.startBundle(Felix.java:2037) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942) at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:399) ... 21 more ERROR - 17:36:16,262 - com.atlassian.plugin.manager.PluginEnabler - [localhost-startStop-1] - Unable to enable plugin com.atlassian.plugins.enterprisetester.RestService com.atlassian.plugin.osgi.container.OsgiContainerException: Cannot start plugin: com.atlassian.plugins.enterprisetester.RestService at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:418) at com.atlassian.plugin.impl.AbstractPlugin.enable(AbstractPlugin.java:286) at com.atlassian.plugin.manager.PluginEnabler.actualEnable(PluginEnabler.java:130) at com.atlassian.plugin.manager.PluginEnabler.enable(PluginEnabler.java:107) at com.atlassian.plugin.manager.DefaultPluginManager.enableDependentPlugins(DefaultPluginManager.java:1212) at com.atlassian.plugin.manager.DefaultPluginManager.addPlugins(DefaultPluginManager.java:1188) at com.atlassian.plugin.manager.DefaultPluginManager.earlyStartup(DefaultPluginManager.java:573) at com.atlassian.plugin.refimpl.ContainerManager.<init>(ContainerManager.java:312) at com.atlassian.plugin.refimpl.InitListener.contextInitialized(InitListener.java:19) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4760) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5184) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:714) at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:919) at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1704) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.osgi.framework.BundleException: Unresolved constraint in bundle com.atlassian.plugins.enterprisetester.RestService [50]: Unable to resolve 50.0: missing requirement [50.0] osgi.wiring.package; (osgi.wiring.package=com.atlassian.jira.component) at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974) at org.apache.felix.framework.Felix.startBundle(Felix.java:2037) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:955) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:942) at com.atlassian.plugin.osgi.factory.OsgiPlugin.enableInternal(OsgiPlugin.java:399)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I can compile the above code using atlas-compile.
After running it using atlas-run, I got the following error when access the resource
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Then I tried a different approach to get workflow manager using ComponentAccessor
package com.atlassian.plugins.enterprisetester.rest; import com.atlassian.plugins.rest.common.security.AnonymousAllowed; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.ComponentManager; import com.atlassian.jira.workflow.WorkflowManager; import com.atlassian.jira.workflow.JiraWorkflow; import com.atlassian.jira.issue.Issue; /** * A resource of message. */ @Path("/message") public class EnterpriseTesterRestResource { @GET @AnonymousAllowed @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response getMessage() { WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager(); JiraWorkflow workflow = workflowManager.getWorkflow("Bug Workflow for Project STPJ"); String workflowName = workflow.getName(); return Response.ok(new EnterpriseTesterRestResourceModel("Hel")).build(); } }
I got the following error (ComponentAccessor has not been initialised) :
Running ut.com.atlassian.plugins.enterprisetester.MyComponentUnitTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 sec Running ut.com.atlassian.plugins.enterprisetester.rest.EnterpriseTesterRestResourceTest Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec <<< FAILURE! messageIsValid(ut.com.atlassian.plugins.enterprisetester.rest.EnterpriseTesterRestResourceTest) Time elapsed: 0 sec <<< ERROR! java.lang.IllegalStateException: ComponentAccessor has not been initialised. This is not expected to occur on a production system. Developers that encounter this message within a unit test should use n MockitoMocksInContainer rule to initialize mockito and ComponentAccessor. For more detailed explanation read the documentation for MockComponentWorker in the jira-tests artifact for more information about what causes this error and how to address it. at com.atlassian.jira.component.ComponentAccessor.getWorker(ComponentAccessor.java:754) at com.atlassian.jira.component.ComponentAccessor.getComponent(ComponentAccessor.java:165) at com.atlassian.jira.component.ComponentAccessor.getWorkflowManager(ComponentAccessor.java:366) at ut.com.atlassian.plugins.enterprisetester.rest.EnterpriseTesterRestResourceTest.messageIsValid(EnterpriseTesterRestResourceTest.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) Results : Tests in error: messageIsValid(ut.com.atlassian.plugins.enterprisetester.rest.EnterpriseTesterRestResourceTest): ComponentAccessor has not been initialise d.(..) Tests run: 2, Failures: 0, Errors: 1, Skipped: 0com.atlassian.plugins.enterprisetester.rest;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.