org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported I've tried to change consumes inside @RequestMapping annotation to text/plain but unfortunately it didn't help.* Any ideas? Thanks, My Code looks like this: package com.budget.processing.application; import com.budget.business.service.Budget; import com.budget.business.service.BudgetItem; import com.budget.business.service.BudgetService; import com.budget.processing.dto.BudgetDTO; import com.budget.processing.dto.BudgetPerConsumerDTO; import com.utils.Constants; import com.common.utils.config.exception.GeneralException; import org.apache.log4j.Logger; import org.joda.time.YearMonth; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import javax.ws.rs.core.MediaType; import java.text.ParseException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @Controller("budgetManager") @RequestMapping(value = "budget", produces = Constants.RESPONSE_APP_JSON) @Transactional(propagation = Propagation.REQUIRED) public class BudgetManager { private static final Logger logger = Logger.getLogger(BudgetManager.class); @Autowired private BudgetService budgetService; @RequestMapping(method = RequestMethod.GET) public @ResponseBody Collection<BudgetDTO> getBudgetMonthlyAllConsumers() throws GeneralException { List<Budget> budgetList = budgetService.getBudgetForAllConsumers(); List<BudgetDTO> bugetDtos = new ArrayList<>(); for (Budget budget : budgetList) { BudgetDTO budgetDTO = generateBudgetDto(budget); bugetDtos.add(budgetDTO); } return bugetDtos; } @RequestMapping(method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON) public @ResponseBody Collection<BudgetDTO> updateConsumerBudget(@RequestParam(value = "budgetPerDate", required = false) ArrayList<BudgetPerConsumerDTO> budgetPerDate) throws GeneralException, ParseException { List<BudgetItem> budgetItemList = new ArrayList<>(); List<Budget> budgets = new ArrayList<>(); if (budgetPerDate != null) { for (BudgetPerConsumerDTO budgetPerConsumerDTO : budgetPerDate) { budgetItemList.add(budgetService.createBudgetItemForConsumer(budgetPerConsumerDTO.getId(), new YearMonth(budgetPerConsumerDTO.getDate()), budgetPerConsumerDTO.getBudget())); } } budgets = budgetService.getBudgetForAllConsumers(); List<BudgetDTO> budgetDTOList = new ArrayList<>(); for (Budget budget : budgets) { BudgetDTO budgetDto = generateBudgetDto(budget); budgetDTOList.add(budgetDto); } return budgetDTOList; } } Here is the exception I get: ERROR 2014-07-26 18:05:10.737 (GlobalExceptionHandler.eITFMSException: 86) Error executing Web Service org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported

