Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere am I going wrong with this servlet in eclipse helios and tomcat 7 on mac?
    primarykey
    data
    text
    <p>I am trying to create a basic servlet with eclipse helios ee and tomcat 7. I can see that tomcat is working fine, because I can start the server from eclipse, point my browser at localhost:8080 and it comes up with the welcome page.</p> <p>So I created a servlet with the dynamic web project wizard, but I get a 404 when trying to view it. I can also see that there is no web.xml file for it in the WEB-INF directory. Should eclipse be creating that automatically or is that something I have to do? In all the tutorials I've seen, it seems like web.xml gets created automatically?</p> <p>Thanks for your help - sorry the question is a bit vague - I'm not really sure where to start looking for a solution..</p> <p>Thanks!</p> <p>EDIT: I've tried creating a web.xml file by hand. I can see that it's in the right place (I think) for the server to see it:</p> <p>/Users/bw/Documents/workspace2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/HelloWorld/WEB-INF/web.xml</p> <p>and the file looks like this:</p> <pre><code>&lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:/java.sun.com/dtd/web-app_2_3.dtd"&gt; &lt;servlet&gt; &lt;servlet-name&gt;hello&lt;/servlet-name&gt; &lt;servlet-class&gt;mytest.HelloWorld&lt;/servlet-class&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;hello&lt;/servlet-name&gt; &lt;url-pattern&gt;/hello&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt; </code></pre> <p>EDIT: Catalina log looks like:</p> <pre><code>Jun 1, 2011 11:37:56 AM 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: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java Jun 1, 2011 11:37:56 AM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:HelloWorld' did not find a matching property. Jun 1, 2011 11:37:56 AM org.apache.coyote.AbstractProtocolHandler init INFO: Initializing ProtocolHandler ["http-bio-8080"] Jun 1, 2011 11:37:56 AM org.apache.coyote.AbstractProtocolHandler init INFO: Initializing ProtocolHandler ["ajp-bio-8009"] Jun 1, 2011 11:37:56 AM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 1154 ms Jun 1, 2011 11:37:56 AM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Jun 1, 2011 11:37:56 AM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.14 Jun 1, 2011 11:37:57 AM org.apache.coyote.AbstractProtocolHandler start INFO: Starting ProtocolHandler ["http-bio-8080"] Jun 1, 2011 11:37:57 AM org.apache.coyote.AbstractProtocolHandler start INFO: Starting ProtocolHandler ["ajp-bio-8009"] Jun 1, 2011 11:37:57 AM org.apache.catalina.startup.Catalina start INFO: Server startup in 583 ms </code></pre> <p>EDIT:</p> <p>Tried removing the app from the server and got this:</p> <pre><code>Jun 1, 2011 12:03:28 PM org.apache.catalina.loader.WebappClassLoader modified SEVERE: Resource '/WEB-INF/classes/mytest/HelloWorld.class' is missing Jun 1, 2011 12:03:28 PM org.apache.catalina.core.StandardContext reload INFO: Reloading Context with name [/HelloWorld] has started Jun 1, 2011 12:03:29 PM org.apache.catalina.core.StandardContext resourcesStart SEVERE: Error starting static Resources java.lang.IllegalArgumentException: Document base /Users/bw/Documents/workspace2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/HelloWorld does not exist or is not a readable directory at org.apache.naming.resources.FileDirContext.setDocBase(FileDirContext.java:140) at org.apache.catalina.core.StandardContext.resourcesStart(StandardContext.java:4836) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5016) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3854) at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:424) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1205) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1391) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1401) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1401) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1380) at java.lang.Thread.run(Thread.java:637) Jun 1, 2011 12:03:29 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Error in resourceStart() Jun 1, 2011 12:03:29 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Error getConfigured Jun 1, 2011 12:03:29 PM org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/HelloWorld] startup failed due to previous errors Jun 1, 2011 12:03:29 PM org.apache.catalina.util.LifecycleBase stop INFO: The stop() method was called on component [Pipeline[StandardEngine[Catalina].StandardHost[localhost].StandardContext[/HelloWorld]]] after stop() had already been called. The second call will be ignored. Jun 1, 2011 12:03:29 PM org.apache.catalina.util.LifecycleBase stop INFO: The stop() method was called on component [WebappLoader[/HelloWorld]] after stop() had already been called. The second call will be ignored. Jun 1, 2011 12:03:29 PM org.apache.catalina.core.StandardContext reload INFO: Reloading Context with name [/HelloWorld] is completed </code></pre> <p>It looks like the classes aren't getting copied from the build directory to the server's area?</p> <p>EDIT:</p> <p>AHA! Finally found the problem. Well, there may have been several things.</p> <p>1) I tried deleting the server, and then creating a new one, and then adding the servlet. Seems like it may have got confused and not copied the necessary files across to the server area.</p> <p>2) Eclipse was giving me the wrong url for viewing the servlet. I was looking at /hello and I needed to look at HelloWorld/hello - it looks like perhaps Eclipse doesn't include the context when it suggests the url for the servlet? </p> <p>I'll post back when I have a clearer idea of what was going wrong..</p> <p>Thanks all for your help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload