简体   繁体   中英

It does not work in tomcat servlet with eclipse

I have installed tomcat with eclipse and I have a project with a servlet. Here I put the structure of both:

在此处输入图片说明

Until this day the steps followed to run the servlet were:

1.Press button right above the following and give "Start" Tomcat

在此处输入图片说明

2.Once booted, press right button over "UsuarioServlet.java" / Run as / Run on server

在此处输入图片说明

Done that everything worked properly but suddenly today when doing so I get the following:

在此处输入图片说明

What happened?.

I had this problem recently.

Here is what helped me. Start tomcat and search in the console the real path where your tomcat is running. Go there and open conf/server.xml . The plug-in that integrates tomcat and eclipse adds one long line there. Scroll down to see it. Here is how this line looks on my machine.

  <Context docBase="C:\workspaces\work7\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\ROOT" path="" reloadable="false"/><Context debug="0" docBase="C:\workspaces\work7\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\webapp" path="/mycompany-webapp-0.9-SNAPSHOT" reloadable="true" source="org.eclipse.jst.jee.server:webapp">
<Valve className="org.apache.catalina.valves.AccessLogValve" pattern="common" prefix="access_log." suffix=".txt"/>

Please pay attention on path attribute. It used to be /webapp but now it became /mycompany-webapp-0.9-SNAPSHOT . So, this is the real URL where the application is deployed.

I used to surf to my application using url http://localhost:8080/webapp . Now I have to use http://localhost:8080/mycompany-webapp-0.9-SNAPSHOT . Alternatively I can stop server, fix the path in server.xml manually, start server and use the "old" URL.

The point is that this behavior is not consistent. Sometimes (when project settings are being changed) this problem is fixed "automatically" but sometimes it returns. It happened not only on my machine but on computers of 2 other team members in company where I work.

I hope this information will help you. Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM