我可以使用其他客户端API创建jira问题,但我无法将screeshot / attachment附加到现有的JIRA
问题。如果有人能够提供真正受到赞赏的解决方案,那将会非常有用。
我刚刚编写了以下代码片段,用于将jpeg文件附加到现有JIRA Issue
。但后来我经历了“线程中的异常”主“java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpConnectionManager"
代码段: -
private static String addAttachment(String attachmentfilepath)抛出URISyntaxException,FileNotFoundException {
final java.net.URI jiraServerUri = new java.net.URI("https://oliveits.atlassian.net");
FileInputStream fileStreamPath = new FileInputStream(attachmentfilenamepath);
JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory();
NullProgressMonitor pm = new NullProgressMonitor();
System.out.println("Server Url :"+jiraServerUri);
JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri,"mobileqa","MobileQA1234");
Issue issue1 = restClient.getIssueClient().getIssue(newKey, pm);
final java.net.URI AttachmentUri = new java.net.URI(jiraServerUri+"/rest/api/2/issue/"+newKey+"/attachments");
System.out.println("URI :"+issue1.getAttachmentsUri());
//restClient.getIssueClient().addAttachment(pm,issue1.getAttachmentsUri(), fileStreamPath , imageName);
restClient.getIssueClient().addAttachment(pm, AttachmentUri, fileStreamPath, imageName);
return attachmentfilepath;
}
例外: -
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/HttpConnectionManager
at com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory.create(JerseyJiraRestClientFactory.java:34)
at com.atlassian.jira.rest.client.internal.jersey.JerseyJiraRestClientFactory.createWithBasicHttpAuthentication(JerseyJiraRestClientFactory.java:39)
at com.jtricks.JTricksRESTClient.addAttachment(JTricksRESTClient.java:157)
at com.jtricks.JTricksRESTClient.main(JTricksRESTClient.java:101)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.HttpConnectionManager
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 4 more
刚刚将缺少的jar文件添加到类路径中。但是我得到了如下所述的例外情况。
异常Msg-1:com.sun.jersey.api.client.ClientHandlerException:Java类com.sun.jersey.multipart.MultiPart的消息体编写器,Java类类com.sun.jersey.multipart.MultiPart ,以及MIME媒体类型multipart / form-data; boundary = Boundary_1_18541827_1358346116249未找到
异常Msg-2:com.sun.jersey.api.client.ClientHandlerException:Java类com.sun.jersey.multipart.MultiPart的消息体编写器和Java类类com.sun.jersey.multipart.MultiPart ,以及MIME媒体类型multipart / form-data; boundary = Boundary_1_18541827_1358346116249未找到
答案 0 :(得分:1)
您的问题来自无法找到org.apache.commons.httpclient.HttpConnectionManager
课程。在类路径中查找commons-httpclient
JAR。