Hi all,
We have a in-house developed plugin installed on JSM. And recently we want to upgrade JSM to JSM 10, but encountered an issue that the package com.atlassian.plugins.rest.common.multipart won’t be exported by JSM. The error is as below:
osgi.wiring.package; (osgi.wiring.package=com.atlassian.plugins.rest.common.multipart) Unresoved requirements: [[our own plugin module name] (osgi.wiring.package=com.atlassian.plugins.rest.common.multipart)]
Could you help on how to fix the issue?
Regards,
YaoqiHuang
You need import
<dependency>
<groupId>com.atlassian.plugins.rest</groupId>
<artifactId>atlassian-rest-v2-api</artifactId>
<scope>provided</scope>
</dependency>
and if exist remove old version:
<dependency>
<groupId>com.atlassian.plugins.rest</groupId>
<artifactId>atlassian-rest-module</artifactId>
<version>7.0.2</version>
<scope>provided</scope>
</dependency>
After this, new classes for Jira, JSM 10 will be available
import com.atlassian.plugins.rest.api.multipart.FilePart;
import com.atlassian.plugins.rest.api.multipart.MultipartFormParam;
Hi @paul.addonix,
Thanks for your response.
But when I try to use the new package, the compilation got the following error:
cannot access com.atlassian.plugins.rest.api.multipart.FilePart
Could you please help on this? Thanks in advance.
Regards,
Yaoqi Huang
Add this dependency
<dependency>
<groupId>com.atlassian.plugins.rest</groupId>
<artifactId>atlassian-rest-v2-api</artifactId>
<scope>provided</scope>
</dependency>
Hi @paul.addonix,
I’ve already added this dependency
<dependency>
<groupId>com.atlassian.plugins.rest</groupId>
<artifactId>atlassian-rest-v2-api</artifactId>
<version>9.0.2</version>
<scope>provided</scope>
</dependency>
Still got this error:
cannot access com.atlassian.plugins.rest.api.multipart.FilePart
Regards,
Yaoqi Huang
Hi @paul.addonix,
It seems that FileUpload is just an interface and no implementation class, so do we need to import other dependencies?
Regards,
Yaoqi Huang
Hi.
Need sample code and list of dependencies in pom.xml.
Hi @paul.addonix,
The related pom and code block are as below:
<dependency>
<groupId>com.atlassian.plugins.rest</groupId>
<artifactId>atlassian-rest-v2-api</artifactId>
<version>9.0.2</version>
<scope>provided</scope>
</dependency>
import com.atlassian.plugins.rest.api.multipart.FilePart;
public class Bean {
private FilePart key;
public Bean(
FilePart key
) throws Exception {
this.key= key;
}
}
Regards,
Yaoqi Huang
You don’t need Bean.
Example for REST API upload:
import com.atlassian.plugins.rest.api.multipart.MultipartFormParam;
import com.atlassian.plugins.rest.api.multipart.FilePart;
@POST
@Path("/upload")
@Produces({MediaType.TEXT_PLAIN})
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Nullable
public String upload(@MultipartFormParam("file") FilePart file)
throws IOException {
//file.getInputStream()
}
Hi @paul.addonix,
This bean is just where the build exception is raised.
Here is the file upload example:
import com.atlassian.plugins.rest.api.multipart.MultipartFormParam;
import com.atlassian.plugins.rest.api.multipart.FilePart;
@POST
@Path("path")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public Response func(
@MultipartFormParam("key") FilePart key
) throws Exception {
try {
bean = new Bean(
key
);
return Response.ok().build();
}
catch (Exception e) {
throw e;
}
}
Regards,
Yaoqi Huang