HTTP Status 404 - on Eclipse with Tomcat - eclipse

I am trying just to run a servlet on my local Tomcat with Eclipse.
But I keep getting this error and do not have any idea what to do differently.
I actually recorded it here : http://www.screenr.com/ZyD8
Many thanks!
Also I changed the web.xml to this:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID"
version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" >
<display-name>
TEST3
</display-name>
<welcome-file-list>
<welcome-file>
TEST3
</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>
helloServlet
</servlet-name>
<servlet-class>
HelloServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
helloServlet
</servlet-name>
<url-pattern>
/hello
</url-pattern>
</servlet-mapping>
</web-app>

I have seen your link.
When ever you run any dynamic web project. By default Servlet container (which is Tomcat in this case) searches for files specified in wel-come list. Check your web.xml, it should contains entry like
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
You haven't created file from any of the above list. So, running
http://localhost:8080/TEST2 will give you 404 error.
Rather run : http://localhost:8080/TEST2/HelloSerlvet will invoke the servlet which you have created.
Edit: Check Project Menu of eclipse and verify "Build Automatically" is checked and Servlet container is running (http://localhost:8080).
Edit 2: Right Click Project --> Properties, Select Java Build Path --> source Tab --> Change Default output folder. Create /WEB-INF/classes
under /WebContent (default in eclipse)

This is based on the answer from Hardik Mishra with some highlights:
1. From the file explorer (not from Eclipse), Manually create the "/WEB-INF/classes" under /WebContent
2. Right Click Project --> Properties, Select Java Build Path --> source Tab --> Change Default output folder to the folder you just created above.
3. go to the file explorer, not from Eclipse, since the Eclipse "project Explorer" may have some filters that doesnot show the classes folder. You should see the .class files compiled under this directory
Try to test it again. If it does not work, restart Eclipse for one time and then it should work.

I have been seeing these types of issue for quite sometime and have seen multiple solutions which work for some and rest still face the same issue.
One of the simple solution is traverse to the .java/.jsp/etc., right click and select run from server option.
I found this solution to be simple yet effective way of running.
path Java Resource->src->->example.java-->right click-->run as-->run on server.
Even after this also you can face few issues like port 8005 not available, please follow the below link to clean out your current Apache setting and re-setting the same.
TOMCAT - HTTP Status 404
Deployment error:Starting of Tomcat failed, the server port 8080 is already in use
Hope this finding was helpful.

Normally, when you modify the web.xml file, you should "clean" Tomcat. Just right-click on Tomcat in Eclipse and clean. Do same for project. You may also stop Tomcat, remove the app from Tomcat (right-click on app under Tomcat and remove) and then add it back. Restart Tomcat.

I am gonna divide this problem in two scenarios:
scenario 1: you are trying to run/execute html/jsp file but getting this error.
scenario 2: you have successfully executed jsp/html file but it is not executing next servlet file. example: there is jsp submit form in webcontent/webapp, it is getting executed but after filling and submitting form you are getting this error.
Scenario 1:
Make sure that your jsp/html file are in webcontent/webapp folder that you created at the time of project creation.
check web.xml file where content should be like this:
try changing tomcat server version.
Scenario 2:
at this level your main culprit is web.xml file where you have to check Servlet mapping thoroughly or add webservlet annotation at file level.

Related

How to check whether ear is deployed correctly in weblogic 12c?

I have an application ear which I am trying to deploy into Oracle Weblogic 12c server. I following instructions given on this site.
After following those steps, I tried to hit the url "http://localhost/myApp/servlet" where myApp is specified in application.xml file and servlet is specified in web.xml file. This web.xml file is located with the .war file and this war file is within the .ear file.
My application.xml looks like below :
<application xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd" version="1.4">
<description>This is my application</description>
<display-name>myApp</display-name>
<module>
<web>
<web-uri>myApp.war</web-uri>
<context-root>/myApp</context-root>
</web>
</module>
</application>
and my web.xml looks like as below :
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>com.foo.bar.MyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServlet</servlet-name>
<url-pattern>servlet</url-pattern>
</servlet-mapping>
When I hit the url on browser, I get 404 (Not Found) error. I am trying to deploy any ear/war on weblogic 12c for the first time so I do not know what is going wrong. I checked server logs too, but there's no stack trace or error.
Request you to please help !!!
Open your Admin Console and you can see if the deploy is deployed correctly.
In NetBeans IDE you go do Services > Servers > Oracle Weblogic Server > right click on Oracle Weblogic and select View Admin Console.
Them you have to login you session and in the menu on left side of your screen, you have deployment. In this part you can see if the deployment is correct.
I hope this will help you.

How to customize JBoss AS7 404 page

I already created a custom 404 page inside my web app deployed in JBoss AS 7.1.
So if my app is at fubar dot com :8080/Myapp and I go to fubar dot com :8080/Myapp/xyzzy, I get the custom error page (defined in the web app's web.xml file).
However, when I go to fubar dot com :8080/xyzzy, JBoss displays the default 404 page which discloses that it's JBoss and which JBoss version.
I need to replace this page in order to hide this information.
Please advise.
If you want to customize the error pages for all the other contexts in JBoss 7, a part of the configuration you have in your Myapp application, you'll also have:
to disable JBoss welcome page: in the file standalone/configuration/standalone.xml (or domain/configuration/domain.xml), set the attribute enable-welcome-root as false (by default it's true)
Then you'll have to deploy a simple war file setting its context-root to '/', and define the error page for this war (using the same method you've used for Myapp). So, the war structure should be similar to (the error.war name is arbitrary):
error.war
|
|- META-INF
|- WEB-INF
| |
| |- web.xml
| |- jboss-web.xml
|
|- error
|- 404.html
where The web.xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>yourcompanyname</display-name>
<error-page>
<error-code>404</error-code>
<location>/error/404.html</location>
</error-page>
</web-app>
And in the jboss-web.xml define the context-root as '/', so it would be:
<jboss-web>
<context-root>/</context-root>
</jboss-web>
The file 404.html is your customized html error page that Jboss will show instead of the 404 default error. That's all, deploy this application in JBoss 7, and you'll have your custom 404 error page when you'll visit fubar dot com:8080/yzyqqa or whatever other root context. Remember that you'll have to keep the error configuration in your Myapp web.xml as well (and in all the other applications you may the deploy in the server).
By the way, have you considered making your app Myapp accessible directly from fubar dot com:8080? Or even better, making the jboss server only accessible from a proxy (for example Apache)?.This way you'd avoid this problem as well.
I hope it helps!
Your problem : You defined the custom error page in web.xml of Myapp. Now if you access any resource with root as Myapp and the request throws a 404 it returns the custom error page.
Now you want that if you access any other root , here xxyzzzz you want to return the custom error page.
Now logically, if you configured a file for other project you cant expect it to be same for other project
Unless
either you configure the same thing for other project , i.e. xxxyzzz as well. i.e. place the 404 config in its web.xml aswell.
or you need to do something at the server scope.
the 1st solution is fairly simple and easy in case there are less number of projects and you not expecting a URL that does not match any of the project.
if you want to go with 1st solution, you know how to do it
Regarding the 2nd approach.
I could find some posts that should be helpful to you
refer these
with jboss as7, the custom of global web.xml is gone.
I could find only one way to configure a global 404 error page. refer here. IT WORKS :D
Custom error pages in Apache for JBoss AS7
I believe you will have to create your own page. JBoss uses Tomcat for serving the web requests.
In Tomcat the way to define your own 404 response page is having the following snippet in your web.xml
(Ref - http://wiki.apache.org/tomcat/FAQ/Miscellaneous#Q6)
<error-page>
<error-code>404</error-code>
<location>/error/404.html</location>
</error-page>
A detailed page on how to do this with struts is created by mykong # http://www.mkyong.com/struts/how-to-handle-404-error-in-struts/.
If you are using any other framework than struts you should have a equivalent.

PrimeFaces components are not displaying when adding PrimeFaces library as "external JAR" to Eclipse project

I tried setting up the PrimeFaces library. So i added the primefaces-3.4.1.jar using the 'add external jar' command. Than I added the namespace: xmlns:p="http://primefaces.org/ui to the html tag. According to the official documentation that is all there is to it, for setting it up.
I tried adding a <p:editor/> componenet to my page, but it is not displayed.
My project configuration is: Eclipse, JSF 2.1 on Glassfish 3.1
Apparently you did the "add external jar" command wrong. It's not clear from the question how exactly you performed this step, but this should be just a matter of dropping the JAR file in its entirety in the project's /WEB-INF/lib folder the usual way (as you would do for every 3rd party JAR file the webapp depends on). The way you put the question indicates that you weren't aware about this after all.
Really nothing more needs to be done. If you have fiddled around in project's Build Path properties, then you should undo that all to avoid possible collisions in the future. Eclipse is smart enough to set the necessary things automatically right whenever you drop a JAR in projects's /WEB-INF/lib folder.
See also:
How to add JAR libraries to WAR project without facing java.lang.ClassNotFoundException? Classpath vs Build Path vs /WEB-INF/lib
I guess this is the same problem & solution: Simple primefaces application not working
missing servlet-mapping in web.xml:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
The PrimeFaces jar (primefaces-7.0.jar in my case) has to be available in the folder /WEB-INF/lib at runtime.

GWT Servlet error com.google.gwt.user.client.rpc .StatusCodeException: 404 on Tomcat server

1) Installed GWT and Eclipse on Mac
2) Created a GWT project (2.4) with generated code called Hello
3) Ran the project on local computer (in dev mode) and it works as expected.
4) Compile the project and upload the war directory to my account hosted by serversanddomains.com
The production front end works fine, but when I try the RPC request I get the following error.
com.google.gwt.user.client.rpc.StatusCodeException: 404
Not Found
The requested URL /hello/greet was not found on this server.
I tried compiling with different versions of java as suggest by How to use GWT - RPC to Tomcat server
Serversanddomains.com currently runs Tomcat and java 1.6.0_29
I asked to see the error log and they responded
Here is the error we are seeing in the error log:
File does not exist: /home/username/public_html/hello/greet, referer: http://mydomain.com/Hello.html
And in the /usr/local/jakarta/tomcat/logs/catalina.out log file no reports of anything.
My web.xml file is:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee">
<!-- Servlets -->
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>com.hello.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/hello/greet</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Hello.html</welcome-file>
</welcome-file-list>
</web-app>
Any suggests would be welcome.
Cheers
As a rule of thumb, shared hosting accounts are usually just apache virtual hosts. Apache is just a web server. To host a GWT app that uses RPC, you need an application server, like Tomcat, Jetty (used by GWT Dev Mode), GlassFish and others.
You will NEVER be able to do that from a shared hosting account, because it's just not possible. You need to get a VPS dedicated server and set everything up yourself, usually.
It looks like your server is not set up to be a servlet container. It does not know how to serve /hello/greet, which your GWT app defines in web.xml.
You should ask your host if they offer hosting that supports this sort of java servlet environment.

Tomcat 404 error in Eclipse - For any page except Welcome page

I am trying to run a website in Eclipse using Tomcat, but I just can view the welcome page. Any link or URL to other pages bring error 404. What I've done so far:
I use a Dynamic Web Project, with some jsp pages. There are no errors in the files.
I've tried Tomcat 6 & 7 servers, and I can see the tomcat default page (http://localhost:8080).
Everything seem fine in Tomcat server configurations, including HTTP port, Arguments, etc.
When I run the server, I'm able to see the Welcome page using http://localhost:8080/.
When I click on a link to another page in directory (ref to http://localhost:8080//), or I redirect to http://localhost:8080// I receive the 404 error.
I tried cleaning server, running new servers, renaming web file names, etc; but the problem remains.
The files also seem OK in the Tomcat wtpwebapps folder.
The website Web.xml is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>ERF_Prototype</display-name>
<welcome-file-list>
<welcome-file>/WEB-INF/Prototype.jsp</welcome-file>
</welcome-file-list>
</web-app>
Any Idea how to solve the problem?
Thanks
Update----------------------------------------------------------------
Problem not solved; I am just trying to avoid it by exporting website to .War, and then import it using tomcat manager.