• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
Bartenders:
  • Himai Minh
  • Carey Brown
  • Frits Walraven

Spring MVC / Eclipse 404 not found

 
Greenhorn
Posts: 2
Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'm trying to learn Spring framework using Eclipse, and found this tutorial:
https://www.youtube.com/watch?v=g2b-NbR48Jo
I followed up to the 29:36 min marker and it works in the video but not for me.

It's supposed to print the following to the console(just to see if it works) : "here"
I've followed the tutorial a few times but getting error:
WARNING: No mapping found for HTTP request with URI [/DemoMVC/add] in DispatcherServlet with name 'telusko'

Here is the info prior to that:


Here is the jsp file:


the web.xml file:


The AddController.java file:


The telusko-servlet.xml file located in the webapp/WEB-INF/ :


- using Eclipse IDE 2021-03(4.19.0)
- Tomcat 8.0 & tried on Tomcat 8.5

the tutorial starts out by starting maven project in Eclipse, then adds the Spring framework using maven.

I'm confused on the @RequestMapping part, and it is defined in the AddController servlet, but I'm not sure what the error comes up?

Any additional info required, let me know.
Beginner in Spring.
Thanks,
J.
 
Saloon Keeper
Posts: 23904
162
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use Code Tags around JSP and XML. They're not just for Java!

I can't really tell for sure, but my suspicion is that you're deploying the webapp to the wrong place.

I'll assume you're using Tomcat, but the principles are the same for the other JEE servers - you cannot just dump files into the TOMCAT_HOME/webapps directory and expect them to run.

Webapps are defined as WAR files. A WAR is a specific type of JAR (ZIP) archive with a specific structure, including the /WEB-INF directory and its children. In many webapp servers, you don't actually need a WAR file, as long as you provide something that looks like what you'd get if you unzipped ("exploded") a WAR file.

So far, so good. But the other thing is that webapp servers support running more than one webapp at a time.

That means that you have to have a mechanism for keeping them separate, since you'd get a real mess if you just jumbled them all together.

Actually, you need two mechanisms. One for URLs, so you know which webapp to send a URL request to, and one for WARs to keep them distinct.

In the case of the WARs, you do that by filing them under the TOMCAT_HOME/webapps/ directory in a subdirectory with the same name as the WAR. For example: TOMCAT_HOME/webapps//DemoMVC,

In the case of URLs, you have the webapp context path. The context path is the part of the URL that indicates which webapp receives the request. It follows the servername/port part of the URL and precedes the webapo's local URL sub-path. By default, it will have the same name as the WAR for that webapp, so if I send a URL request to http://localhost:8080/DemoMVC/add, the webapp server will look at the TOMCAT_HOME/webapps/DemoMVC deployment description (originally /WEB-INF/web.xml, but often now built from annotations).

I think that this is probably where your problem lies.
 
Jahangir Ismail
Greenhorn
Posts: 2
Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,
thanks for the reply. I've fixed up the code tags, looks better, thanks for the tip.

I should have explained in the original post, that I'm running from Eclipse directly. Not deploying to the Tomcat, but running from Eclipse which uses the Tomcat server.
I've uploaded a screen shot of the Eclipse workspace.

I can get to the index.jsp page (uploaded the screen shot), but when clicking on submit button, it gives the error.

I'm not sure if it's Eclipse or a Spring framework configuration?

Just wondering if there is anything missing or add any info in the telusko-servlet.xml file:




I can make normal servlets/jsp examples in Eclipse and works fine. but, using the Spring framework from Eclipse is where it doesn't work for me.

Can you recommend any simple tutorials for beginners in Spring?

Thanks again Tim.



Eclipse.JPG
Eclipse workspace
Eclipse workspace
index-jsp.JPG
index.jsp page
index.jsp page
 
Tim Holloway
Saloon Keeper
Posts: 23904
162
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is more than one way to run Tomcat under Eclipse. There's the WTP plugin that's pre-installed in the JEE spin of Eclipse. It's abominable. There is also an external plugin available developed by sysdeo, and recently named "mongrel".

I use the sysdeo plugin. Both of them spawn JVM's running Tomcat with debugging enabled and a pre-connection from the Eclipse debugger to the Tomcat debug port. But sysdeo uses the actual Tomcat config information to configure and run Tomcat. The WTP plugin makes a bad (incomplete and often stale) copy of the Tomcat config information.

In neither case is Eclipse actually "running" Tomcat. It's only starting/stopping the JVM and handling debugging. So most of the same rules apply either way.

To get a "404", as I said, either you have to have not placed the necessary data (WEB-INF/web.xml and servlet class) in the proper place for Tomcat to find it  or - in the case of annotations - you would have had to have a problem that kept the system from scanning the servlet and digesting its annotations. Which I think is all done internally by Tomcat and probably beyond the reach of WTP to screw up.

On the other hand - and this is one of the big reasons I despise WTP - when using Java Persistence Architecture (Spring JPA) Tomcat requires a set of Spring code reweaving JARs to be located in TOMCAT_HOME/lib and I don't think that WTP handles that very well.
 
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic