Whenever I try to generate a CSV I get a "No enum constant" exception, does anyone have an idea what it could be?


Error that appears in the picture:enter image description here

From what I noticed the error seems to be in the "toCsv" method.
whenever I use debug it stops at "obterCsv", but I’m not sure why it throws an exception.

My code:

  • Controller:
public void exportCsv(@Validated TratativaFiltros filtros, HttpServletResponse response) {
    service.exportarCsv(response, filtros);


  • Service:
private List<TratativaResponse> searchForFiltroAndOrder(TratativaFiltros filtros) {
    var sort = SortBuilders.fieldSort("protocolo").order(SortOrder.DESC);
    var predicate = filtros.toElasticPredicate();
    filtrarPorNivelPermissao(predicate, filtros);
    var tratativas = repository.findAll(sort, predicate.build());

    return tratativas.stream()
        .map(tratativa -> TratativaResponse.of(tratativa))

public void exportarCsv(HttpServletResponse response, TratativaFiltros filtros) {



  • Response:
public static String getCsv(List<TratativaResponse> tratativa) {
    return getCabecalhoCsv()
public static String getCabecalhoCsv() {
    return "\uFEFF"
private static String getLinhasCsv(List<TratativaResponse> tratativa) {
    return !CollectionUtils.isEmpty(tratativa)
        ? tratativa.stream()
        : "Registros não encontrados.\n";
public static TratativaResponseCsv of(TratativaResponse response) {
    var responseCsv = new TratativaResponseCsv();
    BeanUtils.copyProperties(response, responseCsv);
    return responseCsv;
public String[] toCsv() {
    return Stream.of(
public String obterCsv() {
    return Arrays.stream(toCsv()).collect(Collectors.joining(";"));



As the exception says:

There is no enum value "backoffice" in EOrganiacao

Answered By – Simon Martinelli

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published