!!! Od 1.6.2022 jsem zaměstnán na HPP. Kde? To tady nemůžu napsat (kvůli Compliance). Ale na mém Linkedin účtu (nick: Jirka Pinkas) to určitě najdete. 😁 V současnosti mám volných 10 dní, které mohu alokovat na školení 😊

Spring Native & @ResponseStatus

publikováno: 20.12.2021

Ve Spring Native aktuálně nefunguje tento způsob řešení výjimek (možná časem fungovat začne, Spring Native je stále beta):

@ResponseStatus(HttpStatus.NOT_FOUND)
public class NotFoundException extends RuntimeException {
}

Dostanete tuto hlášku:

2021-12-20 13:35:39 [http-nio-8080-exec-1] {requestId:} ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - 
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
[Handler processing failed; nested exception is com.oracle.svm.core.jdk.UnsupportedFeatureError:
Proxy class defined by interfaces [interface org.springframework.web.bind.annotation.ResponseStatus,
interface org.springframework.core.annotation.SynthesizedAnnotation] not found. Generating proxy
classes at runtime is not supported. Proxy classes need to be defined at image build time by
specifying the list of interfaces that they implement. To define proxy classes use
-H:DynamicProxyConfigurationFiles=<comma-separated-config-files> and
-H:DynamicProxyConfigurationResources=<comma-separated-config-resources> options.] with root cause
com.oracle.svm.core.jdk.UnsupportedFeatureError: Proxy class defined by interfaces
[interface org.springframework.web.bind.annotation.ResponseStatus,
interface org.springframework.core.annotation.SynthesizedAnnotation] not found.
Generating proxy classes at runtime is not supported. Proxy classes need to be defined at image
build time by specifying the list of interfaces that they implement. To define proxy classes use
-H:DynamicProxyConfigurationFiles=<comma-separated-config-files> and
-H:DynamicProxyConfigurationResources=<comma-separated-config-resources> options.

Toto řešení ale funguje:

@ControllerAdvice
public class AppControllerAdvice {

@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler
public String handleNotFoundException(NotFoundException e) {
return "error/404";
}

}

 

Reference

Školení mi pomohlo ujasnit si jak má správně probíhat testování kódu, představilo užitečné knihovny a nástroje. Vše bylo podáno zábavnou formou, takže nebyl problém udržet pozornost. Navíc byl výhodou dostatek

Certicon
David

Jedno z nejlepších školení za poslední roky. Kromě seznámení se Springem apod. mě velmi příjemně překvapila hluboká znalost probírané látky a schopnost ji srozumitelně vysvětlit v případě ad hoc dotazů.

Jaroslav

Přestože jsem Cčkař, tak jsem se na školení JUnit dozvěděl nové věci. Zejména co se týče metodiky jednotkového testování a některých odborných termínů.

Retia
Jaromír


Novinky

25.12.2023: testcontainers pro lokální vývoj

25.12.2023: Kubernetes & Prometheus Documentary

9.8.2023: Rancher Desktop 2023