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

J Jan 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

0 votes
Claudio Kirchhoff Jan 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!

0 votes
J Jan 11, 2017

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

0 votes
Claudio Kirchhoff Jan 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 Jan 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 Jan 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

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 in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

8,469 views 26 38
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