简体   繁体   中英

Getting java.lang.TypeNotPresentException: Type javax.servlet.http.HttpServletRequest not present in Spring boot latest migrated application

I have recently started the migration of our application from Spring Web version 5.xx to 6.0.6 It progressively took to upgrade of Java 8 to 17 and Spring Boot version 2.xx to 3 and which are the necessary libraries for this upgrade to be successful

And in such process I have resolved many errors with help of beautiful platforms like Stackoverflow, Spring docs and many wonderful bloggers sites. However I am stumbled upon this as to why this contradictory behaviour is happening where as spring docs apparently says here that spring core has migrated from javax to Jakarta namespace.

Now I am getting this exception. My question is why is still Spring Core(6.0) library referring to javax namespace when it says in documentation it refers to Jakarta namespace, where it must have referred to this

jakarta.servlet.http.HttpServletRequest

Here's the exception.

java.lang.TypeNotPresentException: Type javax.servlet.http.HttpServletRequest not present at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117) ~[?:?] at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125) ~[?:?] at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[?:?] at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68) ~[?:?] at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138) ~[?:?] at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) ~[?:?] at sun.reflect.generics.repository.ClassRepository.computeSuperInterfaces(ClassRepository.java:117) ~[?:?] at sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:95) ~[?:?] at java.lang.Class.getGenericInterfaces(Class.java:1211) ~[?:?] at org.springframework.core.ResolvableType.getInterfaces(ResolvableType.java:500) ~[spring-core-6.0.6.jar:6.0.6] at org.springframework.core.ResolvableType.as(ResolvableType.java:448) ~[spring-core-6.0.6.jar:6.0.6] at org.springframework.core.ResolvableType.forClass(ResolvableType.java:1048) ~[spring-core-6.0.6.jar:6.0.6] at org.springframework.plugin.core.config.PluginRegistriesBeanDefinitionRegistrar.getTargetType(PluginRegistriesBeanDefinitionRegistrar.java:101) ~[spring-plugin-core-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.plugin.core.config.PluginRegistriesBeanDefinitionRegistrar.registerBeanDefinitions(PluginRegistriesBeanDefinitionRegistrar.java:71) ~[spring-plugin-core-2.0.0.RELEASE.jar:2.0.0.RELEASE] at org.springframework.context.annotation.ImportBeanDefinitionRegistrar.registerBeanDefinitions(ImportBeanDefinitionRegistrar.java:86) ~[spring-context-6.0.6.jar:6.0.6] at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromRegistrars$1(ConfigurationClassBeanDefinitionReader.java:373) ~[spring-context-6.0.6.jar:6.0.6] at java.util.LinkedHashMap.forEach(LinkedHashMap.java:721) ~[?:?]

Can someone elaborate, why this might be happening why the latest core library is referring to old javax HttpServletRequest??

I have already gone through relevant questions, But they don't answer my query to the point and they talk about Swagger and SpringFox dependency fixes!! Check here an example.

The solution to fix the problem would be to add javax.servlet api dependency, But still the question remains as to what might have caused Spring Boot 6 jar to look out for javax namespace instead of Jakarta namespace.!!.

Here is the solution, link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM