Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to component import with spring scanner?

Hi everyone,

So I am now working on the posting notifications in confluence tutorial. Which can be found here . I've run into many many issues along the way. Now I am wondering how I would component import with the spring scanner. I've read about the spring scanner stuff but I am still unsure if I am doing it right. You see in the tutorial they say to put this line  in the atlasssian-plugin.xml 

<component-import key="notificationService" interface="com.atlassian.mywork.service.LocalNotificationService"/>

 but when I do that I get an error that states:

atlassian-plugin.xml contains a definition of component-import. This is not allowed when Atlassian-Plugin-Key is set.

 Based off of what I've read I edited my to look like this

package com.example.plugins.tutorial.confluence.notification.resource;

import java.util.concurrent.ExecutionException;

import javax.annotation.Nullable;
import org.springframework.stereotype.Scanned;

import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;
import com.atlassian.confluence.user.UserAccessor;
import com.atlassian.mywork.model.Notification;
import com.atlassian.mywork.model.NotificationBuilder;
import com.atlassian.mywork.service.LocalNotificationService;
import com.atlassian.user.impl.DefaultGroup;

* A resource of creating and listing notifications
@Path ("/")
@Consumes (MediaType.APPLICATION_JSON)
@Produces (MediaType.APPLICATION_JSON)
public class NotificationResource {
private final LocalNotificationService notificationService;
private final UserAccessor userAccessor;
private final PermissionManager permissionManager;

public NotificationResource(final LocalNotificationService notificationService, final UserAccessor userAccessor, final PermissionManager permissionManager) {
this.notificationService = notificationService;
this.userAccessor = userAccessor;
this.permissionManager = permissionManager;
public Response createNotification(@FormParam ("title") String title, @FormParam ("message") String message)
throws Exception {
if (isAdmin()) {
sendNotificationToAllUsers(title, message);
return Response.ok().build();
else {
return Response.status(Response.Status.FORBIDDEN).build();
@Produces (MediaType.APPLICATION_JSON)
public Response findAllNotifications() throws Exception{
if (isAdmin()){
// TODO add code to list past notifications sent by this plugin
return Response.ok().build();
return Response.status(Response.Status.FORBIDDEN).build();
private boolean isAdmin(){
return permissionManager.isConfluenceAdministrator(AuthenticatedUserThreadLocal.getUser());

* Create a single notification and send it to user
* @param user the user who will receive the notification
* @param title the title of the notification
* @param message the body of the notification
* @return the created notification
* @throws InterruptedException
* @throws ExecutionException
private Notification sendNotification(final String user, final String title, final String message) throws InterruptedException, ExecutionException{
Notification notification = notificationService.createOrUpdate(user, new NotificationBuilder()
.application("${project.groupId}.${project.artifactId}") // a unique key that identifies your plugin
.title("Message from your beloved administrator")
.groupingId("com.example.plugins.tutorial.confluence.notification") // a key to aggregate notifications
return notification;

* Iterate on all users of the "confluence-users" group and send a notification to each of them
* @param title the title of the notification to sen
* @param message the body of the notification to send
* @throws ExecutionException
* @throws InterruptedException
private void sendNotificationToAllUsers(final String title, final String message)
throws ExecutionException, InterruptedException {
Pager<String> memberNames = userAccessor.getMemberNames(new DefaultGroup(UserAccessor.GROUP_CONFLUENCE_USERS));
for (String memberName : memberNames) {
sendNotification(memberName, title, message);


 Any help would be greatly appreciated. Thank you for your time. 

1 answer

@Diana Bianco have you solved it? I am in the same situation.

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events