Jersey Http 500 Ошибка при запросе Xml - PullRequest
0 голосов
/ 26 мая 2020

Я следовал инструкциям, установил сервер tomcat9 и сделал проект jersey. Запрос строки возможен, но когда я запрашиваю Xml, созданный из объекта, я получаю внутреннюю ошибку сервера Http 500.

My Resource:

package com.pro_tests.demorest;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

@Path("aliens")
public class AlienResource {

@GET
@Produces(MediaType.APPLICATION_XML)
public Alien getAlien() {
    Alien a1 = new Alien();
    a1.setName("Tim");
    a1.setPoints(60);

    return a1;
}

}

Мой класс, преобразованный в Xml

package com.pro_tests.demorest;

import jakarta.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="alien")

public class Alien 
{
    public Alien() {

    }

private String name;
private int points;

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public int getPoints() {
    return points;
}

public void setPoints(int points) {
    this.points = points;
}

}

...