Меню

Localhost 8080 ошибка 404

I’m really very new to this Tomcat stuff. I downloaded Tomcat 7.0 windows installer and installed it using the default configuration. After installing, I typed localhost:8080 in my browser to see if Tomcat is working. However,it showed error message like this: Access Error: 404 — Not Found Cannot locate document: / And there’s nothing else show with Tomcat or Apache words in the page. It seems Tomcat not responding.

I googled and searched this forum, but so far the solutions people provided didn’t work for me.

  1. checked the server.xml file, 8080 is the HTTP connector port:

    Connector port=»8080″ protocol=»HTTP/1.1″ connectionTimeout=»20000″ redirectPort=»8443″

  2. I did run the Tomcat7.exe in the bin folder. Something run in the command window and disappeared then. Nothing changed then.

  3. I set some environment system variables like JAVA HOME, PATH, and CLASSPATH according to some tutorials online.

Still not work. Only things I’m suspicious are:
1. I have two JRE folder: jre6 and jre7 in the program files directory. Tomcat7 chose the jre7 one.
2. I installed anyother server called Wamp server, which I used to learn some PHP programming with SQL usage. There’s Apache in the package. Not sure if it’s using 8080 port.

Please help. I’ve already digged online more than 2hrs for this headache. Any comments are welcome.

Does the 404 error localhost:8080 mean that Tomcat can’t find the index.html or that it is down completely?

In my case the netstat command shows there is something listening on port 8080

$ netstat -an | grep 8080
tcp6       0      0 :::8080                 :::*                    LISTEN     

Or could this be something broken with Tomcat configuration? If it matters in this case, I use Ubuntu.

Thanks,
Alex

asked Apr 7, 2011 at 20:47

Genadinik's user avatar

1

I’ve heard of Tomcat problems with machines using ipv6. Try to blacklist the ipv6 module on /etc/modprobe.d directory and reboot to see if it binds correctly.

answered Apr 7, 2011 at 20:51

coredump's user avatar

coredumpcoredump

12.7k2 gold badges34 silver badges53 bronze badges

7

