HTTP Status 404 while trying to run my servlet - java

I have a dyanmic web project with a DAO FileDao in package de.vogella.wtp.filecounter.dao; and a servlet FileCounter in package de.vogella.wtp.filecounter.servlets; packages respectively.
I was trying to run the servlet and changed the ports 8088 since my 8080 is already occupied with some other application. When I run this servlet I get the below error in console:
Jun 1, 2012 2:39:13 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting propert
y 'source' to 'org.eclipse.jst.jee.server:de.vogella.wtp.filecounter' did not fi
nd a matching property.
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8088"]
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8010"]
Jun 1, 2012 2:39:13 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 380 ms
Jun 1, 2012 2:39:13 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 1, 2012 2:39:13 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.27
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8088"]
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8010"]
Jun 1, 2012 2:39:13 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 260 ms
This is the error:
HTTP Status 404 - /de.vogella.wtp.filecounter/servlet/de.vogella.wtp.filecounter.servlets.FileCounter
--------------------------------------------------------------------------------
type Status report
message /de.vogella.wtp.filecounter/servlet/de.vogella.wtp.filecounter.servlets.FileCounter
description The requested resource (/de.vogella.wtp.filecounter/servlet/de.vogella.wtp.filecounter.servlets.FileCounter) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/7.0.27
Any guesses on what went wrong?

HTTP Error 404 means page or resources not found.
So you just typed incorrect URL. just check URL in web.xml and the URL typed in browser.
Here, maybe FileCounter class is misplaced. check it too.

I was doing the same tutorial and had the same problem. I guess it's a pretty common tutorial, so I'll leave my answer here.
In my installation, Eclipse does not create a web.xml by default. When creating a Servlet, Eclipse uses annotations for mapping. I accidentaly erased the annotation when copying the tutorial's code. I guess you did the same.
To solve it I included a #WebServlet annotation before the class. Like this:
#WebServlet("/FileCounter")
public class FileCounter extends HttpServlet {
...

Related

Tomcat is automatically shutting down

I have installed Tomcat 7 with Java 7 on a debian box. It has 512 MB of RAM. I run tomcat out of the box, I have installed nothing, and it is consistently shutting down by itself. I am not even browsing the Tomcat landing page.
As you can see, it is running perfectly normal and then all of a sudden it stops:
Jul 21, 2013 6:11:20 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jul 21, 2013 6:11:20 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 1063 ms
Jul 21, 2013 8:22:35 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Jul 21, 2013 8:22:35 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Jul 21, 2013 8:22:35 AM org.apache.catalina.core.StandardService stopInternal
It just mysteriously stops. What can it be? I know the Tomcat distribution and the Java distribution are good because I downloaded them from the Tomcat site and Oracle, and FTP'd them over to my server.
There are no other errors in any other tomcat log files. Is is a permissions thing? Memory issue? Appreciate your help.
I think a memory issue would show up in the log. I would simply reinstall Tomcat and check if it's still buggy.

Tomcat 7 not starting in Eclipse 4.2 (timeout). How to get more verbose output?

I am really struggling with an Eclipse project where Tomcat is giving me timeout. I thought at first this might be a mistake I did in some project configuration, so I reverted to an earlier version of my code. However this is still giving the same error! When I try to start a new project (Spring MVC) along the existing one, the new one seems to work fine and (if I disable the non-working one) the server now starts.
My question really is: How can I get more verbose output or log from Tomcat? The server telling me "it was unable to start within the time limit" does not really help me. Most of the solutions I have found for this kind of problem arent really solutions either, but "remove the server and add it again" or "Delete your eclipse workspace and start over again", etc. Is it really not possible to get Tomcat 7 to do some proper debug-logging to tell me whats going on?
The following is all the output I get:
mai 03, 2013 1:17:45 PM org.apache.catalina.core.AprLifecycleListener init
mai 03, 2013 1:17:46 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:kneip' did not find a matching property.
mai 03, 2013 1:17:46 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
mai 03, 2013 1:17:46 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
mai 03, 2013 1:17:46 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 666 ms
mai 03, 2013 1:17:46 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
mai 03, 2013 1:17:46 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
mai 03, 2013 1:17:57 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Fri May 03 13:17:57 CEST 2013]; root of context hierarchy
INFO : org.springframework.context.annotation.ClassPathBeanDefinitionScanner - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
INFO : org.springframework.web.context.support.AnnotationConfigWebApplicationContext - Successfully resolved class for [net.krg.kneip.AppConfig]
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#4cb8a2a9: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,appConfig,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,camel,jmsConfig,activeMq,pooledConnectionFactory,jmsConnectionFactory,applicationContextProvider]; root of factory hierarchy
Thanks in advance!
In the end you need to increase the timeout limit for startup of tomcat from eclipse.
Double click on the Server ("Apache Tomcat") within the "Servers" view.
Open the "Timeouts" Section
increase "Start (in seconds)" to 120
(this does not lead to more log information, but it should solve your problem.)

