Hello,
I am trying to add an anonymous REST endpoint to my plug-in. I wrote tests for each level of exchanges (ut/it), and am currently testing the REST resource through org.apache.wink.client.RestClient, all inner-level tests being successful at this point:
package com.atlassian.tutorial.status; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import com.atlassian.plugins.rest.common.security.AnonymousAllowed; @Path("/status") public class RestResource { @GET @Path("/name") @AnonymousAllowed @Produces({ MediaType.APPLICATION_JSON }) public Response getName() { return Response.ok(new MyPluginComponentImpl(null).getName()).build(); } }
I implemented that per the tutorial and answers I found here and there. I checked my test server System Plug-ins, which is 6.1#6144, and found that atlassian-rest-module was provided under version 2.8.0-m8. So my pom.xml lists:
(...) <dependency> <groupId>com.atlassian.plugins.rest</groupId> <artifactId>atlassian-rest-module</artifactId> <version>${rest.version}</version> <scope>provided</scope> </dependency> (...) <properties> <jira.version>6.1</jira.version> <amps.version>5.0.13</amps.version> <plugin.testrunner.version>1.2.3</plugin.testrunner.version> <!-- TestKit version 5.x for JIRA 5.x, 6.x for JIRA 6.x --> <testkit.version>5.2.26</testkit.version> <rest.version>2.8.0-m8</rest.version> </properties> (...)
I have a few problems with the method I used to build this configuration:
I cannot use "2.8.0-m8" in the "dependency" block, else Maven downloads "2.8.0", following its strict version format, and fails. Maven succeeds when the indirect "rest.version" is used, but emits a warning about deprecation. I use Maven 3.2.1, so I assume this is more or less expected.
[WARNING] The property 'rest.version' is no longer usable to override the related bundled plugin. Use <pluginArtifacts> or <libArtifacts> to explicitly override bundled plugins and libraries, respectively.
When running atlas-integration-test, the JIRA test instance cannot start properly because atlassian-rest-module, which Maven downloaded, fails to start as a plug-in.
[INFO] [talledLocalContainer] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activator' defined in URL [bundle://116.0:0/META-INF/spring/atlassian-plugins-components.xml]: Invocation of init method failed; nested exception is com.sun.jersey.spi.service.ServiceConfigurationError: com.sun.jersey.spi.HeaderDelegateProvider: The class com.sun.jersey.core.impl.provider.header.LocaleProvider implementing provider interface com.sun.jersey.spi.HeaderDelegateProvider could not be instantiated: Cannot cast com.sun.jersey.core.impl.provider.header.LocaleProvider to com.sun.jersey.spi.HeaderDelegateProvider
So obviously I missed something. Initially, I thought that adding atlassian-rest-module as a dependency was weird, but understandable. In any case it should be "provided". Adding jira-core internals as a dependency does not fix anything, as expected.
So how should I configure my pom.xml to use the annotation "AnonymousAllowed"?
Community moderators have prevented the ability to post new answers.
Hi, Im having the same issue, were you able to solve it?
Thanks!
Hello, I have the same issue with the annotation "AnonymousAllowed", it cannot be imported in Eclipse.
I just created a plugin and a REST module using the atlas commands.
My pom.xml contains these dependencies about REST:
<dependency> <groupId>com.atlassian.plugins.rest</groupId> <artifactId>atlassian-rest-common</artifactId> <version>1.0.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.atlassian.plugins.rest</groupId> <artifactId>atlassian-rest-parent</artifactId> <version>2.9.8</version> <type>pom</type> </dependency>
Here is my complete pom:
<?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>sladi</groupId> <artifactId>jiplu</artifactId> <version>1.0.0-SNAPSHOT</version> <organization> <name>Example Company</name> <url>http://www.example.com/</url> </organization> <name>jiplu</name> <description>This is the sladi:jiplu plugin for Atlassian JIRA.</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> <!-- 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> --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.6.6</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>1.8.5</version> <scope>test</scope> </dependency> <dependency> <groupId>net.sourceforge.jtds</groupId> <artifactId>jtds</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.atlassian.plugins.rest</groupId> <artifactId>atlassian-rest-common</artifactId> <version>1.0.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.atlassian.plugins.rest</groupId> <artifactId>atlassian-rest-parent</artifactId> <version>2.9.8</version> <type>pom</type> </dependency> <dependency> <groupId>com.atlassian.sal</groupId> <artifactId>sal-api</artifactId> <version>2.6.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.wink</groupId> <artifactId>wink-client</artifactId> <version>1.1.3-incubating</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> --> </configuration> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> <properties> <jira.version>6.4.11</jira.version> <amps.version>5.1.16</amps.version> <plugin.testrunner.version>1.2.3</plugin.testrunner.version> <!-- TestKit version 6.x for JIRA 6.x --> <testkit.version>6.3.11</testkit.version> </properties> </project>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.