Какой мой URL в этом сервлете JBOSS / Wildfly? - PullRequest
0 голосов
/ 19 февраля 2019

Я пытаюсь освоить разработку Wildfly.Я использую книгу Франческо Марчиони "Разработка Java EE 7 с использованием WildFly".Я просто пытаюсь заставить работать сервлет Hello World, но я получаю сообщение об ошибке 404 при переходе к «http://localhost:8080/hello/test».Согласно книге, @ WebServlet ("/ test") отказывается от требования использовать файл web.xml.У кого-нибудь есть какие-либо идеи?

Вот файл Webcontent / WEB_INF / jboss-web-xml

<jboss-web>
    <context-root>/hello</context-root>
 </jboss-web> 

и TestServlet.java

package com.packtpub.wflydevelopement.chapter2;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class TestServlet
 */
@WebServlet("/test")
public class TestServlet extends HttpServlet {

    private static final String CONTENT_TYPE = "text/html;charset=UTF-8";
    private static final String MESSAGE = "<!DOCTYPE html><html>" + "<head><title>Hello!</title></head>"
        + "<body>Hello World WildFly</body>" + "</html>";

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType(CONTENT_TYPE);
        try (PrintWriter out = response.getWriter()) {
            out.println(MESSAGE);
        }
    }
}

Также является частью журнала запуска.

0:42:58,166 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-4) ISPN000128: Infinispan version: Infinispan 'Estrella Galicia' 9.3.1.Final
20:42:58,828 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 72) WFLYCLINF0002: Started client-mappings cache from ejb container
20:42:59,676 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 74) WFLYUT0021: Registered web context: '/hello' for server 'default-server'
20:42:59,693 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 42) WFLYSRV0010: Deployed "HelloWorld.war" (runtime-name : "HelloWorld.war")
20:42:59,904 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
20:42:59,913 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
20:42:59,914 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
20:42:59,914 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 14.0.1.Final (WildFly Core 6.0.2.Final) started in 27197ms - Started 405 of 590 services (326 services are lazy, passive or on-demand)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...