Package com.atlassian.confluence does not exist

Hi, I’ve been trying to develop a small REST API plugin to expose some functions from com.atlassian.confluence.spaces, com.atlassian.confluence.security, and com.atlassian.confluence.user from the Java API. When running atlas-run, I’m getting the error message “package com.atlassian.confluence does not exist” for each of these imports.

My pom.xml includes the following dependency, and the rest of the pom.xml is just the generated pom.xml created when running atlas-create-confluence-plugin and selecting a REST API plugin:

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

What could I missing?

Did you run the mvn install command to source the confluence dependency and add it to your local ~/.m2 folder? What was the output of that command? com.atlassian.confluence being missing when you try to run the plugin suggests that the dependency hasn’t been satisfied to complile your plugin successfully.

I’ve run atlas-mvn install, it runs fine until compile stage, where it fails out saying the same “package com.atlassian.confluence does not exist”. My local m2 folder has .m2\repository\com\atlassian\confluence and other atlassian dependencies populated, and everything seems to be there.

I’ve run atlas-mvn install, it runs fine until compile stage, where it fails out saying the same “package com.atlassian.confluence does not exist”. My local m2 folder has .m2\repository\com\atlassian\confluence and other atlassian dependencies populated, and everything seems to be there.

I realized I put this as a post reply, instead of a reply to you directly.

Hi @DanielFernow

The problem you’re having sounds strange to me, I’m not sure what could be causing it. Have you tried to reproduce the problem with a simple “hello world” style plugin to see if there is anything specific to your plugin’s pom or atlassian-plugin.xml that might be causing this?

If you are comfortable sharing your code, I could try running it on my machine to see if I get the same problem?

I realized I put this as a post reply, instead of a reply to you directly.

No problem! I find the threading on this forum to be very confusing :slight_smile:

Hi Joe, I’ve reproduced it on a “hello world” plugin generated by following this tutorial’s first few steps, substituting refapp for confluence. The plugin built fine, and then I added just the line “import com.atlassian.confluence.spaces” to MyRestResource.java. The pom.xml was generated with com.atlassian.confluence as a dependency. I’m a “new user” so I’m unable to upload any attachments to my comments, apparently, but I can copy/paste the body of my “MyRestResource.java” (the only file I changed from the generated confluence rest API module) and “pom.xml” files:

pom.xml

<?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.atlassian.plugins.tutorial</groupId>
    <artifactId>Message</artifactId>
    <version>1.0</version>
    <organization>
        <name>Example Company</name>
        <url>http://www.example.com/</url>
    </organization>
    <name>Message</name>
    <description>This is the com.atlassian.plugins.tutorial:Message plugin for Atlassian Confluence.</description>
    <packaging>atlassian-plugin</packaging>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence</artifactId>
            <version>${confluence.version}</version>
            <scope>provided</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>
        <!-- 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>
        <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.3.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.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.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.8.5</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>confluence-maven-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${confluence.version}</productVersion>
                    <productDataVersion>${confluence.data.version}</productDataVersion>
                    <enableQuickReload>true</enableQuickReload>
                    <!-- 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.atlassian.plugins.tutorial.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>${atlassian.spring.scanner.version}</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>
        <confluence.version>6.14.0</confluence.version>
        <confluence.data.version>6.14.0</confluence.data.version>
        <amps.version>8.0.2</amps.version>
        <plugin.testrunner.version>2.0.1</plugin.testrunner.version>
        <atlassian.spring.scanner.version>1.2.13</atlassian.spring.scanner.version>
        <!-- This property ensures consistency between the key in atlassian-plugin.xml and the OSGi bundle's key. -->
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

MyRestResource.java

package com.atlassian.plugins.tutorial.rest;

import com.atlassian.plugins.rest.common.security.AnonymousAllowed;

import com.atlassian.confluence.spaces;

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 World")).build();
    }
}

I wasn’t able to reproduce the problem with the pom and REST resource class you provided.

I did get this error trying to run the package command:

[ERROR] /Users/jclark/Dev/atlassian/test-confluence-plugin/src/main/java/com/atlassian/plugins/tutorial/api/MyRestResource.java:[4,32] cannot find symbol
  symbol:   class spaces
  location: package com.atlassian.confluence

Which is a different error to yours. I fixed this problem by changing import com.atlassian.confluence.spaces; to import com.atlassian.confluence.spaces.*;

Which tutorial are you following and which version of the atlassian plugin SDK do you have installed?

This tutorial: https://developer.atlassian.com/server/framework/atlassian-sdk/developing-a-rest-service-plugin/

SDK version 8.0.16.

And yeah, as expected, changing to match your line still yielded my error, not yours.

Something else you could try is deleting everything from ~/.m2/repository/com/atlassian and trying to download all the dependencies again. Perhaps the Confluence jar was corrupted on download? If you do this, you could share the build log from running atlas-mvn install to see if there are any errors we can debug.