WebSphere应用服务器8:错误404:java.io.FileNotFoundException:SRVE0190E:文件未找到:

7
我希望能在WAS8.5.5.2中部署应用程序。我已经制作了具有以下结构的ear包:
serverEar.ear -- serverWar.war ---- WEB-INF ---- 'web'目录内容
我拥有application.xml文件:
 <application version="6" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" >
    <module>
        <web>
            <web-uri> serverWar.war</web-uri>
            <context-root>serverWar</context-root>
        </web>
    </module>

    <library-directory> web/lib</library-directory>

</application>

web.xml:

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

    <servlet>
        <servlet-name>p1</servlet-name>
        <servlet-class>com.test.Server</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>p1</servlet-name>
        <url-pattern>/server</url-pattern>
    </servlet-mapping>

    <security-constraint>
        <display-name/>
        <web-resource-collection>
            <web-resource-name/>
            <description/>
            <url-pattern>/*</url-pattern>
            <http-method>POST</http-method>
            <http-method>GET</http-method>
        </web-resource-collection>
        <user-data-constraint>
            <description/>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>

</web-app>

我有以下目录结构:

enter image description here

我已经从WAS ibm/console安装了应用程序。安装目录是 ..\Desktop\Test\out\artifacts\serverEar ,我的ear文件放在这里(不确定安装目录是否会影响此问题?)。
应用程序已成功安装并已启动。
我尝试了URL:https://my_server:9443/serverWar/server,但它给了我:Error 404:java.io.FileNotFoundException:SRVE0190E:未找到文件:/server 我以前从未处理过WAS,也不确定我可能犯了什么错误。
非常感谢任何建议和指针!
2个回答

4
好的,问题现在已经解决。问题是上下文根未设置为 serverWar,因此无法识别 serverWar/server 的服务器 url。所以我按照以下步骤从 IBM 控制台设置上下文根来解决这个问题。
在解决了这个问题之后,我遇到了另一个相关的问题: Error 404: javax.servlet.UnavailableException: SRVE0200E: Servlet: Could not find required class 看起来我们需要在WEB-INF中有一个 classes 目录,但由于某些原因 IntelliJ 没有创建这个目录。以上结构对 WildFly 和 WebLogic 都有效。因此,在 WAS 上部署 ear 文件时,你只需要从production目录复制 classes。这让我的应用程序如预期地工作。
在进行了以上所有更改后,我可以成功访问 url:https://my_server:9443/serverWar/server
希望这能帮助那些新手使用 WAS!

0
希望这篇文章能帮助到其他人,因为我花了很多时间才找到原因:
当我尝试在 WAS 8.5 上部署 WAR 文件时,我遇到了同样的问题。在我的情况下,问题是这个 WAS 使用的是 Java JDK 6,而我的应用程序需要 JDK 8。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接