Hello together,
again I'm really lost in jira plugin development. I tried to develop a rest service as written in the official docu. Here is my atlassian-plugin.xml:
<?xml version="1.0" encoding="UTF-8"?> <atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2"> [...] <rest name="My Rest Resource" i18n-name-key="my-rest-resource.name" key="my-rest-resource" path="/myrestresource" version="1.0"> <description key="my-rest-resource.description">The My Rest Resource Plugin</description> </rest> </atlassian-plugin>
My Java Class looks like this:
package de.rk.tools.jira.plugins.rest; import com.atlassian.plugins.rest.common.security.AnonymousAllowed; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; /** * A resource of message. */ @Path("/message") public class MyRestResource { @GET @AnonymousAllowed @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public Response getMessage() { return Response.ok(new MyRestResourceModel("Hello World2323")).build(); } }
I really don't know how to access this resource over an url. I've tried http://localhost:5990/refapp/rest/myrestresource/latest/message but only get an error page. I don't know if its important, but here my "deployment" process:
1. Run local jira with atlas-run-standalone --product jira
2. Build plugin jar with atlas-mvn clean install
3. Upload plugin into local jira.
Community moderators have prevented the ability to post new answers.
You're missing something in your REST url:
http://localhost:5990/refapp/rest/1.0/myrestresource/latest/message
Both URLs doesn' work at me. But my .pom seems to be incorrect. Here is the end of my project pom:
<properties> <jira.version>5.1.8</jira.version> <amps.version>4.1.5</amps.version> <plugin.testrunner.version>1.1</plugin.testrunner.version> </properties>
The end of the POM of the demoproject in the documentation for creating a rest resource looks like this:
<properties> <refapp.version>2.20.0-m2</refapp.version> <amps.version>4.1.5</amps.version> <plugin.testrunner.version>1.1</plugin.testrunner.version> </properties>
Which is correct? The only goal I wan't to achieve in my project is to create some Java objects and access these in the gadget.xml. How I can achieve this is not important for me. With my little knowledge building a REST resource and accessing it over AJAX seems to be a good way.
My "normal" working business is to write Java beans for this issues and register them using the spring framework ;). Developing a jira plugin is very difficult for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, my bad. The URL should be:
http://localhost:5990/refapp/rest/myrestresource/1.0/latest/message
Can you also confirm that the REST resource is enabled in the UPM?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No url is working :(. Is there a way to check which URLs are available? It seems to me, that I've forgotten something. Are there some other requirements to use own rest resources?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What error are you getting?
Can you also confirm that the REST resource is enabled in the UPM?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's a little bit frustrating. This URL works for me http://localhost:2990/jira/rest/myrestresource/1.0/message, but only once (don't mind about the other port). Problem is: I run "atlas-mvn (clean) install" and getting a jar, with my changes. I deploy it in my plugin manager, and all looks fine. All modules are active and the "My Rest Resource" and "Rest Servlet filter" is displayed as well. But if I reload the URL above i get a 404 again! Let me have a look in the log...
Hmm, seems interesting:
Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems: The import com.atlassian.plugins.rest cannot be resolved AnonymousAllowed cannot be resolved to a type at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:115) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877) ... 173 more Caused by: java.lang.Error: Unresolved compilation problems: The import com.atlassian.plugins.rest cannot be resolved AnonymousAllowed cannot be resolved to a type
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
From your latest error, you need to make sure that your plugin has all the available dependencies. The development and real version may have different dependencies set.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Seems, you are right. Calling multiple times "atlas-mvn clean", "atlas-mvn eclipse:clean" and "atlas-mvn eclipse:eclipse" solved the problem. Hope I can start work now. Thank for your help. I mark my question as answered.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This gave me fits for a while. But this worked:
Check your offending reference and comment back in.
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.