我正在尝试在 IntelliJ IDEA 上创建一个简单的 RESTful Web 服务,但现在遇到以下错误:
The content of element 'application' is not complete. One of '{"http://java.sun.com/xml/ns/javaee":description, "http://java.sun.com/xml/ns/javaee":display-name, "http://java.sun.com/xml/ns/javaee":icon, "http://java.sun.com/xml/ns/javaee":initialize-in-order, "http://java.sun.com/xml/ns/javaee":module}
我相信这些元素在我之前是不需要的application.xml
,然后我在部署时突然遇到了这个问题。
我在我的项目中启用了 javaEEApplication 和 Web 方面,部署描述符似乎也设置正确。我将 Jersey-2.2 引用为使用 RESTful 服务的库。我的项目还有 GlassFish 4.1.1 - RESTful Web Service 作为依赖项。
我正在使用从模块自动生成的 Exploded 工件,并且运行配置设置为先构建然后构建工件。glassfish 管理员的凭据是正确的。
我想知道为什么我突然遇到这个问题,我虽然 IntelliJ 会在application.xml
它需要的部署描述符 () 中自动生成任何必要的内容。有谁知道我错过了什么?也许我必须引用 Java EE 6 或 7 作为库本身?我在这里迷路了。
下面的完整错误日志以防万一:
"C:\Program Files (x86)\glassfish4\glassfish\bin\asadmin.bat" start-domain domain1
"C:\Program Files\Java\jdk1.8.0_77\bin\java" -Dfile.encoding=windows-1252 -classpath "C:\Program Files (x86)\glassfish4\glassfish\modules\javax.ejb-api.jar;C:\Program Files.....
[2017-02-05 03:16:49,423] Artifact CapstoneIntelliJProject:war exploded: Server is not connected. Deploy is not available.
Detected server admin port: 4848
Detected server http port: 8080
Attempting to start domain1.... Please look at the server log for more details.....
Connected to server
[2017-02-05 03:16:52,358] Artifact CapstoneIntelliJProject:war exploded: Artifact is being deployed, please wait...
[2017-02-05 03:16:53,536] Artifact CapstoneIntelliJProject:war exploded: Error during artifact deployment. See server log for details.
[2017-02-05 03:16:53,537] Artifact CapstoneIntelliJProject:war exploded: java.io.IOException: com.sun.enterprise.admin.remote.RemoteFailureException: Error occurred during deployment: Exception while deploying the app [CapstoneIntelliJProject_war_exploded] : org.xml.sax.SAXParseException; lineNumber: 7; columnNumber: 15; Deployment descriptor file META-INF/application.xml in archive [CapstoneIntelliJProject_war_exploded]. cvc-complex-type.2.4.b: The content of element 'application' is not complete. One of '{"http://java.sun.com/xml/ns/javaee":description, "http://java.sun.com/xml/ns/javaee":display-name, "http://java.sun.com/xml/ns/javaee":icon, "http://java.sun.com/xml/ns/javaee":initialize-in-order, "http://java.sun.com/xml/ns/javaee":module}' is expected.. Please see server.log for more details.
"C:\Program Files (x86)\glassfish4\glassfish\bin\asadmin.bat" stop-domain domain1
Process finished with exit code 0
Waiting for the domain to stop .
Command stop-domain executed successfully.
Disconnected from server
编辑:我已经解决了这个特定问题,为项目启用 javaEEapplication 方面是一个错误,因为它只是一个安静的 Web 服务。现在我面临一个新问题,输出告诉我Application [CapstoneIntelliJProject_war_exploded] contains no valid components.
。服务器日志不包含任何有用的信息。我不确定我的战争出了什么问题,它似乎配置得很好。