java - NoClassDefFoundError JIRA REST API

标签 java maven maven-plugin jira

我是 JIRA 新手,我下载了 eclipse Indigo 和 JIRA 5.0 版本的 m2e 插件

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)

我还下载了 commons-logging-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>

这将是我的第一个程序,我什至还不知道 JIRA 到底是什么。

最佳答案

发生这种情况是因为您使用的 API 在运行时需要 Jakarta Commons 的 HTTPClient。 commons-httpclient 是否包含在您的运行时类路径中? (编译时不需要它)

关于java - NoClassDefFoundError JIRA REST API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13133202/

相关文章:

java - findbugs-maven-plugin 什么都不做

tomcat - 像分解一样运行 Maven Tomcat 7

java - Intellij Maven : Create jar with all library dependencies

java - findbugs-maven-plugin 项目与 JDK 1.6 1.7 和 1.8 一起工作

java - JPA CriteriaBuilder 泛型错误 : CriteriaQuery<capture#2-of ? > 不适用于参数 (Expression<Long>)

java - 谷歌 Collection ( Guava 图书馆): ImmutableSet/List/Map and Filtering

java - accessDeniedPage 重定向,而不仅仅是显示相应页面的 RSS 提要

java - 这段Java代码是什么意思?

java - 添加 GitLab 私有(private)仓库作为 Maven 依赖

java - 使用 Wildfly Maven 插件在与 localhost 不同的地址上部署应用程序