1
WebResourceDataProviderを提供設定に使用すると問題が発生します。すべて手動で作成されます。https://developer.atlassian.com/docs/advanced-topics/adding-data-providers-to-your-pluginしかし、ページを開くときにクラッシュします。奇妙なバグですJIRAプラグインjsonリソース:com.atlassian.json.marshal.Jsonableにキャストできません
package com.company.plugins.sestit.settings;
import com.atlassian.json.marshal.Jsonable;
import com.atlassian.webresource.api.data.WebResourceDataProvider;
import com.google.gson.Gson;
import java.io.IOException;
import java.io.Writer;
/**
* Provides plugin settings data as downloadable web resource.
*/
public class PluginSettingsDataProvider implements WebResourceDataProvider
{
public Jsonable get() {
return new Jsonable() {
public void write(Writer writer) throws IOException {
String[] strings = {"abc", "def", "ghi"};
writer.write(new Gson().toJson(strings));
}
};
}
}
<web-resource name="Resources" key="resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<data key="settings" class="com.company.plugins.sestit.PluginSettingsDataProvider" />
<context>atl.general</context>
</web-resource>
[INFO] [talledLocalContainer] Caused by: java.lang.ClassCastException: ccom.company.plugins.sestit.settings.PluginSettingsDataProvider$1 cannot be cast to com.atlassian.json.marshal.Jsonable
[INFO] [talledLocalContainer] at com.atlassian.plugin.webresource.PluginResourceLocatorImpl$1.apply(PluginResourceLocatorImpl.java:219)
[INFO] [talledLocalContainer] at com.atlassian.plugin.webresource.PluginResourceLocatorImpl$1.apply(PluginResourceLocatorImpl.java:215)
[INFO] [talledLocalContainer] at com.google.common.collect.Iterators$8.next(Iterators.java:812)
[INFO] [talledLocalContainer] at com.google.common.collect.Iterators.addAll(Iterators.java:356)
<?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.company.plugins.sestit</groupId>
<artifactId>sestit</artifactId>
<version>0.0.1</version>
<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>
<name>sestit</name>
<description>This is</description>
<packaging>atlassian-plugin</packaging>
<dependencies>
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<!-- Add dependency on jira-core if you want access to JIRA implementation classes as well as the sanctioned API. -->
<!-- This is not normally recommended, but may be required eg when migrating a plugin originally developed against JIRA 4.x -->
<!--<!–-->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-core</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
<!--–>-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</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>
<dependency>
<groupId>com.atlassian.templaterenderer</groupId>
<artifactId>atlassian-template-renderer-api</artifactId>
<version>1.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.sal</groupId>
<artifactId>sal-api</artifactId>
<version>2.10.16</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>
<!-- Uncomment to use TestKit in your project. Details at https://bitbucket.org/atlassian/jira-testkit -->
<!-- You can read more about TestKit at https://developer.atlassian.com/display/JIRADEV/Plugin+Tutorial+-+Smarter+integration+testing+with+TestKit -->
<!--
<dependency>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-client</artifactId>
<version>${testkit.version}</version>
<scope>test</scope>
</dependency>
-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-jira-plugin</artifactId>
<version>${amps.version}</version>
<extensions>true</extensions>
<configuration>
<productVersion>${jira.version}</productVersion>
<productDataVersion>${jira.version}</productDataVersion>
<!-- Uncomment to install TestKit backdoor in JIRA. -->
<!--
<pluginArtifacts>
<pluginArtifact>
<groupId>com.atlassian.jira.tests</groupId>
<artifactId>jira-testkit-plugin</artifactId>
<version>${testkit.version}</version>
</pluginArtifact>
</pluginArtifacts>
-->
<enableQuickReload>true</enableQuickReload>
<enableFastdev>false</enableFastdev>
<jvmArgs>-Dplugin.resource.directories=/src/main/resources</jvmArgs>
<pluginArtifacts>
<pluginArtifact>
<groupId>com.atlassian.labs.plugins</groupId>
<artifactId>quickreload</artifactId>
<version>${quick.reload.version}</version>
</pluginArtifact>
</pluginArtifacts>
<!-- 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.company.plugins.sestit.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>
<jira.version>6.4.11</jira.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>
<!-- TestKit version 6.x for JIRA 6.x -->
<testkit.version>6.3.11</testkit.version>
<quick.reload.version>1.30.2</quick.reload.version>
</properties>
</project>
POMを投稿できますか? –
@ScottDudley、投稿 – avengerweb
ここで問題を再現しようとしましたが、エラーなしで私のために働いていました。 [MVCE](http://stackoverflow.com/help/mcve)を作成できますか?あなたのメソッドから返された匿名クラスは明らかにJsonableを実装していますが、あなたのプラグインのJsonableクラスがJIRAが使用するものとは異なるクラスローダーからロードされていると思われます。メソッド内にブレークポイントを設定し、Jsonable.classがどこから来るかを調べることができます。また、これはあなたの問題とは何の違いもありませんが、JIRA 6.4にはすでにCP上にGSONが含まれていますので、POMに依存関係に ' 'を追加することができます。 –