Hi, I am migrating confluence 6x to 9.2.7, But I am facing too many dependency issues in my current code base. So could you please suggest what and all dependencies should be used
That’s quite a broad question and it’s hard to give any specific advice on what dependencies you need (as dependencies are often app specific)
One suggestion might be to create a blank application (atlas-create-confluence-plugin) using the latest version of the SDK (>=9.1.1) and see what dependencies are in a standard, empty application as a starting point.
Then add in any dependencies that are specific to your app.
Another thing you can do is use dependencyManagement in your pom.xml like this, at it brings in all of the correct dependency versions for the target version:
<dependencyManagement>
<dependencies>
<dependency> <groupId>com.atlassian.confluence</groupId>
<artifactId>confluence-plugins-platform-pom</artifactId> <version>${confluence.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
I hope this helps.
Thank you for your valuable response. Could you please confirm which spring-scanner version I should use and either jakarta or javax, Currently I am changing the dependency injection of the whole codebase and I am using @Named and @Inject annotations, but I am getting the error like there is no bean defined. Please help me out on this
In our case, we’re using spring-scanner 3.0.3, and for Confluence 9.x and earlier we use javax.
For Confluence 10.x you will need to use jakarta.
Here’s an excerpt from our pom.xml that we use for Confluence 9.x
<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.atlassian.confluence</groupId>
<artifactId>confluence-plugins-platform-pom</artifactId>
<version>${confluence.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.atlassian.confluence</groupId>
<artifactId>confluence</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.plugin</groupId>
<artifactId>atlassian-spring-scanner-annotation</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.upm</groupId>
<artifactId>licensing-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.upm</groupId>
<artifactId>upm-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.sal</groupId>
<artifactId>sal-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.atlassian.templaterenderer</groupId>
<artifactId>atlassian-template-renderer-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<scope>provided</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>
<compressResources>false</compressResources>
<enableQuickReload>true</enableQuickReload>
<server>localhost</server>
<jvmArgs>-Xms1g -Xmx2g -XX:-UseGCOverheadLimit -server</jvmArgs>
<instructions>
<Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
<Export-Package>net.oharagroup.confluence.plugins.api,</Export-Package>
<!--
!java.* is needed here to suppress 'Importing java.* packages not allowed'
in OSGI Core 6. We can safely remove this once we drop support for Confluence 7.x,
and revert back to <Import-Package>*</Import-Package>
(ref: https://bnd.bndtools.org/instructions/noimportjava.html)
-->
<Import-Package>!java.*,*</Import-Package>
<Spring-Context>*</Spring-Context>
<Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>
</instructions>
<systemPropertyVariables>
<atlassian.darkfeature.site-wide.synchrony.opt-in.disable>true</atlassian.darkfeature.site-wide.synchrony.opt-in.disable>
<atlassian.darkfeature.site-wide.shared-drafts.disable>true</atlassian.darkfeature.site-wide.shared-drafts.disable>
</systemPropertyVariables>
</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>
<verbose>false</verbose>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<confluence.version>9.5.4</confluence.version>
<confluence.data.version>9.5.4</confluence.data.version>
<amps.version>9.4.1</amps.version>
<atlassian.spring.scanner.version>3.0.3</atlassian.spring.scanner.version>
<atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
</project>
I should note that we don’t consider ourselves experts in Java, so take the above as an example of a pom that works, but not necessarily the best example.
Thank you so much
Hi, are you using javax.inject.Inject or jakarta? and also could you please explain how dependency injection is injected in your codebase like @Named or @Component etc
Hi @AkshayBhat ,
I’ve checked our apps and we’re not using @Named or @Component annotations specifically, but we are using @ComponentImport and @Inject like this:
import java.lang.SuppressWarnings;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import javax.inject.Inject;
import com.atlassian.sal.api.pluginsettings.PluginSettings;
import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory;
import com.atlassian.sal.api.transaction.TransactionCallback;
import com.atlassian.sal.api.transaction.TransactionTemplate;
import com.atlassian.sal.api.user.UserKey;
import com.atlassian.sal.api.user.UserManager;
import java.util.List;
@Path("/config")
public class ConfigResource
{
@ComponentImport
private final UserManager userManager;
@ComponentImport
private final PluginSettingsFactory pluginSettingsFactory;
@ComponentImport
private final TransactionTemplate transactionTemplate;
@Inject
public ConfigResource(UserManager userManager, PluginSettingsFactory pluginSettingsFactory,
TransactionTemplate transactionTemplate)
{
this.userManager = userManager;
this.pluginSettingsFactory = pluginSettingsFactory;
this.transactionTemplate = transactionTemplate;
}
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response get(@Context HttpServletRequest request)
{
...
Don’t know if that helps at all.
Hi, @scottohara , it helped me a lot, but I am facing the issue event listener, event is not triggering. So could you please share your snippet how you are using event listener in your plugin
Thanks,
Akshay
Hi @AkshayBhat,
I don’t think we have any event listeners in our app, unfortunately.
Hi, @scottohara , ok but could you check are using any dependency like this in your pom.xml
com.atlassian.event
atlassian-event
5.0.0
provided
We don’t have that dependency in our pom.xml
Thanks for your kind support @scottohara
Thanks,
Akshay