atlassian-plugin.xml:
<web-item name="Run Grovy Script" i18n-name-key="run-grovy-script.name" key="run-grovy-script" section="operations-work" weight="1000">
<description key="run-grovy-script.description">The Run Grovy Script Plugin</description>
<label key="run-grovy-script.label"/>
<link linkId="run-grovy-script-link">/plugins/servlet/rungrovyservlet</link>
<styleClass>trigger-dialog</styleClass>
</web-item>
<servlet name="Run Grovy Servlet" i18n-name-key="run-grovy-servlet.name" key="run-grovy-servlet" class="com.example.issuetest.grovyscript.RunGrovyServlet">
<description key="run-grovy-servlet.description">The Run Grovy Servlet Plugin</description>
<url-pattern>/rungrovyservlet</url-pattern>
</servlet>
RunGrovyScript.java:
package com.example.issuetest.grovyscript;
import groovy.lang.GroovyShell;
import javax.inject.Named;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Named
public class RunGrovyServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
GroovyShell shell = new GroovyShell();
String script = "println 'Groovy script executed from Jira plugin!'";
try {
shell.evaluate(script);
resp.getWriter().write(" Groovy script executed successfully!");
} catch (Exception e) {
resp.getWriter().write(" Error running Groovy script: " + e.getMessage());
}
}
}
After running this plugin first of all my plugin automatic disabled and from the logs i am getting
Errors:
2 plugins failed to load during Jira startup.
[INFO] [talledLocalContainer]
[INFO] [talledLocalContainer] 'com.example.issuetest.issuedetail' - 'issuedetail' failed to load.
[INFO] [talledLocalContainer] Cannot start plugin: com.example.issuetest.issuedetail
[INFO] [talledLocalContainer] Unable to resolve com.example.issuetest.issuedetail [193](R 193.0): missing requirement [com.example.issuetest.issuedetail [193](R 193.0)] osgi.wiring.package; (osgi.wiring.package=com.ibm.icu.lang) Unresolved requirements: [[com.example.issuetest.issuedetail [193](R 193.0)] osgi.wiring.package; (osgi.wiring.package=com.ibm.icu.lang)]
atlassian-plugin/issuedetail/target/jira/home/plugins/installed-plugins/issuedetail-1.0.0-SNAPSHOT.jar
[INFO] [talledLocalContainer]
[INFO] [talledLocalContainer] 'com.example.issuetest.issuedetail-tests' - 'issuedetail' failed to load.
[INFO] [talledLocalContainer] Cannot start plugin: com.example.issuetest.issuedetail-tests
[INFO] [talledLocalContainer] Unable to resolve com.example.issuetest.issuedetail-tests [194](R 194.0): missing requirement [com.example.issuetest.issuedetail-tests [194](R 194.0)] osgi.wiring.package; (osgi.wiring.package=com.example.issuetest.issuedetail.api) [caused by: Unable to resolve com.example.issuetest.issuedetail [193](R 193.0): missing requirement [com.example.issuetest.issuedetail [193](R 193.0)] osgi.wiring.package; (osgi.wiring.package=com.ibm.icu.lang)] Unresolved requirements: [[com.example.issuetest.issuedetail-tests [194](R 194.0)] osgi.wiring.package; (osgi.wiring.package=com.example.issuetest.issuedetail.api)]
This error means your plugin bundle can’t resolve the `com.ibm.icu.lang` package at runtime, so OSGi disables it during startup. Jira’s plugin framework isolates dependencies, and only certain packages from the host application are exported. The Groovy runtime and ICU4J libraries used internally by Jira aren’t automatically available to your plugin, so your classpath can’t find them. To fix this, declare the missing dependencies directly in your plugin’s `pom.xml` and import them explicitly in your `atlassian-plugin.xml` or via the `Import-Package` header in your `maven-bundle-plugin` configuration. For example, add a provided dependency for Groovy and an import for `com.ibm.icu.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.