# Instantiate NavBuilder

**URL:** <https://community.developer.atlassian.com/t/instantiate-navbuilder/82023>\
**Category:** Bitbucket Server\
**Created:** [July 23, 2024, 7:13am UTC](https://community.developer.atlassian.com/t/instantiate-navbuilder/82023 "2024-07-23T07:13:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![a112](https://avatars.discourse-cdn.com/v4/letter/a/c77e96/32.png) [@a112](https://community.developer.atlassian.com/u/a112)\
**Post date:** [July 23, 2024, 7:13am UTC](https://community.developer.atlassian.com/t/instantiate-navbuilder/82023/1 "2024-07-23T07:13:23Z")

</div>

Hello. I am trying to retrieve a pull request url and I saw the NavBuilder interface would be useful for that. I’m struggling to instantiate a class that implements this interface though.  
I imported the bitbucket-server-api and spi packages in my pom.xml. I’m probably not giving enough information because I’m new developing bitbucket-plugins.  
I’ll provide a code snippet so that you understand my idea.

> String content = String.format(“Branch "%s" was merged into branch "%s" at %s. Details at %s”, fromBranch, toBranch, event.getDate().toString(), url);

I’d set the url with the buildAbsolute() for the specific pullRequest.  
I tried using

> @ComponentImport  
> NavBuilder nb;

or

> @Autowired  
> NavBuilder nb;

But none of them worked. There were exceptions telling me no bean implementing NavBuilder was available.  
What are the steps to be followed to obtain an instance of NavBuilder or its nested classes (e.g. NavBuilder.PullRequestOverview, …)?

---

<div class="post-metadata">

**Author:** ![wkritzinger](https://sea1.discourse-cdn.com/atlassiandeveloper/user_avatar/community.developer.atlassian.com/wkritzinger/32/36921_2.png) [@wkritzinger](https://community.developer.atlassian.com/u/wkritzinger)\
**Post date:** [September 20, 2024, 1:41am UTC](https://community.developer.atlassian.com/t/instantiate-navbuilder/82023/2 "2024-09-20T01:41:29Z")

</div>

The `NavBuilder` needs to be imported as a component. In general there are 3 ways to do this, depending on which way you use in your plugin it might be different.

You need a `<component-import>` element in your `atlassian-plugin.xml`, or you have to define a `<osgi:import>` element in your `META-INF/spring/component-imports.xml` file.

Or you can use this method: [https://developer.atlassian.com/server/framework/atlassian-sdk/spring-java-config/](https://developer.atlassian.com/server/framework/atlassian-sdk/spring-java-config/)
