|
Replies:
31
-
Pages:
3
[
1
2
3
| Next
]
-
Last Post:
Jun 19, 2009 9:42 PM
Last Post By: David Peterson ...
|
|
|
Posts:
30
Registered:
10/28/08
|
|
|
|
REST api
Posted:
May 7, 2009 2:46 PM
|
|
|
Hi,
I'm working on a plugin that exposes resources through a REST api, taking instructions from http://confluence.atlassian.com/display/DEVNET/REST+Plugin+Module+Type. I have decorated a class with the right JAX-RS annotations, and added this part to my atlassian-plugin.xml:
<rest name="restful Hello" key="helloWorldRest" path="/helloworld" version="1.0">
<description>Provides hello world services.</description>
</rest>
The Plugin Manager in Confluence (3.0-m9-r2) shows my plugin, in which several modules are enabled. Only the "restful Hello" module us disabled, with the message:
Error: Support for this module is not currently installed.
What do I need to do to install support for a REST api?
|
|
Posts:
93
Registered:
01/07/07
|
|
|
|
Re: REST api
Posted:
May 7, 2009 7:24 PM
in response to: Paul Bakker
|
|
|
Hi Paul,
you will need to install the REST plugin. It is not bundled by default with Confluence (yet). The REST plugin itself has some dependencies that need to be installed as plugins. The page at https://studio.atlassian.com/wiki/display/REST/Installing+the+REST+module describes what you need to install. SAL is already bundled as part of Confluence so you don't need to worry about it.
SaM
|
|
Posts:
855
Registered:
03/07/04
|
|
|
|
Re: REST api
Posted:
May 7, 2009 7:30 PM
in response to: Samuel Le Berri...
|
|
|
By "SAL is already bundled with Confluence", Sam means "Confluence 3.0 will bundle all the pre-requisites required by the REST plugin, but it's not compatible with Confluence 2.10."
Hope this clears things up.
C
|
|
Posts:
30
Registered:
10/28/08
|
|
|
|
Re: REST api
Posted:
May 8, 2009 12:22 AM
in response to: Samuel Le Berri...
|
|
|
|
Hi Samuel,
The page you mentioned is behind a login for which I have no account and I cannot signup.
Is there another way for me to get the info and/or required packages?
Thanks,
Paul
|
|
Posts:
93
Registered:
01/07/07
|
|
|
Posts:
30
Registered:
10/28/08
|
|
|
|
Re: REST api
Posted:
May 8, 2009 8:01 AM
in response to: Samuel Le Berri...
|
|
|
Hi Samuel,
Thanks for the quick reply. I have installed all four jars. I cannot get the REST interface working though.
Could you have a look at how I configured it and maybe suggest what is missing?
My atlassian-plugin.xml looks like:
<atlassian-plugin key="${atlassian.plugin.key}" name="Attachments Server" pluginsVersion="2">
....
<rest key="helloWorldRest" path="/helloworld" version="1">
<description>Provides hello world services.</description>
</rest>
....
</atlassian-plugin>
I have an action class ExampleMacro:
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.ext.Provider;
import com.atlassian.confluence.core.ConfluenceActionSupport;
....
@Provider
public class ExampleMacro extends ConfluenceActionSupport
{
....
@GET
@Produces("text/html")
@Path("/helloworld")
public String showHelloWorld() throws Exception {
return super.doDefault();
}
....
}
From the explanations in REST Plugin Module Type, I get the impression that this is all that's needed, but when I try to access the page via http://localhost:8080/confluence/rest/helloworld/1
I get Confluence's "Page Not Found" page. Have you got a setup like this working? Do you have an example?
Thanks!
|
|
Posts:
30
Registered:
10/28/08
|
|
|
|
Re: REST api
Posted:
May 8, 2009 9:34 AM
in response to: Paul Bakker
|
|
|
Oops, I failed to notice that I should access the page as
http://localhost:8080/confluence/rest/helloworld/1/resource
(After changing @Path("/helloworld") to @Path("resource") on the method).
Now I'm getting:
com.atlassian.plugin.servlet.util.LazyLoadedReference$InitializationException:
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
at com.atlassian.plugin.servlet.util.LazyLoadedReference.get(LazyLoadedReference.java:94)
at com.atlassian.plugin.servlet.DefaultServletModuleManager.getFilter(DefaultServletModuleManager.java:284)
.......
I read a workaround here that mentions specifying your own implementation of ResourceConfig, but in this case Confluence is in charge I'm afraid. Does anybody know how to tackle this?
|
|
Posts:
93
Registered:
01/07/07
|
|
|
|
Re: REST api
Posted:
May 8, 2009 6:43 PM
in response to: Paul Bakker
|
|
|
|
Hi Paul,
one question first. Do you bundle your resource class in your plugin? I mean you don't bundle it in one of its dependencies?
As you said it the ResourceConfig is not under your control here. The REST plugin takes care of that for you. For you information, the REST plugin will scan your plugin with a REST module for all classes annotated with @Provider or with @Path (@Path annotation on methods are detected as well). All classes found are "fed" to the ResourceConfig.
Having a second look at your class I see that it is both annotated with @Provider and @Path (on a method). The @Provider annotation is not necessary here and I am thinking that it could be why Jersey doesn't find it as a resource. According to the JAX-RS spec classes annotated with @Path (or one method at least with @Path) are resources and classes annotated with @Provider are considered providers.
Hope this all makes sense. Let me know how it goes, it is still early stages of the REST plugin so let us know anything you think we could do to make it even simpler to developers.
Thanks.
|
|
Posts:
30
Registered:
10/28/08
|
|
|
|
Re: REST api
Posted:
May 9, 2009 12:54 AM
in response to: Samuel Le Berri...
|
|
|
Hi Samuel,
I don't bundle the ResourceConfig in my plugin.
Removing the @Provider annotation doesn't change anything.
The full stacktrace is:
com.atlassian.plugin.servlet.util.LazyLoadedReference$InitializationException: com.sun.jersey.api.container.ContainerException:
The ResourceConfig instance does not contain any root resource classes.
at com.atlassian.plugin.servlet.util.LazyLoadedReference.get(LazyLoadedReference.java:94)
at com.atlassian.plugin.servlet.DefaultServletModuleManager.getFilter(DefaultServletModuleManager.java:284)
at com.atlassian.plugin.servlet.DefaultServletModuleManager.getFilters(DefaultServletModuleManager.java:166)
at com.atlassian.plugins.rest.module.servlet.DefaultRestServletModuleManager.getFilters(DefaultRestServletModuleManager.java:107)
at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:53)
at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:41)
at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:57)
at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
at com.atlassian.plugins.rest.module.servlet.RestServletUtilsUpdaterFilter.doFilterInternal(RestServletUtilsUpdaterFilter.java:26)
at com.atlassian.plugins.rest.module.servlet.RestServletUtilsUpdaterFilter.doFilter(RestServletUtilsUpdaterFilter.java:40)
at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:57)
at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:55)
at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:41)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.atlassian.confluence.util.LoggingContextFilter.doFilter(LoggingContextFilter.java:46)
at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:31)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.atlassian.seraph.filter.SecurityFilter.doFilter(SecurityFilter.java:204)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.atlassian.seraph.filter.TrustedApplicationsFilter.doFilter(TrustedApplicationsFilter.java:120)
at com.atlassian.confluence.util.AbstractBootstrapHotSwappingFilter.doFilter(AbstractBootstrapHotSwappingFilter.java:30)
at com.atlassian.core.filters.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:31)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.atlassian.seraph.filter.BaseLoginFilter.doFilter(BaseLoginFilter.java:138)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:55)
at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:41)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.atlassian.confluence.util.ClusterHeaderFilter.doFilter(ClusterHeaderFilter.java:35)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.atlassian.gzipfilter.GzipFilter.doFilterInternal(GzipFilter.java:81)
at com.atlassian.gzipfilter.GzipFilter.doFilter(GzipFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:46)
at com.atlassian.confluence.extra.webdav.servlet.filter.AbstractHttpFilter.doFilter(AbstractHttpFilter.java:43)
at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:57)
at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:42)
at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:55)
at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:41)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.atlassian.core.filters.HeaderSanitisingFilter.doFilter(HeaderSanitisingFilter.java:44)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:613)
Caused by: com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
at com.sun.jersey.server.impl.application.WebApplicationImpl.processRootResources(WebApplicationImpl.java:607)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:480)
at com.atlassian.plugins.rest.module.RestDelegatingServletFilter$JerseyOsgiServletContainer.initiate(RestDelegatingServletFilter.java:198)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:433)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:167)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:323)
at com.atlassian.plugins.rest.module.RestDelegatingServletFilter.init(RestDelegatingServletFilter.java:102)
at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.init(DelegatingPluginFilter.java:43)
at com.atlassian.plugin.servlet.DefaultServletModuleManager$LazyLoadedFilterReference.create(DefaultServletModuleManager.java:328)
at com.atlassian.plugin.servlet.DefaultServletModuleManager$LazyLoadedFilterReference.create(DefaultServletModuleManager.java:313)
at com.atlassian.plugin.servlet.util.LazyLoadedReference$1.call(LazyLoadedReference.java:62)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
at java.util.concurrent.FutureTask.run(FutureTask.java:123)
at com.atlassian.plugin.servlet.util.LazyLoadedReference.get(LazyLoadedReference.java:74)
... 63 more
I've experimented with
@GET
@Produces("text/html")
@Path("/list")
public String listAttachments() throws Exception {
Page page = pageManager.getPage(this.pageId);
this.dataMap = getDataMap(page);
System.err.println("Have pageId [" + this.pageId + "]");
return super.doDefault();
}
@GET
@Produces("text/plain")
@Path("/hellotext")
public String showHelloWorldText() throws Exception {
return "Hello World";
}
|
|
Posts:
93
Registered:
01/07/07
|
|
|
|
Re: REST api
Posted:
May 10, 2009 6:52 PM
in response to: Paul Bakker
|
|
|
Hi Paul,
I am assuming you are using JDK 6. Can you try running Confluence with JDK 5 and let me know how it goes? If you confirm that it works using JDK 5, then adding this bundle-instruction element to your atlassian-plugin.xml should make it work with JDK 6.
<plugin-info>
...
<bundle-instruction>
<Import-Package>javax.xml.bind*;version="2.1.0",*</Import-Package>
</bundle-instruction>
...
</plugin-info>
More information about in the Plugins framework documentation. There is also an entry in the FAQ that can be useful to you.
What I believe is happening is that JDK 6 and the REST plugin are both exporting JAXB (it is not present in JDK 5). As you may already know Plugins 2 is based on OSGi. The REST plugin and your plugin don't import JAXB from the same bundle and so when scanning for annotation the ones from the REST module and your plugin are not equal being loaded by 2 different classloaders. Explicitly setting the version of JAXB you want to use will ensure that your plugin imports the version exported by the REST plugin. I hope this makes sense.
Edited by: Samuel Le Berrigaud Atlassian on May 11, 2009 9:52 AM
|
|
Posts:
6
Registered:
05/11/09
|
|
|
|
Re: REST api
Posted:
May 11, 2009 4:00 AM
in response to: Paul Bakker
|
|
|
Hi,
i am also trying to create a simple REST interface for Confluence 2.10.2. Unfortunately I already get errors when I try to install the jars you attached to this thread. Do I need other jars for 2.10.2. And if yes, where can I download those? Searching for confluence plugins is really confusing. Some are not listed in the plugin repository. (The repository even does not work in my 2.10.2. debug confluence version). Some plugins don't even tell you, why they can't be installed, which dependencies are missing...  Really frustrating.
I thought maven should care about the dependencies. So why doesn't it work, when I add the dependency
<dependency>
<groupId>com.atlassian.plugins.rest</groupId>
<artifactId>atlassian-rest-module</artifactId>
<version>1.0.0.rc2</version>
</dependency>
to my plugin? Why does it have to be installed to the confluence instance, too?
Does someone have a simple sample plugin implementation for the REST interface, so that I can see what I did wrong?
thanks,
Guido
|
|
Posts:
30
Registered:
10/28/08
|
|
|
|
Re: REST api
Posted:
May 11, 2009 4:45 AM
in response to: Samuel Le Berri...
|
|
|
Hi Samuel,
I am already using JDK 5.
I tried several things:
I went to java 1.6 and included the bundle-instruction in atlassian-plugin.xml.
It didn't work.
Now, I'm back at java 1.5 and removed the bundle-instruction.
Here is some more information about my project setup and environment.
Can you have a look? Maybe you see something wrong.
My project's Maven pom file:
<?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">
<parent>
<groupId>com.atlassian.confluence.plugin.base</groupId>
<artifactId>confluence-plugin-base</artifactId>
<version>22</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.sourcesense.restaccess</groupId>
<artifactId>attachmentsclient</artifactId>
<version>1.0-SNAPSHOT</version>
<name><!-- TODO: Add a name for your plugin --></name>
<packaging>atlassian-plugin</packaging>
<properties>
<atlassian.plugin.key>com.sourcesense.restaccess.attachmentsclient</atlassian.plugin.key>
<atlassian.product.version>3.0-m9-r2</atlassian.product.version>
<atlassian.product.test-lib.version>1.4.1</atlassian.product.test-lib.version>
<atlassian.product.data.version>2.10</atlassian.product.data.version>
<jersey-version>1.0</jersey-version>
</properties>
<dependencies>
<dependency>
<groupId>org.randombits.confluence</groupId>
<artifactId>confluence-conveyor</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>com.sun.grizzly</groupId>
<artifactId>grizzly-servlet-webserver</artifactId>
<version>1.9.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Targeting 1.5 -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Here is a summary from my Tomcat's manager page.
Server Information
Tomcat Version JVM Version JVM Vendor OS Name OS Version OS Architecture
Apache Tomcat/6.0.18 1.5.0_16-b06-284 Apple Inc. Mac OS X 10.5.6 i386
Here is my atlassian-plugin.xml again (it was refactored a bit).
<atlassian-plugin key="${atlassian.plugin.key}" name="Attachments Client" pluginsVersion="2">
<plugin-info>
<description>Plugin that exposes a REST interface to Confluence attachments</description>
<version>1.0</version>
<vendor name="Sourcesense" url="http://www.sourcesense.com"/>
</plugin-info>
<web-item key="listAttachments" name="List attachments" section="system.content.action" weight="20">
<label key="List attachments" />
<link>/pages/attachments/list.action?pageId=$helper.page.id&spaceKey=$helper.space.key</link>
<icon height="16" width="16">
<link>/images/icons/attach_16.png</link>
</icon>
</web-item>
<listener name='Action Conveyor' class='org.randombits.confluence.conveyor.ConveyorListener' key='actionConveyor'>
<description>Sets up the action conveyor for this plugin.</description>
</listener>
<rest name="List Attachments" key="list.attachments" path="/attachments" version="1">
<description>REST interface to a list of attachments.</description>
</rest>
</atlassian-plugin>
|
|
Posts:
93
Registered:
01/07/07
|
|
|
|
Re: REST api
Posted:
May 12, 2009 2:22 AM
in response to: Guido
|
|
|
|
Hi Guido,
as Charles mentioned earlier in this thread, the REST module is not compatible with Confluence 2.x. It will be compatible with Confluence 3.0 and you can now try using it against the milestones as Paul is trying to do.
Regards,
SaM
|
|
Posts:
6
Registered:
05/11/09
|
|
|
|
Re: REST api
Posted:
May 12, 2009 2:38 AM
in response to: Samuel Le Berri...
|
|
|
Ups... sorry. That makes everything a little bit more clear 
half of the weekend -> trash can ... should read more carefully.
I will try it again soon.
cu,
Guido
|
|
Posts:
93
Registered:
01/07/07
|
|
|
|
Re: REST api
Posted:
May 12, 2009 3:31 AM
in response to: Samuel Le Berri...
|
|
|
|
Hi Paul,
I think I figured out what could be wrong with your config. The class with the @Path annotation should be annotated at the class level with @Path. Or at least there should be one. That's what Jersey calls a root resource.
Srry for not spotting that before, I tried it locally and was able to reproduce the same error message and putting the annotation on class (rather than on the method) fixed it.
SaM
|
|
|
Legend
|
|
Genius: 1000
- 10000
pts
|
|
Expert: 500
- 999
pts
|
|
Guide: 250
- 499
pts
|
|
Enthusiast: 50
- 249
pts
|
|
Newbie: 5
- 49
pts
|
|
Atlassian Employee
|
|
Atlassian Partner
|
|
Helpful Answer
(5 pts)
|
|
Correct Answer
(10 pts)
|
|