Table of Contents
Question content
Solution
Home Java Spring SseEmitter throws java.lang.IllegalArgumentException: No suitable converter class error when sending DTO object

Spring SseEmitter throws java.lang.IllegalArgumentException: No suitable converter class error when sending DTO object

Feb 09, 2024 pm 09:21 PM
usdt

When php editor Baicao uses Spring SseEmitter to send DTO objects, you may encounter java.lang.IllegalArgumentException: No suitable converter class error. This error usually occurs when the converter is not configured correctly, resulting in the inability to convert the DTO object into the correct data format. The way to solve this problem is to check whether the converter class is correctly configured in the configuration file and ensure that the converter class can correctly convert the DTO object into the corresponding data format.

Question content

In our spring-boot application we have the following simple ssesstatusdto dto:

@builder
@allargsconstructor
@noargsconstructor
public class ssestatusdto {

    private string currentphase;
    private int percentage;
    private string result;
}
Copy after login

For some reason I can't understand, spring cannot convert this dto to json when trying to send the information back to the client:

emitter.send(SseEmitter.event()
                    .data(SseStatusDto.builder()
                            .currentPhase("DONE")
                            .percentage(100)
                            .result("temp-result")
                            .build()), MediaType.APPLICATION_JSON);
Copy after login

I get java.lang.illegalargumentexception: No suitable converter for class <class>

What did I miss?

Solution

Try adding getters and setters for the sestatusdto model:

@Builder
@AllArgsConstructor
@NoArgsConstructo
@Getter
@Setter
public class SseStatusDto {

  private String currentPhase;
  private int percentage;
  private String result;
}
Copy after login

This should solve your problem.

The above is the detailed content of Spring SseEmitter throws java.lang.IllegalArgumentException: No suitable converter class error when sending DTO object. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1672
14
PHP Tutorial
1277
29
C# Tutorial
1257
24
The latest updates to the oldest virtual currency rankings The latest updates to the oldest virtual currency rankings Apr 22, 2025 am 07:18 AM

The ranking of virtual currencies’ “oldest” is as follows: 1. Bitcoin (BTC), issued on January 3, 2009, is the first decentralized digital currency. 2. Litecoin (LTC), released on October 7, 2011, is known as the "lightweight version of Bitcoin". 3. Ripple (XRP), issued in 2011, is designed for cross-border payments. 4. Dogecoin (DOGE), issued on December 6, 2013, is a "meme coin" based on the Litecoin code. 5. Ethereum (ETH), released on July 30, 2015, is the first platform to support smart contracts. 6. Tether (USDT), issued in 2014, is the first stablecoin to be anchored to the US dollar 1:1. 7. ADA,

Ranking of the top ten digital currency exchanges The latest list of top ten virtual currency trading software platforms Ranking of the top ten digital currency exchanges The latest list of top ten virtual currency trading software platforms Apr 22, 2025 pm 01:15 PM

The top ten digital currency exchanges are: 1. Binance, 2. OKX, 3. gate.io, 4. Coinbase, 5. Kraken, 6. Bitfinex, 7. Huobi, 8. KuCoin, 9. Bitstamp, 10. Gemini, these platforms are highly regarded for their high liquidity, extensive trading pairs, relatively low transaction fees, multi-level security measures, and a friendly user interface.

What currency does Ripple (XRP currency) belong to? Detailed tutorial for beginners What currency does Ripple (XRP currency) belong to? Detailed tutorial for beginners Apr 28, 2025 pm 07:57 PM

Created by Ripple, Ripple is used for cross-border payments, which are fast and low-cost and suitable for small transaction payments. After registering a wallet and exchange, purchase and storage can be made.

Which address is the official website app of the okx trading platform? The top three exchanges Which address is the official website app of the okx trading platform? The top three exchanges Apr 28, 2025 pm 07:21 PM

OKX provides a convenient trading experience, and the app can be downloaded on the App Store and Google Play. The top three exchanges are Binance, OKX and Gate.io.

Binance official website entrance Binance official latest entrance 2025 Binance official website entrance Binance official latest entrance 2025 Apr 28, 2025 pm 07:54 PM

Visit Binance official website and check HTTPS and green lock logos to avoid phishing websites, and official applications can also be accessed safely.

Recommended top 10 for easy access to digital currency trading apps (latest ranking in 25) Recommended top 10 for easy access to digital currency trading apps (latest ranking in 25) Apr 22, 2025 am 07:45 AM

The core advantage of gate.io (global version) is that the interface is minimalist, supports Chinese, and the fiat currency trading process is intuitive; Binance (simplified version) has the highest global trading volume, and the simple version model only retains spot trading; OKX (Hong Kong version) has the simple version of the interface is simple, supports Cantonese/Mandarin, and has a low threshold for derivative trading; Huobi Global Station (Hong Kong version) has the core advantage of being an old exchange, launches a meta-universe trading terminal; KuCoin (Chinese Community Edition) has the core advantage of supporting 800 currencies, and the interface adopts WeChat interaction; Kraken (Hong Kong version) has the core advantage of being an old American exchange, holding a Hong Kong SVF license, and the interface is simple; HashKey Exchange (Hong Kong licensed) has the core advantage of being a well-known licensed exchange in Hong Kong, supporting France

What are the stablecoins? How to trade stablecoins? What are the stablecoins? How to trade stablecoins? Apr 22, 2025 am 10:12 AM

Common stablecoins are: 1. Tether, issued by Tether, pegged to the US dollar, widely used but transparency has been questioned; 2. US dollar, issued by Circle and Coinbase, with high transparency and favored by institutions; 3. DAI, issued by MakerDAO, decentralized, and popular in the DeFi field; 4. Binance Dollar (BUSD), cooperated by Binance and Paxos, and performed excellent in transactions and payments; 5. TrustTo

Top 10 Currency Exchange Trading Platform Ranking Top 10 Currency Exchange App Recommended in 2025 Top 10 Currency Exchange Trading Platform Ranking Top 10 Currency Exchange App Recommended in 2025 Apr 28, 2025 pm 12:18 PM

Ranking of the top ten currency trading platforms: 1. Binance, 2. OKX, 3. Gate.io, 4. Coinbase, 5. Kraken, 6. Huobi, 7. KuCoin, 8. Bitfinex, 9. Bittrex, 10. Poloniex, these exchanges provide registration, verification, deposit, withdrawal and trading functions, which are suitable for traders of different levels.