Atlassian Spring Scanner annotations not working with Confluence Blueprints

hello community, I was following this guide on creating advanced blueprints for Confluence Server. The last part of the guide implements a Java class that has an event listener, and the guide includes a couple component and component-import lines in the atlassian-plugin.xml

<component-import key="eventPublisher" interface="com.atlassian.event.api.EventPublisher"/>
<component key="eventListener" class="com.example.plugins.tutorial.confluence.simplebp.MyBlueprintListener"/>

I am aware that the Atlassian Spring Scanner does not use these component statements anymore and I have followed this documentation to replace them with proper annotations and remove the .xml import lines from atlassian-plugin.xml

With these annotations added when I enter the atlas-run command, the plugin is “loaded” however the blueprint does not appear in the Create(…) menu

However if I omit line 15 @Named("MyBlueprintListener") The blueprint appears again in the menu but the java class is not implemented, no log message is made.

For reference I am using Atlassian Spring Scanner 1 not 2 and I have double checked my dependencies in my pom.xml. The skeleton code for the blueprint was generated using atlas-create-confluence-plugin command

I am at a loss as to why this is not working. Any help would be appreciated.

Hi @nabil.babu,
this is a stripped version of an event listener for a custom event I wrote. It does not need a class annotation. Maybe you can find something useful in it:

public class ProfileViewListener implements Serializable{

	@Autowired
	private final ActiveObjects ao;

	@Autowired
	private final UserDetailsManager udm;

	private static final long serialVersionUID = -123456789L;

	@Inject
	public ProfileViewListener(@ComponentImport ActiveObjects ao, @ComponentImport UserDetailsManager udm){
		this.ao = checkNotNull(ao);
		this.udm = checkNotNull(udm);
	}

	@com.atlassian.event.api.EventListener
	public void ownProfileViewEvent(ProfileViewEvent event) {
		if(AuthenticatedUserThreadLocal.get() == null){
			return;
		}
	}			

I do not know what you are trying to achieve, but there is no need for the eventPublisher, if you do not want to publish another event yourself.

But here is another approach: Maybe your Java class is loaded, but the condition is not true. To check this, just insert System.out.println("hello"); to line 33 and look if something is happening.

Also try removing the ComponentImport and declaration of the event in line 23 and 24.

Best regards
Alex

Hey @alexander.botor Thanks for your reply,

I applied your suggested changes and I took a look at your code and added in and removed annotations . I also added in the “System.out.println” just to see if I got anything. Still nothing, the event isn’t being called at all, neither is the constructor. Here’s how it looks now

Thank you for your help.

In your pom.xml, what version of scanner (atlassian-spring-scanner-runtime, atlassian-spring-scanner-annotation) are you using? If you are unsure post the whole. Depending on its version, you should (or not) add @Scanned annotation to the class.

System.out.println is throwing stuff to catalina.out. Are you checking that file?

Since this is a LISTENER it has to be declared in the atlassian-plugin.xml e.g:

<listener name="signup-listener" key="signupListener" class="dk.xxxxxxxxx.dcimteam.socks.impl.listener.PictureListener"/>

On top of hat, you have an SLF4J logger, did you add the package in the Profiling And Logging section in the admin menu?

Hi @Panos
Thanks for your reply, currently I am running version 1.2.13 of the atlassian spring scanner version. I tried adding in the SLF4J logger to the Profiling and Logging section but I am using “atlas-run” to test my blueprint not a standalone staging instance of Confluece so my changes to the section do not carry over for each rebuild of the instance, so that also means I do not have a catalina.out file either, I’ll try to test this blueprint on a staging confluence server and see if I can get any log messages. I also tried adding in the listener declaration that you suggested and it resulted in the same result I have been seeing, the blueprint icon disappearing from the Create Menu.

The 1.2.13 version of spring scanner requires that you put @Scanned in your class.

That 99.9% means your plugin is not correctly installed