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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Use of a thirdparty jar which used ServiceLoader to load some dependent services not working

I am trying to develop a bamboo task for one of my project. The purpose of this jar is to parse the working directory and create a JSON output. For this purpose, I have also developed a java library which will take the working directory as input and provide a parsed output in JSON. Now, this java library uses java's ServiceLoader to load some dependent service classes. Independently, this library works as expected and loads all the dependencies and does its work. However, on using this library as a third party lib in the plugin, the library is not loading the dependent classes. In some post i saw the loading classes in  atlassian sdk is triky. Please advise what I am doing wrong or missing. 

the pom at the pluging:

 <dependency>
<groupId>com.abd.plug</groupId>
<artifactId>buildInspLib</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>



 

The dependencies which would be loaded by serviceLoader at the pom at the buildIspLib: 

 

 <dependency>
<groupId>com.abd.parser</groupId>
<artifactId>parser1</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>com.abd.parser</groupId>
<artifactId>parser2</artifactId>
<version>1</version>
</dependency>

 

The code to load the service implementations. the buildInspLib has the META-INF directory which has the file with the implementing classes in it. Please note, this library works as expected if run outside of the atlassian sdk

//loads all the classes implementing ParserService
ServiceLoader<ParserService> loader = ServiceLoader.load(ParserService.class);

ExecutorService exec = Executors.newCachedThreadPool();

List<Future<ComputedData>> analysersOutput = new ArrayList<>();

System.out.println(" before distribution.."); //THIS LINE GETS PRINTED IN THE PLUGIN

for (ParserService serv : loader) {

try {

System.out.println(" distributing for : "+serv.getAnalyserType()+" );
//THIS LINE NEVER GETS PRINTED IN THE PLUGIN
....

...

How am I using this thirdparty lib?

new ParserInspector().inspect(taskContext.getWorkingDirectory().getAbsolutePath())

Please note: the library is being loaded. I can say that because, i could see the logs being printed. However, the service loader is not able to find the implementation classes  

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 7.1 is here and is packed with value!

I'm happy to announce that Bamboo 7.1 has been released and it’s overflowing with awesome new features. Top-voted issues First and foremost, a bunch of JAC top voted issues has been delivered - y...

694 views 1 6
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you