Hello sir Gaurav Raj!! I have the same problem like Sayanika Dutta ,Error instantiating servlet class [org.springframework.web.servlet.DispatcherServlet]" . can you help me please? I
@GauravRaj213 жыл бұрын
Ok, I have figured out the issue and the error was on my side. I missed recording one part of the video. In order to solve the issue, you need to include the javax servlet api in your pom file. You can find the latest version here: mvnrepository.com/artifact/javax.servlet/javax.servlet-api The dependency was included in the github project, but looks like I forgot to record that part in my video. Let me know if you still face any issues after doing that. ****** The below is my understanding currently. But parts of it might be wrong. If you have any doubts about this, let me know. Why do you need to include the javax-servlet-api dependency separately? - javax.servlet is a package that's part of Java EE (Java Enterprise Edition). It's not in the JDK. - spring-webmvc also does not pull in javax library as a dependency. To pull in javax.servlet dependency, you need to include javax-servlet-api separately. - If we were using something like Spring Boot, we would not have to do this manually. Because Spring Boot uses the spring-boot-starter-web dependency, which automatically pulls in tomcat which in turn pulls in javax.servlet. Because we are not using Boot, we have to do this manually. A SO post that explains a bit here: stackoverflow.com/questions/860022/wheres-javax-servlet So if it was javax-servlet-api that was missing, why were we seeing an error in the instantiation of the DispatcherServlet which is a Spring class? - There are two things to unpack here. You were reading the error wrong. Note that the error that you were seeing (Error instantiating servlet class [org.springframework.web.servlet.DispatcherServlet]) is not just a single error, but an entire error stack. If you want to find the ROOT cause of the error, you have to scroll to the bottom of the page and see the bottom-most error. That is the ROOT cause. Every other error that is "on-top" of that is just being caused BECAUSE of the root cause. So the focus should always be on solving the ROOT cause. That should get rid of the other errors - You can verify that the DispatcherServlet does infact use the javax-servlet-api. You can do this in this way: once you have included the javax-servlet-api dependency in your project and rebuilt everything, search for the DispatcherServlet class. In that class you will find HttpServletRequest type. Now when you click on that type, it should take you to the package that that class belongs to and in that you can see javax.servlet.http which is a package in the javax-servlet-api. That is why the DispatcherServlet was throwing an error.
@radugribincea14233 жыл бұрын
@@GauravRaj21 Thank you very much!!!!!!!!!!!!!!!!!!!!!!!!!!! I have fixed the problem!!!!!!!!!!!!! Thank youuuuuuuuuuuuuuuuuuuuu!!!!!!!!!!!
@karenestarly52763 жыл бұрын
Chevere, me sirvio mucho tu ayuda para empezar a crear webpages con intellij y java, gracias.
@tapanradadiya36572 жыл бұрын
Hello sir i cant able to find tomcat in my run/debug configurations please help me
@TuanNguyen-qh7pk2 жыл бұрын
Thanks a lot, you save my day :3
@WillianSantos202 жыл бұрын
Thank you
@challangebee49112 жыл бұрын
not working
@sayanikadutta36853 жыл бұрын
I am getting an error message in /employee message:"Error instantiating servlet class [org.springframework.web.servlet.DispatcherServlet]" . Can you please help?
@GauravRaj213 жыл бұрын
Are you getting the same error when trying to access the "/" path? If yes then it probably is due to missing dependencies. I have linked the github repo in the video description. Take a look at the pom and see what's missing. Browse the repo at the first commit. If you are able to see the "Hello World" message when you visit the "/" path, then that does not make much sense to me. In that case I would just start a new project and incrementally make changes with testing at each step to isolate the issue. Hope this helps.
@radugribincea14233 жыл бұрын
Hello, did you solved the problem , sir?
@GauravRaj213 жыл бұрын
Sorry I think this was my error. I have written the solution while answering Radu Gribincea in the comment section. You can check it out if you want and let me know if you are still facing the issue or not.