1

So I have a Tomcat 8.0.44. My web xml is:

 <?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">

<display-name>server-web</display-name>
<context-param>
    <param-name>isLog4jAutoInitializationDisabled</param-name>
    <param-value>true</param-value>
</context-param>
<context-param>
    <param-name>log4jConfiguration</param-name>
    <param-value>server-web/src/main/webapp/WEB-INF/log4j2.xml</param-value>
</context-param>
<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>
<servlet>
    <servlet-name>server-web</servlet-name>
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    <init-param>
        <param-name>jersey.config.server.provider.packages</param-name>
        <param-value>server</param-value>
    </init-param>
    <init-param>
        <param-name>jersey.config.server.provider.classnames</param-name>
        <param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>server-web</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

Neither my log4j config is OK, nor Tomcat can find a simple resource like this class:

@Path("/")
public class InitServerPoint {
Logger logger = LogManager.getLogger(InitServerPoint.class);

@GET
@Produces("text/html")
public Response getStartingPage() throws IOException {
    logger.error("Init log message");
    String output = "file path: " + file.getAbsolutePath() + "<h1>Hello 
 World!<h1>"
            + "<p>RESTful Service is running ... <br>Ping @ " + new 
 Date().toString() + "</p<br>";
    return Response.status(200).entity(output).build();

}

}

and when I type http://localhost:8080/server-web/ it returns 404. Can you please help me with configurations?

S. Korchev
  • 13
  • 1
  • 5
  • Is everything deployed correctly? Are you running Tomcat through Eclipse or cmd? – Shadov May 23 '17 at 14:53
  • I am running Tomcat with Eclipse. Strange thing is when I run it from cmd I can go to localhost:8080 page but when I run it from Eclipse I got this error – S. Korchev May 23 '17 at 14:58
  • I also noticed that the wtpwebapps/root/web.xml page is with version 2.5 for a web-app but mine web.xml ( in the project ) is 3.1.. – S. Korchev May 23 '17 at 15:00
  • What I do: click twice on your Tomcat in Servers view, in Server Locations pick `use Tomcat Installations`, set paths to your Tomcat installation and deploy path to webapps. – Shadov May 23 '17 at 15:02
  • I did that and did not help.. – S. Korchev May 23 '17 at 15:31
  • Is your project in the `webapps` folders of Tomcat installation? And check if `localhost:8080/manager` works (or whatever port you are using) – Shadov May 23 '17 at 15:41
  • When I start Tomcat from eclipse I can not go to localhost:8080/ or localhost:8080/manager neither. I dont know why it can not find these resources.. When I start it from Eclipse, Tomcat cant find any resources.. – S. Korchev May 23 '17 at 15:50
  • Ok when I copy ROOT folder from tomcat`s installation folder and replace the Root folder that Eclipse creates I can see the tomcat welcome page, but I still can not reach any of my resources.. – S. Korchev May 23 '17 at 16:00
  • When you choose `use Tomcat Installations` and give paths to your Tomcat Installation like I wrote few comments ago, the Eclipse folder doesn't matter, that's the point, it uses Tomcat folder, let's say `C:/Tomcat/webapps`, and your project should be there in that folder. If your project is there and you can't access it then check your deployment assembly. Also check this if you can't access manager: https://stackoverflow.com/questions/3535078/tomcat-manager-html-is-not-available – Shadov May 23 '17 at 16:35
  • I think that I miss some dependency in my pom.xml and i can not integrate properly Jersey and tomcat – S. Korchev May 23 '17 at 18:17

0 Answers0