This error just means the default page (not necessarily index.html) cannot be found. Have a look at your tomcat log files (tomcat-dir/logs/* ) for details.

answered Apr 7, 2011 at 21:04

jlliagre's user avatar

jlliagrejlliagre

8,76118 silver badges36 bronze badges

Details
Written by  
Last Updated on 05 November 2019   |   Print  Email

In Java web development with Tomcat, it’s very often that you get HTTP 404 error like this:

tomcat-error-404

The error code is HTTP 404 (not found) and the description is:

The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.

This error means the server could not find the requested resource (JSP, HTML, images…) and returns HTTP status code 404. Most of the time, you can fix this error by correcting the URL. However, sometimes it’s not easy like that, making it is an annoying error.

Here I suggest some possible reasons and how to fix the error HTTP 404 in Java web development with Tomcat.

 

1. The URL is not handled by any Java servlets

You need to check URL mapping in your servlet classes to make sure the requested URL is actually handled by a servlet. For example:

@WebServlet("/view_book")
public class ViewBookServlet extends HttpServlet {
...
}

This servlet handles the URL /view_book. If the request URL is /view_books the server will raise HTTP 404 error. You can fix by either correcting the URL or correcting the URL mapping in the @WebServlet annotation.

In older Java web application, you have to check the web deployment descriptor file web.xml because a Java servlet can be mapped to URL via XML like this:

<servlet-mapping>
    <servlet-name>ViewBookServlet</servlet-name>
    <url-pattern>/view_book</url-pattern>
</servlet-mapping>

 

2. Java servlet forwarding to a resource that does not exist

In this case, the requested URL is handled by a Java servlet, but code in the servlet forwards to a resource (JSP, HTML…) which does not exist, as shown in the following screenshot:

tomcat-error-404-forwarding

The code in the servlet class would look like this:

String registerForm = "frontend/registerform.jsp";
RequestDispatcher dispatcher = request.getRequestDispatcher(registerForm);
dispatcher.forward(request, response);

You can fix by correcting the forward path in the servlet, and make sure that the forwarded resource does actually exist in the given path.

 

3. URL is case-sensitive

Note that Tomcat treats URL as case-sensitive, for instance /Register is different than /register. So you need to check and use correct case for the letters in request URL.

Also pay attention to the webapp name in the URL, for instance http://localhost:8080/BookstoreWebsite/ is different than http://localhost:8080/BookStoreWebsite/

TIP: in Eclipse, you can right click on the project, then click Run As > Run on Server, the IDE will always use the correct name of the web application.

Finally, you should not let the user see the raw HTTP 404 error page rendered by the server. Instead, you should design your own user-friendly 404 error page – follow this tutorial: How to Handle Error for Java web applications.

You can also watch the video version below:

 

Other Java Servlet Tutorials:

  • Java Servlet Quick Start for beginners (XML)
  • Java Servlet for beginners (annotations)
  • Java Servlet and JSP Hello World Tutorial with Eclipse, Maven and Apache Tomcat
  • Handling HTML form data with Java Servlet
  • Java File Download Servlet Example

About the Author:

Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.

Add comment

Categories

  • 385.5K All Categories
  • 5.1K Data
  • 2.5K Big Data Appliance
  • 2.5K Data Science
  • 453.4K Databases
  • 223.2K General Database Discussions
  • 3.8K Java and JavaScript in the Database
  • 47 Multilingual Engine
  • 606 MySQL Community Space
  • 486 NoSQL Database
  • 7.9K Oracle Database Express Edition (XE)
  • 3.2K ORDS, SODA & JSON in the Database
  • 585 SQLcl
  • 4K SQL Developer Data Modeler
  • 188K SQL & PL/SQL
  • 21.5K SQL Developer
  • 46 Data Integration
  • 46 GoldenGate
  • 298.4K Development
  • 4 Application Development
  • 20 Developer Projects
  • 166 Programming Languages
  • 295K Development Tools
  • 150 DevOps
  • 3.1K QA/Testing
  • 646.7K Java
  • 37 Java Learning Subscription
  • 37.1K Database Connectivity
  • 201 Java Community Process
  • 108 Java 25
  • 8.1K Embedded Technologies
  • 22.2K Java APIs
  • 138.3K Java Development Tools
  • 165.4K Java EE (Java Enterprise Edition)
  • 22 Java Essentials
  • 176 Java 8 Questions
  • 86K Java Programming
  • 82 Java Puzzle Ball
  • 65.1K New To Java
  • 1.7K Training / Learning / Certification
  • 13.8K Java HotSpot Virtual Machine
  • 94.3K Java SE
  • 13.8K Java Security
  • 208 Java User Groups
  • 25 JavaScript — Nashorn
  • Programs
  • 667 LiveLabs
  • 41 Workshops
  • 10.3K Software
  • 6.7K Berkeley DB Family
  • 3.6K JHeadstart
  • 6K Other Languages
  • 2.3K Chinese
  • 207 Deutsche Oracle Community
  • 1.1K Español
  • 1.9K Japanese
  • 474 Portuguese

adamar

Newbie, Dan:

In Chrome after http://localhost:8080/apex/apex_admin «HTTP Error 404 Problem accessing /ordsapex_admin. Reason: Not Found».

Installation steps:

APEX 5.0.1.00.06

@apxrtins.sql SYSAUX SYSAUX TEMP /i/;

@apxchpwd.sql;

ALTER USER  APEX_050000, FLOWS_FILES, APEX_PUBLIC_USER UNLOCK & pass

EXEC DBMS_XDB.SETHTTPPORT(0);

Best Answer

  • Kiran Pawar


    Kiran Pawar


    Associate Projects — Oracle APEX Pune, Maharashtra, IndiaMember Posts: 2,951 Bronze Crown

Answers

  • Dumitru Puscasu

  • adamar

    I stared in standalone mode.

    Accidentely I saved my question before ending. Seeing my text disapearing I posted again my question.

    In fact I made also the folowing steps:

    ORDS 3.01.177.18.02

    java -jar ords.war install advanced

    java -jar ords.war user adminlistener «Listener Administrator»

    APEX

    @apex_rest_config.sql

    Thanks. Best regards.

  • Kiran Pawar


    Kiran Pawar


    Associate Projects — Oracle APEX Pune, Maharashtra, IndiaMember Posts: 2,951 Bronze Crown

    Hi Dumitru Puscasu,

    Dumitru Puscasu wrote:
    
    Hi. First of all you need to setup port 8080
    as in your URL:  http://localhost:8080/apex/apex_admin
    EXEC DBMS_XDB.SETHTTPPORT(8080);
    Did you start ORDS as a standalone service or deploy it on application server?
    Did you configured ORDS (http://docs.oracle.com/cd/E56351_01/doc.30/e56293/toc.htm)?

         The Web Listener option ORDS has to do nothing with EPG(Embedded PL/SQL Gateway).  The above step of setting HTTP port is for EPG and not for ORDS.

    Regards,

    Kiran

  • Kiran Pawar


    Kiran Pawar


    Associate Projects — Oracle APEX Pune, Maharashtra, IndiaMember Posts: 2,951 Bronze Crown

  • Dumitru Puscasu

    Hi adamar.

    Usually, error 404 seems that you have problems with i.war archive (you need to create a war archive for apex image directory and make a static configuration in ords.war. Look at ORDS documentation.

    Did you do such stems?

    If you are using Oracle Application Express, you must create a web archive to reference the Oracle Application Express, image files. Before you begin, you must create a web archive (WAR) file to reference the Oracle Application Express image files. Use the static command to create a web archive file namedi.war:

    java -jar ords.war static <apex directory>images 

    Where:

    • <<span class="codeinlineitalic" style="font-style: italic;">apex directory></span> is the directory location of Oracle Application Express.

    The created images WAR does not contain the static resources; instead, it references the location where the static resources are stored. Therefore the static resources must be available at the specified path on the server where the WAR is deployed.

  • Kiran Pawar


    Kiran Pawar


    Associate Projects — Oracle APEX Pune, Maharashtra, IndiaMember Posts: 2,951 Bronze Crown

    Hi Dumitru Puscasu,

    Dumitru Puscasu wrote:
    
    
    
    Usually, error 404 seems that you have problems with i.war archive (you need to create a war archive for apex image directory and make a static configuration in ords.war. Look at ORDS documentation. Did you do such stems? If you are using Oracle Application Express, you must create a web archive to reference the Oracle Application Express, image files. Before you begin, you must create a web archive (WAR) file to reference the Oracle Application Express image files. Use the static command to create a web archive file namedi.war: java -jar ords.war static <apex directory>images

    Where:

    • <<span class="codeinlineitalic" style="font-style: italic;">apex directory></span> is the directory location of Oracle Application Express.

    The created images WAR does not contain the static resources; instead, it references the location where the static resources are stored. Therefore the static resources must be available at the specified path on the server where the WAR is deployed.

        The OP want’s to use ORDS 3.0.1 in Standalone Mode. Hence, there is no need to create i.war and deploy it. The i.war is required for ORDS deployed to Oracle WebLogic Server/Oracle Glassfish Server.

        The 404 is not raised for Static Files Configuration.

        Refer :

    • APEX 5 — Problem with Static Files after Installation
    • APEX 5.0: There are issues with the configuration of the Static Files in your environment

        Do you have ORDS 3.0.1 installable? If yes unzip it and read (what i have proposed in above reply):

    Also open your "ords.3.0.1.177.18.02" folder and run the "readme.html" file in a browser and check the section "404 Errors when configuring Oracle REST Data Services" regarding the causes for 404.
    
    

    Regards,

    Kiran

  • adamar

    First of all you have installed «Runtime Environment» for Oracle APEX 5.0 and «Runtime Environment» doesn’t have GUI as in «Development Environment». «Runtime Environment» has GUI access only for the applications deployed in it.

         I converted «Runtime Environment» to «Development Environment», as you suggested

         I followed all the steps, except cofiguring PL/SQL Gateway. I thougt wrongly it is related only with XML DB Protocol Server.

    Second thing : When you use Oracle REST Data Services as your Web Listener option, there is no /apex but /ords. So your APEX login links will be:

    • http://localhost:8080/ords/ (APEX Development)
    • http://localhost:8080/ords/apex_admin (APEX Instance Administration)

    I used the syntax with apex instead ords as it is written in e39147 — Application Builder User’s Guide.pdf (May 2015) page 34.

    Third thing : Regarding 404 — While configuring ORDS 3.0 have you skipped «PL/SQL Gateway» configuration? ( This step refers to configuring Oracle APEX with ORDS (configuring APEX_PUBLIC_USER) which is required for functioning of Oracle APEX with ORDS) ?     Else you will run in following error :

    • Re: Re: ORDS 3 404 Error
    • Re: problem with ords 3.0

    I skipped «PL/SQL Gateway» configuration. In one of the links I found detailed explanations how to proceed and with your help my problem was solved.

    Also open your «ords.3.0.1.177.18.02» folder and run the «readme.html» file in a browser and check the section «404 Errors when configuring Oracle REST Data Services» regarding the causes for 404.

    I did it and I noticed there was the answer at my problem.

    Lastly go through the following threads regarding installing Oracle APEX and configuring ORDS where I have discussed in detail errors faced during configuring ORDS and how to resolve them:

    • ORDS installation after APEX 5
    • Can’t get Apex 5 to work…

    I saved the links, I’ll read tomorrow. Now at us it is after midnight.

    Thanks for complete, competent and explicit answers.

    Best regards,

    adamar

This discussion has been closed.

when i accesss my web application hosted on local tomcat with localhost i see the expected welcome page but when i access it with ip address it does not work and give
404 error. I am not getting what is the issue with the link with ipaddress instead of localhost?

http://localhost:8080/wiki/ works fine
http://10.232.176.9:8080/wiki/ does not work

i have confirmed the ip address from ipconfig from command prompt. Its same.

Fahim Parkar's user avatar

Fahim Parkar

30.5k42 gold badges159 silver badges276 bronze badges

asked Feb 10, 2012 at 10:12

M Sach's user avatar

3

I’m almost sure it has something to do with what IP addresses the webserver is listening too. See this Apache documentation page to see how it’s done in Apache; which, I believe, Tomcat is based on…?

answered Feb 10, 2012 at 12:24

bart's user avatar

bartbart

7,5623 gold badges33 silver badges40 bronze badges

2

That seems like your external IP, so you might have a router/firewall blocking access.
Have you tried accessing with 127.0.0.1:8080, or from (another computer in your) network, using an IP like 10.1.1.X, 192.168.1.X or whathever your subnet is?

answered Feb 10, 2012 at 10:31

Marcelo's user avatar

MarceloMarcelo

4,5307 gold badges30 silver badges45 bronze badges

4

when i accesss my web application hosted on local tomcat with localhost i see the expected welcome page but when i access it with ip address it does not work and give
404 error. I am not getting what is the issue with the link with ipaddress instead of localhost?

http://localhost:8080/wiki/ works fine
http://10.232.176.9:8080/wiki/ does not work

i have confirmed the ip address from ipconfig from command prompt. Its same.

Fahim Parkar's user avatar

Fahim Parkar

30.5k42 gold badges159 silver badges276 bronze badges

asked Feb 10, 2012 at 10:12

M Sach's user avatar

3

I’m almost sure it has something to do with what IP addresses the webserver is listening too. See this Apache documentation page to see how it’s done in Apache; which, I believe, Tomcat is based on…?

answered Feb 10, 2012 at 12:24

bart's user avatar

bartbart

7,5623 gold badges33 silver badges40 bronze badges

2

That seems like your external IP, so you might have a router/firewall blocking access.
Have you tried accessing with 127.0.0.1:8080, or from (another computer in your) network, using an IP like 10.1.1.X, 192.168.1.X or whathever your subnet is?

answered Feb 10, 2012 at 10:31

Marcelo's user avatar

MarceloMarcelo

4,5307 gold badges30 silver badges45 bronze badges

4

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Loadpicture pascal abc ошибка
  • Loadout ошибка 0004 131007 steam временно недоступен