我正在创建应该执行我的Java xml-rpc客户端的confluence宏。
我测试了我的Java xml-rpc客户端在eclipse(主函数)中终止它 - 它完美无缺,
但是当我尝试将其与汇合连接时,我得到错误:
(宏已成功安装 - 错误作为输出)
呈现宏&#T; TESTLINK PLUGIN' : 无法初始化类org.apache.xmlrpc.util.SAXParsers
有人可以帮我理解这里发生了什么吗?我读到它可能是外部罐子的问题 - 但是鉴于awesers不能解决我的问题。
我还使用 mvn-install 命令安装了我的xmlrpc,并将依赖项添加到我的pom.xml中,SAXParsers应该包含在那里......
这是我到目前为止所做的代码:
testlink.java:
package com.project.testlink.api;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Map;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
public class testlink {
public testlink() {
// TODO Auto-generated constructor stub
}
// Substitute your Dev Key Here
public static final String DEV_KEY = "zzzzZZz";
// Substitute your Server URL Here
public static final String SERVER_URL = "zzzZZZZ/xmlrpc.php";
public static String testLinkReport(String link)
{
String title="Error Ocurred";
String tcid = link.substring(link.lastIndexOf("=")+1);
try
{
XmlRpcClient rpcClient;
XmlRpcClientConfigImpl config;
config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL(SERVER_URL));
rpcClient = new XmlRpcClient();
rpcClient.setConfig(config);
ArrayList<Object> params = new ArrayList<Object>();
Hashtable<String, Object> executionData = new Hashtable<String, Object>();
executionData.put("devKey", DEV_KEY);
executionData.put("testcaseexternalid", tcid);
params.add(executionData);
Object[] result = (Object[]) rpcClient.execute("tl.getTestCase", params);
Map item = (Map)result[0];
title = tcid+":"+ item.get("name").toString();
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (XmlRpcException e)
{
e.printStackTrace();
}
return title;
}
}
mymacro.java:
package com.project.testlink.api;
import java.util.Map;
import com.atlassian.confluence.content.render.xhtml.ConversionContext;
import com.atlassian.confluence.macro.Macro;
import com.atlassian.confluence.macro.MacroExecutionException;
public class mymacro implements Macro {
public mymacro() {
// TODO Auto-generated constructor stub
}
@Override
public String execute(Map<String, String> arg0, String arg1, ConversionContext arg2)
throws MacroExecutionException {
// TODO Auto-generated method stub
return testlink.testLinkReport("HL&item=testcase&id=7780");
}
@Override
public BodyType getBodyType() {
// TODO Auto-generated method stub
return BodyType.NONE;
}
@Override
public OutputType getOutputType() {
// TODO Auto-generated method stub
return OutputType.BLOCK;
}
/*
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(testlink.testLinkReport("HL&item=testcase&id=7780"));
}
*/
}
Atlassian的-plugin.xml中:
<atlassian-plugin key="${atlassian.plugin.key}" name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}" url="${project.organization.url}" />
<param name="plugin-icon">images/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>
</plugin-info>
<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="testlink"/>
<xhtml-macro name="TESTLINK PLUGIN" class="com.project.testlink.api.mymacro" key="mymacro" icon="/download/resources/${project.groupId}.${project.artifactId}/images/pluginIcon.png">
<category name="external-content"/>
<parameters>
<parameter name="Testlink" type="string" required="true"/>
</parameters>
<description>Inserts a calendar for the week into the current page</description>
</xhtml-macro>
<!-- add our web resources -->
<web-resource key="testlink-resources" name="testlink Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="testlink.css" location="/css/testlink.css"/>
<resource type="download" name="testlink.js" location="/js/testlink.js"/>
<resource type="download" name="images/" location="/images"/>
<context>testlink</context>
</web-resource>
</atlassian-plugin>
的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.project.testlink</groupId>
<artifactId>testlink</artifactId>
<version>1.0.0-SNAPSHOT</version>
<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>
<name>testlink</name>
<description>This is the com.project.testlink:testlink plugin for Atlassian Confluence.</description>
<packaging>atlassian-plugin</packaging>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.atlassian.confluence</groupId>
<artifactId>confluence</artifactId>
<version>${confluence.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-annotation</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-runtime</artifactId>
<version>${atlassian.spring.scanner.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
<scope>provided</scope>
</dependency>
<!-- WIRED TEST RUNNER DEPENDENCIES -->
<dependency>
<groupId>com.atlassian.plugins</groupId>
<artifactId>atlassian-plugins-osgi-testrunner</artifactId>
<version>${plugin.testrunner.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2-atlassian-1</version>
</dependency>
<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xml-common</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>org.apache.xmlrpc</groupId>
<artifactId>xml-client</artifactId>
<version>3.1.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-confluence-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${confluence.version}</productVersion>
<productDataVersion>${confluence.data.version}</productDataVersion>
<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>
<!-- See here for an explanation of default instructions: -->
<!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
<!-- Add package to export here -->
<Export-Package>
com.project.testlink.api,
</Export-Package>
<!-- Add package import here -->
<Import-Package>
org.springframework.osgi.*;resolution:="optional",
org.eclipse.gemini.blueprint.*;resolution:="optional",
*
</Import-Package>
<!-- Ensure plugin is spring powered -->
<Spring-Context>*</Spring-Context>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
<version>1.2.6</version>
<executions>
<execution>
<goals>
<goal>atlassian-spring-scanner</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<scannedDependencies>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-external-jar</artifactId>
</dependency>
</scannedDependencies>
<verbose>false</verbose>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<confluence.version>5.10.2</confluence.version>
<confluence.data.version>5.10.1</confluence.data.version>
<amps.version>6.2.4</amps.version>
<plugin.testrunner.version>1.2.3</plugin.testrunner.version>
<atlassian.spring.scanner.version>1.2.6</atlassian.spring.scanner.version>
<!-- This key is used to keep the consistency between the key in atlassian-plugin.xml and the key to generate bundle. -->
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
</properties>
</project>
答案 0 :(得分:0)
问题解决了。
为here
等依赖项添加了“排除”之后我必须从 .jar 文件中删除 SAXParsers 类,现在它可以正常工作:)
问题是您正在使用的Apache XML-RPC客户端库有很多其他依赖项,它们会在您编译时捆绑到您的插件中,并且它们与JIRA中已经提供的库冲突。