0

I have recently started the migration of our application from Spring Web version 5.x.x to 6.0.6 It progressively took to upgrade of Java 8 to 17 and Spring Boot version 2.x.x 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.

Naseer Mohammad
  • 389
  • 4
  • 14
  • 1
    Look closer at this part in your stack trace `spring-plugin-core-2.0.0.RELEASE`. It is indeed not remotely related to Swagger and SpringFox. – BalusC Jun 07 '23 at 16:04
  • @BalusC , Got that, But you can also see that I have the Spring Core 6.0.6 Jar, Hope you've noticed it. Looked for Spring Plugin Jar why its being 2.0.0 even if I have Spring Core 6, Spring Boot 3+ etc. Could you please provide some solution to this? – Naseer Mohammad Jun 08 '23 at 10:08
  • 1
    Sorry, I don't do Spring. First step for you would be to carefully check dependency tree. – BalusC Jun 08 '23 at 10:10

1 Answers1

0

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

Naseer Mohammad
  • 389
  • 4
  • 14