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

Java API GET Request - 500 Internal Server Error

J January 11, 2017

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Claudio Kirchhoff January 12, 2017

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

0 votes
J January 11, 2017

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?!

0 votes
Claudio Kirchhoff January 11, 2017

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

0 votes
J January 11, 2017

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

0 votes
Claudio Kirchhoff January 11, 2017

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!

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events