首页 > 解决方案 > META-INF/application.xml 中的文件过早结束

问题描述

我已经通过 maven 3 创建了一个 Web 应用程序,并且在项目结构中有 myartifactid/META-INF/application.xml 文件。这包含:

<?xml version="1.0" encoding="UTF-8"?>
<application 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/application_8.xsd"
             version="8">

</application>

我正在使用带有 jdk 1.8.0_191 的 GlassFish 5。每当我启动服务器时,我都会收到以下错误(文件过早结束。有关更多详细信息,请参阅 server.log。在 application.xml 中):

Successfully started the domain : domain1
domain  Location: /usr/applicationserver/glassfish5/glassfish/domains/domain1
Log File: /usr/applicationserver/glassfish5/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.
Connected to server
[2018-11-14 11:45:33,345] Artifact myproject: Artifact is being deployed, please wait...
[2018-11-14 11:45:35,767] Artifact myproject: Error during artifact deployment. See server log for details.
[2018-11-14 11:45:35,767] Artifact myproject: java.io.IOException: com.sun.enterprise.admin.remote.RemoteFailureException: Error occurred during deployment: Exception while deploying the app [myproject] : org.xml.sax.SAXParseExceptionpublicId: http://www.oracle.com/technetwork/java/index.html; lineNumber: 1; columnNumber: 1; Deployment descriptor file META-INF/application.xml in archive [myproject].  Premature end of file.. Please see server.log for more details.

在 Intellij 中,它给我一个错误“必须声明元素应用程序”。环顾四周,这个文件似乎被用作 javaeeApplication 的部署描述符。在 Intellij 的 myproject.iml 文件中,我有:

<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
  <component name="FacetManager">
    <facet type="javaeeApplication" name="javaEEApplication">
      <configuration>
        <descriptors>
          <deploymentDescriptor name="application.xml" url="file://$MODULE_DIR$/META-INF/application.xml" />
        </descriptors>
      </configuration>
    </facet>
    <facet type="web" name="Web">
      <configuration>
        <descriptors>
          <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/web/WEB-INF/web.xml" />
        </descriptors>
        <webroots>
          <root url="file://$MODULE_DIR$/web" relative="/" />
        </webroots>
        <sourceRoots>
          <root url="file://$MODULE_DIR$/src/main/java" />
        </sourceRoots>
      </configuration>
    </facet>
  </component>
</module>

标签: javaglassfish

解决方案


部署描述符中的 URL 错误。java.sun.com 的所有用途都应该是 xmlns.jcp.org。如果您的部署描述符是由某个程序创建的,请将此错误报告给该程序的所有者。如果您的应用程序在更正此错误后无法部署,请相应地更新您的帖子。


推荐阅读