Stack Overflow | Nir | 2 years ago
  1. 0

    Error: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported

    Stack Overflow | 2 years ago | Nir
    org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported I've tried to change consumes inside @RequestMapping annotation to text/plain but unfortunately it didn't help.* Any ideas? Thanks, My Code looks like this: package com.budget.processing.application; import com.budget.business.service.Budget; import com.budget.business.service.BudgetItem; import com.budget.business.service.BudgetService; import com.budget.processing.dto.BudgetDTO; import com.budget.processing.dto.BudgetPerConsumerDTO; import com.utils.Constants; import com.common.utils.config.exception.GeneralException; import org.apache.log4j.Logger; import org.joda.time.YearMonth; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import javax.ws.rs.core.MediaType; import java.text.ParseException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @Controller("budgetManager") @RequestMapping(value = "budget", produces = Constants.RESPONSE_APP_JSON) @Transactional(propagation = Propagation.REQUIRED) public class BudgetManager { private static final Logger logger = Logger.getLogger(BudgetManager.class); @Autowired private BudgetService budgetService; @RequestMapping(method = RequestMethod.GET) public @ResponseBody Collection<BudgetDTO> getBudgetMonthlyAllConsumers() throws GeneralException { List<Budget> budgetList = budgetService.getBudgetForAllConsumers(); List<BudgetDTO> bugetDtos = new ArrayList<>(); for (Budget budget : budgetList) { BudgetDTO budgetDTO = generateBudgetDto(budget); bugetDtos.add(budgetDTO); } return bugetDtos; } @RequestMapping(method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON) public @ResponseBody Collection<BudgetDTO> updateConsumerBudget(@RequestParam(value = "budgetPerDate", required = false) ArrayList<BudgetPerConsumerDTO> budgetPerDate) throws GeneralException, ParseException { List<BudgetItem> budgetItemList = new ArrayList<>(); List<Budget> budgets = new ArrayList<>(); if (budgetPerDate != null) { for (BudgetPerConsumerDTO budgetPerConsumerDTO : budgetPerDate) { budgetItemList.add(budgetService.createBudgetItemForConsumer(budgetPerConsumerDTO.getId(), new YearMonth(budgetPerConsumerDTO.getDate()), budgetPerConsumerDTO.getBudget())); } } budgets = budgetService.getBudgetForAllConsumers(); List<BudgetDTO> budgetDTOList = new ArrayList<>(); for (Budget budget : budgets) { BudgetDTO budgetDto = generateBudgetDto(budget); budgetDTOList.add(budgetDto); } return budgetDTOList; } } Here is the exception I get: ERROR 2014-07-26 18:05:10.737 (GlobalExceptionHandler.eITFMSException: 86) Error executing Web Service org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported
  2. 0

    SpringMVC JSON unsupported type

    techjaffa.info | 8 months ago
    org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    SpringMVC JSON unsupported type

    Stack Overflow | 3 years ago | sonoerin
    org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.springframework.web.HttpMediaTypeNotSupportedException

      Content type 'text/plain;charset=UTF-8' not supported I've tried to change consumes inside @RequestMapping annotation to text/plain but unfortunately it didn't help.* Any ideas? Thanks, My Code looks like this: package com.budget.processing.application; import com.budget.business.service.Budget; import com.budget.business.service.BudgetItem; import com.budget.business.service.BudgetService; import com.budget.processing.dto.BudgetDTO; import com.budget.processing.dto.BudgetPerConsumerDTO; import com.utils.Constants; import com.common.utils.config.exception.GeneralException; import org.apache.log4j.Logger; import org.joda.time.YearMonth; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import javax.ws.rs.core.MediaType; import java.text.ParseException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @Controller("budgetManager") @RequestMapping(value = "budget", produces = Constants.RESPONSE_APP_JSON) @Transactional(propagation = Propagation.REQUIRED) public class BudgetManager { private static final Logger logger = Logger.getLogger(BudgetManager.class); @Autowired private BudgetService budgetService; @RequestMapping(method = RequestMethod.GET) public @ResponseBody Collection<BudgetDTO> getBudgetMonthlyAllConsumers() throws GeneralException { List<Budget> budgetList = budgetService.getBudgetForAllConsumers(); List<BudgetDTO> bugetDtos = new ArrayList<>(); for (Budget budget : budgetList) { BudgetDTO budgetDTO = generateBudgetDto(budget); bugetDtos.add(budgetDTO); } return bugetDtos; } @RequestMapping(method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON) public @ResponseBody Collection<BudgetDTO> updateConsumerBudget(@RequestParam(value = "budgetPerDate", required = false) ArrayList<BudgetPerConsumerDTO> budgetPerDate) throws GeneralException, ParseException { List<BudgetItem> budgetItemList = new ArrayList<>(); List<Budget> budgets = new ArrayList<>(); if (budgetPerDate != null) { for (BudgetPerConsumerDTO budgetPerConsumerDTO : budgetPerDate) { budgetItemList.add(budgetService.createBudgetItemForConsumer(budgetPerConsumerDTO.getId(), new YearMonth(budgetPerConsumerDTO.getDate()), budgetPerConsumerDTO.getBudget())); } } budgets = budgetService.getBudgetForAllConsumers(); List<BudgetDTO> budgetDTOList = new ArrayList<>(); for (Budget budget : budgets) { BudgetDTO budgetDto = generateBudgetDto(budget); budgetDTOList.add(budgetDto); } return budgetDTOList; } } Here is the exception I get: ERROR 2014-07-26 18:05:10.737 (GlobalExceptionHandler.eITFMSException: 86) Error executing Web Service org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported

      at org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch()
    2. Spring MVC
      DispatcherServlet.getHandler
      1. org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping.handleNoMatch(RequestMappingInfoHandlerMapping.java:215)
      2. org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lookupHandlerMethod(AbstractHandlerMethodMapping.java:289)
      3. org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:229)
      4. org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.getHandlerInternal(AbstractHandlerMethodMapping.java:56)
      5. org.springframework.web.servlet.handler.AbstractHandlerMapping.getHandler(AbstractHandlerMapping.java:298)
      6. org.springframework.web.servlet.DispatcherServlet.getHandler(DispatcherServlet.java:1091)
      6 frames