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

Java API GET Request - 500 Internal Server Error

Hey,

all of my GET requests to JIRA return the Internal Server Error 500.

image2017-1-11 15:15:29.png

 

Backend Java Code:

import io.swagger.annotations.Api;

import java.net.URISyntaxException;
import java.util.ArrayList;

import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import PACKAGE_NAME.JiraService;

@Api(tags = { "jira" })
@Named
@Stateless
@Path("jira")
public class AktuelleBugs {

     @Inject
        JiraService JiraService;


    @GET
    @Path("/getAktuelleBugs")
    @Produces(MediaType.APPLICATION_JSON)
    public ArrayList<String> getAktuelleBugs() throws URISyntaxException  {
        return JiraService.getAktuelleBugs();
}
}
/*JiraService.java*/

public ArrayList<String> getAktuelleBugs() throws URISyntaxException{
            JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
            URI uri = new URI("https://mycompany.com/jira/");
            JiraRestClient client = factory.createWithBasicHttpAuthentication(uri, "user", "password");
            Promise<SearchResult> searchJql = client.getSearchClient().searchJql(
                    "project=\"System Betrieb\" AND issuetype != epic AND type=bug ORDER BY priority ASC");
            SearchResult searchResult = searchJql.claim();

            Iterable<Issue> issues = searchResult.getIssues();
        
            ArrayList<String> issueList= new ArrayList<String>();
                
            for (Issue issue : issues) {
                issueList.add(issue.getKey());
                issueList.add(issue.getSummary());
                issueList.add(issue.getPriority().getName());
            }
                
            return issueList;
        }

 

Front End gets JSON (BACKEND_URL = localhost:8080/Application_Name/rest/)

angular.module('Application_Name').controller('aktuelleBugs', 
            function ($scope, $http, $q, BACKEND_URL) {
        'use strict';
    
       
      var deferred = $q.defer();
        
        $http({
            method : "GET",
            url : BACKEND_URL + "jira/getAktuelleBugs"
        }).then(function (response) {
            
            deferred.resolve(response.data);
            
        }, function myError(response) {
            deferred.reject(response);
        });
       
        
      deferred.promise.then(function(bugs){
	...
	...
	.

 

 

When starting the server(JBOSS) locally everything works fine.

 

Hoping that this issue can be solved as soon as possible smile

5 answers

There should be an error message in the logs - can you post it?

On a sidenote: you should use 'jiraService' (lowercase) as a variable name!

Unfortunately I dont have access to the logs and thank you smile.

Darn, those would be really helpful smile

Then all I can advise is to try to systematically narrow down the problem:

  1. Return a hardcoded response from your REST endpoint and see if the error persists
  2. if no, then re-add the call to getAktuelleBugs() and return a hardcoded answer from there
  3. and so on, until you find out where exactly the error occurs

If you at least know where the error happens, you might get an idea of the reason

I guess I have to ask for the logs, because none of the things I tried worked.

 

Just for the record:

 

    Tried to return String "Hello world" with the class AktuelleBugs()

        REST Client was able to GET the String

    Different locations of the class had no effect

 

Could be an issue with the Server configuration of the JIRA host?!

So the error is in the AktuelleBugs() method. You could move 'return "hello world"' further down, line by line to determine the actual line of the error, but getting the logs is certainly the smart way to go smile

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published Thursday in Confluence

Confluence CVEs and common questions

Two vulnerabilities have been published for Confluence Server and Data Center recently: March 20, 2019 CVE-2019-3395 / CVE-2019-3396 April 17, 2019 CVE-2019-3398 The goal of this article is...

82 views 0 9
Read article

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