How to build a Rest plugin along with Confluence API?

Hi,
Can someone please help?!
I’m trying to develop a plugin which makes use of regular Confluence java API like PageManager, SpaceManager etc. along with the ability to get CRUD working using REST calls.
I followed https://developer.atlassian.com/server/framework/atlassian-sdk/developing-a-rest-service-plugin/ and got the Rest plugin working.
But, it doesn’t get me the Confluence Java API. So, I added :

       <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence</artifactId>
            <version>${confluence.version}</version>
            <scope>provided</scope>
        </dependency>

This breaks the Rest calls:
ERROR in logs:

[atlassian.plugin.servlet.DefaultServletModuleManager] getInstance Unable to create new reference LazyLoadedFilterReference{descriptor={}:my-rest-resource1-filter (Rest Resource Plugin), filterConfig=com.atlassian.plugin.servlet.filter.PluginFilterConfig@4d0b29c5}
com.atlassian.util.concurrent.LazyReference$InitializationException: com.sun.jersey.spi.inject.Errors$ErrorMessagesException
        at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:149)
        at com.atlassian.util.concurrent.LazyReference.get(LazyReference.java:112)
        at com.atlassian.plugin.servlet.DefaultServletModuleManager.getInstance(DefaultServletModuleManager.java:447)
        at com.atlassian.plugin.servlet.DefaultServletModuleManager.getFilter(DefaultServletModuleManager.java:440)
        at com.atlassian.plugin.servlet.DefaultServletModuleManager.getFilters(DefaultServletModuleManager.java:300)
        at com.atlassian.plugins.rest.module.servlet.DefaultRestServletModuleManager.getFilters(DefaultRestServletModuleManager.java:121)
        at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:68)
        at com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter.doFilter(ServletFilterModuleContainerFilter.java:58)
        at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter.doFilter(DelegatingPluginFilter.java:64)
        at com.atlassian.plugin.servlet.filter.IteratingFilterChain.doFilter(IteratingFilterChain.java:37)
        at com.atlassian.plugin.servlet.filter.DelegatingPluginFilter$1.doFilter(DelegatingPluginFilter.java:58)
        at com.atlassian.plugins.rest.module.servlet.RestServletUtilsUpdaterFilter.doFilterInternal(Rest
...
..

My guess is that the plugin skeleton you’re using is configured only with the maven-amps-plugin. You need to change that yo the maven-confluence-plugin, so that when you run atlas-debug or atlas-run, it will automatically launch Confluence instead of Refapp.

1 Like

Thanks for the response @richatkins!
I’m building this plugin using “atlas-mvn {clean} package”.
I have a confluence sand-box instance where I’m deploying this plugin.
The issue is that, something in the “com.atlassian.confluence.confluence” dependency which I’m adding on top of template pom.xml from that tutorial, is causing an exception while the Rest service is being run.
I need that dependency for a logic I’m trying to build in the plugin (to be able to use Page and Space Managers).
I need help in finding a way where both co-exist.

Hello, @sameer.v.

Checking the tutorial link you’ve provided, that’s for the refapp. To answer your initial question as to how to build a REST plugin along with Confluence API, here are the steps:

  1. Call atlas-create-confluence-plugin (instead of atlas-create-refapp-plugin)
  2. Once the project is created, go to the newly created directory
  3. Call atlas-create-confluence-plugin-module and select REST Plugin Module

If you haven’t done much with the refapp template you have yet, it might be worthwhile (or faster) starting with a Confluence template.

Cheers!
Ian

1 Like

Hi @iragudo,
Thanks for the hint. I used your steps to work it up from scratch. Finally got to the cause of the issue I was facing while comparing. And it’s rather lame :frowning:
I had a method in one of the classes with just '@Path(“something”) ’ and no @GET/@POST. I deleted that “@Path” in my old project and it started working.
Thanks for the helpful tips! Appreciate it!

1 Like