Jsp+Java application execution not working

I'm sorry of being so general, but I have a problem with my application execution and I have no idea of what it could be.
It's made by Jsp and Java parts, and developed with Eclipse. It uses a Postgresql database and an Apache Tomcat server.
When I click on Run As -> Run On Server, the program stops immediately. This is what Eclipse shows:
And this is what the console prints:
17-lug-2012 14.53.31 org.apache.catalina.core.AprLifecycleListener
init INFO: The APR based Apache Tomcat Native library which allows
optimal performance in production environments was not found on the
java.library.path:
C:\Programmi\Java\jdk1.6.0_21\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Programmi/Java/jre6/bin/client;C:/Programmi/Java/jre6/bin;C:/Programmi/Java/jre6/lib/i386;C:\Programmi\CollabNet\Subversion
Client;C:\Programmi\MiKTeX
2.9\miktex\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;
c:\Programmi\Microsoft
SQL
Server\90\Tools\binn\;C:\Programmi\Intel\DMIX;C:\Programmi\Intel\WiFi\bin\;C:\Programmi\MATLAB\R2010a\runtime\win32;C:\Programmi\MATLAB\R2010a\bin;C:\Programmi\File
comuni\Autodesk
Shared\;C:\Programmi\R-Language\R-2.13.1\bin\;C:\Programmi\R-Language\R-2.13.1\bin\;C:\Programmi\OpenVPN\bin\;
C:\Programmi\Java\jdk1.6.0_21\bin\ 17-lug-2012 14.53.31
org.apache.tomcat.util.digester.SetPropertiesRule begin
AVVERTENZA:
[SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting
property 'source' to 'org.eclipse.jst.jee.server:BioTesiWeb' did not
find a matching property. 17-lug-2012 14.53.32
org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"] 17-lug-2012 14.53.32
org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"] 17-lug-2012 14.53.32
org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 460 ms 17-lug-2012 14.53.32
org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina 17-lug-2012 14.53.32
org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.6 17-lug-2012 14.53.32
org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"] 17-lug-2012 14.53.32
org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"] 17-lug-2012 14.53.32
org.apache.catalina.startup.Catalina start
INFO: Server startup in 401
ms
Have you any idea of why the execution of the program fails?
Are there some libraries missing?
Have I forgot something?
Please give more details...
For now just Check ur Servlet mapping in web.xml ? And also the servlet is named correctly...
Take a look at the below links for the error your getting
https://stackoverflow.com/questions/2231163/what-tomcat-native-library-should-i-be-using-in-production
APR based Apache Tomcat Native library was not found on the java.library.path?

Tomcat auto unpack WAR file changed the last modified time of files

I experienced an issue when I tried to deploy a WAR file to tomcat.
While the auto unpack process from tomcat, the last modified date of unpack files were being modified.
The date of unpack web app. files became 12 hours faster, and this results several miscellaneous errors.
I tried to unpack manually via jar -xvf, the last modified date of files remain unchanged.
I also tested in a local tomcat (same timezone with dev. env.), nothing changed in last modified date.
It seems the tomcat timezone issue, does setup on tomcat I can do to solve out this issue?
Great thanks for any help.
Environment:
Tomcat 6 on linux, with GMT-4 timezone both set in server and tomcat
the WAR file created by machine with GMT+8 timezone set
In my case, the application was setting the default timezone from within Tomcat as the application was being initialized. The difference introduced by the change in timezones matched the offset in the file modification times.
I was surprised that any code within the app could run before being unpacked, but the Tomcat container does give the application an opportunity to run initialization code prior to all files being unpacked.
Look for an occurrence of TimeZone.setDefault() and try removing the call or moving the call later in the initialization sequence.
Helpful clues:
This JSP told me that the application was always running with a specific timezone regardless of the environment settings:
<html>
<body>
<h2>Current Timezone</h2>
<% java.util.Date date = new java.util.Date();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("zzz"); %>
<%=sdf.format(date)%>
</body>
</html>
In the log files, I could see the instant the timezone was changing (four hour jump). It happens at the time the app is loaded.
Note: Once set, the timezone will stay set until Tomcat is restarted.
Sep 18, 2015 2:34:26 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8443
Sep 18, 2015 2:34:26 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 285 ms
Sep 18, 2015 2:34:26 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Sep 18, 2015 2:34:26 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.24
Sep 18, 2015 2:34:26 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive myWebapp.war
Sep 18, 2015 6:34:30 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Sep 18, 2015 6:34:34 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.UrlRewriteFilter INFO: loaded (conf ok)
Sep 18, 2015 6:34:34 PM org.apache.catalina.core.ApplicationContext log
INFO: struts: []: Verifying ModuleConfig for this module
Sep 18, 2015 6:34:34 PM org.apache.catalina.core.ApplicationContext log
INFO: struts: []: Verification of ModuleConfig has been completed
Sep 18, 2015 6:34:34 PM org.apache.catalina.core.ApplicationContext log
INFO: struts: []: Verifying ModuleConfig for this module

Tomcat Java GC Issue Linux

I am running a Tomcat Web Server(7.0) on Ubuntu. I have the same War file using Java 1.6 in my local Windows machine and I face no issues whatsoever. However, on the linux machine my tomcat fails after some time or stops working and I get Java GC exceptions. It starts with these errors :
Jul 10, 2011 4:29:05 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/manager]
Jul 10, 2011 4:29:05 PM org.apache.catalina.session.StandardManager doUnload
SEVERE: IOException while saving persisted sessions: java.io.FileNotFoundException: /home/infocomm/tomcat/work/Catalina/localhost/manager/SESSIONS.ser (No such file or directory)
java.io.FileNotFoundException: /home/infocomm/tomcat/work/Catalina/localhost/manager/SESSIONS.ser (No such file or directory)
Then these errors:
Jul 10, 2011 4:29:05 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
WARNING: JDBC driver de-registration failed for web application [/manager]
java.lang.NullPointerException
at org.apache.catalina.loader.WebappClassLoader.clearReferencesJdbc(WebappClassLoader.java:2012)
at org.apache.catalina.loader.WebappClassLoader.clearReferences(WebappClassLoader.java:1948)
at org.apache.catalina.loader.WebappClassLoader.stop(WebappClassLoader.java:1860)
at org.apache.catalina.loader.WebappLoader.stopInternal(WebappLoader.java:659)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:216)
at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5032)
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:216)
at org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:952)
at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1199)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1360)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:290)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1228)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1384)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1394)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1373)
at java.lang.Thread.run(Thread.java:619)
Jul 10, 2011 4:29:05 PM org.apache.catalina.util.LifecycleBase destroy
INFO: The destroy() method was called on component [StandardContext[/manager]] after destroy() had already been called. The second call will be ignored.
Jul 10, 2011 4:29:05 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context []
Jul 10, 2011 4:29:05 PM org.apache.catalina.session.StandardManager doUnload
Then Finally TOmcat stops responding with these errors:
Jul 10, 2011 5:07:44 PM org.apache.catalina.util.LifecycleBase destroy
INFO: The destroy() method was called on component [StandardContext[/host-manager]] after destroy() had already been called. The second call will be ignored.
Jul 10, 2011 6:31:44 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor rcbp.xml from /home/infocomm/tomcat/conf/Catalina/localhost
Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" java.lang.OutOfMemoryError: PermGen space
Would Appreciate any help.
This only happens after I exit the remote shell with which I started the Tomcat Application.
does tomcat (when running with a specific user account) has access to this file, it should have enough privilege create, update & delete the file.
/home/infocomm/tomcat/work/Catalina/localhost/manager/SESSIONS.ser
in windows its very rare for this scenario to surface unless you've started tomcat as an unprivileged user.

Categories