Modifying an existing spring-boot project

Hello, everyone!

I’m trying to build a spring boot Atlassian connect plugin. I was able to do everything that I want on the spring boot basic project which I downloaded from atlassian connect spring boot repository. Now I’m trying to modify an existing spring boot project in order to perform the same operation on it. But I’m facing some issues. I’m not sure if they are relevant but I’ll try to list everything I noticed that has or may have an effect on the project.

1-) First of all, the spring boot project I’m trying to modify is generated by Jhipster. And has multiple other folders in resources folder. The folder layout is like:
resources_folder
By the way, as you can see I put the app descriptor in static folder. Otherwise, the application was throwing and didn’t start:
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/web/AbstractErrorController.class] cannot be opened because it does not exist

2-) When I run atlassian-sample project (the working one :smiley: ) when I type the url produced by ngrok to the browser, it automatically redirects to atlassian-connect.json such as when I type https://acb63e8c.ngrok.io, it redirects to _https://acb63e8c.ngrok.io/atlassian-connect.json_. But in my application it was redirecting to Jhipster index.html. I had to add /atlassian-connect.json path myself at the end of the url. And another difference was the working application’s app descriptor looks like this on browser:

{
  "key": "atlassian-connect-spring-boot-sample-basic",
  "baseUrl": "https://acb63e8c.ngrok.io",
  "name": "Atlassian Connect Spring Boot Basic Sample",
  "authentication": {
    "type": "jwt"
  },
  "lifecycle": {
    "installed": "/installed",
    "uninstalled": "/uninstalled"
  }
}

Instead my new application’s app descriptor looks like plain text:

{ "key": "atlassian-connect-test-plugin", "baseUrl": "https://7385700d.ngrok.io", "name": "Atlassian Connect Test Plugin", "authentication": { "type": "jwt" }, "lifecycle": { "installed": "/installed", "uninstalled": "/uninstalled" }, "scopes": [ "read" ] }

3-) When I try to upload the plugin to Jira. Jira shows the message:
The app host returned HTTP response code 404 when we tried to contact it during installation. Please try again later or contact the app vendor.
I think the Lifecycle controller does not work.

4-) Besides when I try to autowire AtlassianHostRestClients the application throws an exception and does not start:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.atlassian.connect.spring.AtlassianHostRestClients' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

I wrote just a simple service that does nothing.

@Service
public class JiraService {

    @Autowired
    private AtlassianHostRestClients atlassianHostRestClients;

}

Any help on these will be appreciated. Thanks in advance :slight_smile:

Hi @eren581,

I’m afraid that atlassian-connect-spring-boot is likely too opinionated, makes too many assumptions about your project configuration, and simply doesn’t play well enough with the different Spring libraries for it to work smoothly with JHipster out of the box.

We can’t provide detailed support for this kind of usage, so I would rather recommend that you start from a fresh project using atlassian-connect-spring-boot (such as one generated using our archetype), and then progressively add elements of your JHipster project to it. (That will require you to understand what the JHipster code and configuration does.)

Cheers,
Einar

Thank you for your quick reply Einar. I’ll try. If I resolve the problem I’ll share the solution here in case anyone else faces the same problem.

EDIT: I was able to solve my problem without starting from a new project but modifying the project I got. But as Einar suggested starting from the beginning would be the proper way to solve the problem since I am not very sure how elegant my solution is. So I don’t suggest this unless you have to :smiley: I will try to answer all the questions that I asked respectively according to these methods I used.

1-) It is okay to put app descriptor file in the static folder inside resources.
2-) It is also okay that app descriptor looks like plain text. If the format is correct it is not important. But I found out that this difference is due to configurations automatically generated by Jhipster. In the WebConfigurer.java file, you can add a mime type for json and fix this difference. (Default mime type was TEXT_HTML_VALUE)
3-) As I suspected, the lifecycle controller was not working. I am not sure but this may be occurred due to Jhipster’s Hazelcast configurations because I realized that there are some classes named LifecycleEvent and LifecycleListener under Hazelcast package. Maybe some conflict occurred between Hazelcast and Atlassian packages. To solve this problem, I decided to manually add LifecycleController class among my project files. So I downloaded the source code of LifecycleController on my IDE, then copied the contents of the class into my project package with the same name. (I did this other related classes too. It may sound a lot of work to do but there were fewer classes needed than I expected :smiley: )
4-) As in the LifecycleController, since my application did not recognize AtlassianHostRestClients as a bean, I thought adding AtlassianHostRestClients class manually may work also. I thought since the bean definition will be inside the main project package, it should recognize the bean no matter what configurations set. And it worked.

Again I don’t think it is a proper way to proceed but you can take a look at these if you face similar problems.

The problem could be also in not implemented AtlassianHostRepository and there is an inappropriate exception with this, there should be checking that user implement that repository and then throw normal exception related to this.