Hi I am currently working on a custom plugin after upgrading from Jira 9 to Jira 10.3.2.
There are lot of changes which is exactly breaking the plugin flow.
I cannot do @ComponentImport on lots of objects(TemplateRenderer, ActiveObjects etc) from the osgi bundle into a classes such as
@Component
public class CustomPluginServlet extends HttpServlet {
@Inject
public CustomPluginServlet(@ComponentImport UserManager userManager) {
this.userManager = ComponentAccessor.getUserManager();
}
or in classes such as
@Path("/samplePath")
@Component
public class CustomConfigRestResource {
private final TransactionTemplate transactionTemplate;
@Inject
public CustomConfigRestResource(@ComponentImport TransactionTemplate transactionTemplate) {
this.transactionTemplate = transactionTemplate;
}
Is there a way to overcome this? Secondly I have a custom class in my plugin very similar to shown below.
Named
@ExportAsService({TransactionTemplate.class})
public class MyTransactionTemplate implements TransactionTemplate {
private ActiveObjects ao;
@Inject
public MyTransactionTemplate(@ComponentImport ActiveObjects ao) {
this.ao = ao;
}
@Override
public <T> T execute(TransactionCallback<T> action) {
return ao.executeInTransaction(() -> {
try {
return action.doInTransaction();
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}
}
How do I inject this in the class CustomPluginServlet shown above?
Hi @Ravi Saurav
Your REST resources can still use Spring Scanner + @ComponentImport
after upgrading to Jira 10.3, but you must migrate to Jakarta packages and have Spring Scanner correctly configured. See release notes here.
- javax.servlet.* → jakarta.servlet.* (your servlet must extend jakarta.servlet.http.HttpServlet).
- javax.ws.rs.* → jakarta.ws.rs.* for REST resources.
- Build on Java 17.
Ensure you’re on Spring Scanner v2 and include the runtime so @ComponentImport/@ExportAsService generate the <component-import>/<component> entries in your plugin descriptor.
ActiveObjects & TemplateRenderer are still available as Spring services. Import and inject them only in Spring-managed classes (not raw servlets), see this page.
Your class seems fine, just ensure it’s Spring-managed and exported.
These are some clues to migrate to Jira 10.x
I hope that helps
Hi @Tuncay Senturk _Snapbytes_ thanks for your reponse but the issue is not resolved yet.
I added jakarta dependency with provided scope because with compile scope it says its a banned dependency.
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version> <!-- Match Jira SDK / Tomcat version -->
<scope>prvided</scope>
</dependency>
Here is the stacktrace I get:
Caused by: org.osgi.framework.BundleException: Unable to resolve com.xxxx.xxx.it.applications.custom-plugin[365](R 365.0): missing requirement [com.xxxx.xxx.it.applications.custom-plugin [365](R 365.0)] osgi.wiring.package; (osgi.wiring.package=jakarta.servlet) Unresolved requirements: [[com.xxxx.xxx.it.applications.custom-plugin [365](R 365.0)] osgi.wiring.package; (osgi.wiring.package=jakarta.servlet)]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My bad, sorry!
Jira 10.x requires Java 17 but not jakarta imports (not yet for 10.3), On Platform 7, Atlassian moved many deps to Jakarta but kept javax.* package names. Switching to jakarta.* will come later on Platform 9.
So, use provided javax.servlet as the below
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
and use the import
import javax.servlet.http.HttpServlet;
for REST, I think you need to use the dependency below
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>2.1.6</version>
<scope>provided</scope>
</dependency>
I am not 100% sure but I'd follow these steps.
By the way, it is always better to post this sort of developing questions on Atlassian Developer Community. You'd find better/more answers there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Tuncay Senturk _Snapbytes_ I will use that channel. But the @ComponentImport wouldn;t work.
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.