GlassFish 3.1.2 在部署时提供 404 而没有任何错误

Posted

技术标签:

【中文标题】GlassFish 3.1.2 在部署时提供 404 而没有任何错误【英文标题】:GlassFish 3.1.2 gives 404 without any error on deployment 【发布时间】:2012-12-02 01:28:20 【问题描述】:

我尝试将一个非常简单的 helloworld.war 部署到 ubuntu 10.04 上的 glassfish 3.1.2 服务器。在我的电脑上它工作正常,但在我的服务器上我总是得到一个 404 页面。 我的服务器上没有错误。有人有想法吗?

我注意到另一个奇怪的行为。重新启动服务器后,我无法登录管理控制台。我总是得到验证失败重新输入您的用户名和密码。当我重新启动 glassfish 时,它又可以工作了。

这听起来很熟悉,但我不明白他的解决方案对我有什么帮助。 glassfish autodeploy gives 404 with simple app

[#|2012-12-14T02:53:30.368+0100|INFO|glassfish3.1.2|org.glassfish.admingui|_ThreadID=71;_ThreadName=Thread-2;|uploadFileName=HelloWorld-1.0-SNAPSHOT.war|#]

[#|2012-12-14T02:53:30.605+0100|INFO|glassfish3.1.2|javax.enterprise.resource.webcontainer.jsf.config|_ThreadID=135;_ThreadName=Thread-2;|Mojarra 2.1.6 (SNAPSHOT 20111206) für Kontext '/HelloWorld-1.0-SNAPSHOT' wird initialisiert.|#]

[#|2012-12-14T02:53:30.729+0100|INFO|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=135;_ThreadName=Thread-2;|WEB0671: Loading application [HelloWorld-1.0-SNAPSHOT] at [/HelloWorld-1.0-SNAPSHOT]|#]

[#|2012-12-14T02:53:30.883+0100|INFO|glassfish3.1.2|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=135;_ThreadName=Thread-2;|HelloWorld-1.0-SNAPSHOT was successfully deployed in 482 milliseconds.|#]

index.xhtml

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <h:body>
        Hello from Facelets
    </h:body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<context-param>
    <param-name>javax.faces.PROJECT_STAGE</param-name>
    <param-value>Development</param-value>
</context-param>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
    <session-timeout>
        30
    </session-timeout>
</session-config>
<welcome-file-list>
    <welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>

【问题讨论】:

【参考方案1】:

我猜你在名为 faces 的目录中没有 index.xhtml...试试这个:

<welcome-file-list>
    <welcome-file>index.xhtml</welcome-file>
</welcome-file-list>

【讨论】:

好的..我注意到它仍然可以工作......你打电话给哪个网址? over Application -> 午餐它给了我 IP:8080/HelloWorld-1.0-SNAPSHOT 但我也试过 IP:8080/HelloWorld。 @user1902794 我遇到同样的错误你找到解决办法了吗? @Sanshai28 不,不是。我不能再复制它了。服务器设置更改并且错误消失了。现在我在一个带有最新 oracle java 版本的 docker 容器中使用 GlassFish 4。 @user1902794 无论如何,谢谢您的回复:-)

以上是关于GlassFish 3.1.2 在部署时提供 404 而没有任何错误的主要内容,如果未能解决你的问题,请参考以下文章

气氛无法在 Glassfish 3.1.2 上获得会话

部署期间出现 NoSuchMethodException

glassfish - springboot - 部署应用程序时出错

在Glassfish上部署Web应用程序时出错

在 Glassfish 中部署战争文件失败

在Glassfish 5.0中部署ADF WEbapp时出错