2012-10-30 107 views
0

我是新來的JIRA我下載M2E Eclipse插件靛藍和JIRA 5.0版本NoClassDefFoundError的JIRA REST API

public class JIRAClient { 
     public static void main(String[] args) throws URISyntaxException { 
      final JerseyJiraRestClientFactory factory = new JerseyJiraRestClientFactory(); 
      final URI jiraServerUri = new URI("http://jira.travelclick.net:8080/jira/rest/api"); 

Exception---> final JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraServerUri, "nsrivastava", "Password12"); 

      final NullProgressMonitor pm = new NullProgressMonitor();  
      final Issue issue = restClient.getIssueClient().getIssue("TST-1", pm); 
      System.out.println(issue);   

      } 
     } 

我有例外

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 client.JIRAClient.main(JIRAClient.java:24) 

下面我也下載共享記錄-1.1。 1.jar文件是我的類路徑文件(由Eclipse創建)

<?xml version="1.0" encoding="UTF-8"?> 
<classpath> 
    <classpathentry kind="src" output="target/classes" path="src/main/java"> 
     <attributes> 
      <attribute name="optional" value="true"/> 
      <attribute name="maven.pomderived" value="true"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> 
     <attributes> 
      <attribute name="maven.pomderived" value="true"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry kind="src" output="target/test-classes" path="src/test/java"> 
     <attributes> 
      <attribute name="optional" value="true"/> 
      <attribute name="maven.pomderived" value="true"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> 
     <attributes> 
      <attribute name="maven.pomderived" value="true"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"> 
     <attributes> 
      <attribute name="maven.pomderived" value="true"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> 
     <attributes> 
      <attribute name="maven.pomderived" value="true"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry kind="lib" path="C:/Users/bhaviksh/Downloads/httpcomponents-client-4.2.2-bin/httpcomponents-client-4.2.2/lib/commons-logging-1.1.1.jar"/> 
    <classpathentry kind="output" path="target/classes"/> 
</classpath> 

這將是我的第一個程序,我甚至不知道w JIRA到底是什麼呢。

回答

2

發生這種情況是因爲您使用的API需要Jakarta Commons的HTTPClient 運行時。 commons-httpclient是否包含在運行時類路徑中? (你不需要它進行編譯)

+0

不,它不是,但我找不到那個jar文件。我從這個鏈接http://hc.apache.org/downloads.cgi下載了一個HttpClient jar,但它不包含commons-httpclient –

+0

完成謝謝你,你真棒 –