Why is a Bamboo CustomBuildCompleteAction implementation in my plugin unable to be cast?

I have been trying to develop a plugin which implements the Bamboo CustomBuildCompleteAction module.

I wish to trace my plugin code using IDEA and have started the Bamboo instance from the command line - atlas-debug --product bamboo. Running IDEA in debug mode informs me that it has successfully connected the debug port.

Having placed a breakpoint at the first line of code in my override of the CustomBuildCompleteAction.run() method, I would expect to see it triggered upon successful completion of a manually triggered build. However I do not. Instead, I see in the Bamboo .log the following:

ERROR [AtlassianEvent::0-BAM::EVENTS:pool-2-thread-13] [NamedThreadFactory] Uncaught exception in thread AtlassianEvent::0-BAM::EVENTS:pool-2-thread-13

java.lang.ClassCastException: co.nz.xxxxx.bamboo.plugins.PostBuildCompleteNotifier cannot be cast to com.atlassian.bamboo.build.CustomPostBuildCompletedAction

Can anyone assist me to resolve this? What do I need to add/modify to ensure that my implementation of the CustomPostBuildCompletedAction is cast-able?

2 answers

1 accepted

This widget could not be displayed.

The cause of my problem was right there in the exception message and was staring me in the face:

"PostBuildCompleteNotifier cannot be cast to com.atlassian.bamboo.build.CustomPostBuildCompletedAction".

I had implemented the CustomPostBuildComplete interface...

public PostBuildCompleteNotifier implements CustomPostBuildCompleteAction

..but had declared the postBuildCompletedAction module in atlassian-plugin.xml:

<postBuildCompletedAction .../>

Silly boy - RTFM!

This widget could not be displayed.

Investigating this a bit further, I have added a constructor to my plugin to confirm that debugging is actually working. Here is the code, and the constructor definitely does get hit.

public class TestCompleteBuildAction implements CustomBuildCompleteAction

{

public TestCompleteBuildAction()

{

String _text = "constructor got hit";// <-- breakpoint here definitely fires

}

@Override

public void run(Buildable buildable, BuildResults buildResults)

{

String _text = buildable.getBuildKey();// <--breakpoint here does not.

}

}

The stack trace in the ERROR shows that the PostBuildCompletedEventsListener appears to be the class that is trying to cast my class (complete log entry follows):

ERROR [AtlassianEvent::0-BAM::EVENTS:pool-2-thread-12] [NamedThreadFactory] Uncaught exception in thread AtlassianEvent::0-BAM::EVENTS:pool-2-thread-12

java.lang.ClassCastException: co.nz.xxxxxx.bamboo.plugins.TestCompleteBuildAction cannot be cast to com.atlassian.bamboo.build.CustomPostBuildCompletedAction

at com.atlassian.bamboo.v2.build.events.PostBuildCompletedEventListener$1.run(PostBuildCompletedEventListener.java:67)

at com.atlassian.bamboo.variable.CustomVariableContextRunnerImpl.execute(CustomVariableContextRunnerImpl.java:27)

at com.atlassian.bamboo.v2.build.events.PostBuildCompletedEventListener.performAction(PostBuildCompletedEventListener.java:54)

...

Unfortunately, still no closer to understanding why ClassCastException is being thrown. Any assistance gratefully received.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

165 views 2 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you