0

我的应用程序在不设置任何上下文根的情况下与 payara 服务器一起使用,但 payara micro 将默认上下文根设置为我的 war 文件的名称。如果 ot payara micro ,如何将上下文根设置为空?

一种方法是将战争名称设置为 ROOT.war 但使用该名称我在部署时会出现以下错误。我尝试将 xerces-2.9.1 jar 放入 --addLibs 但不起作用。

2020-08-20T21:36:53.110+0200] [] [SEVERE] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1597952213110] [levelValue: 1000] [[
  Exception while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException: java.lang.AbstractMethodError
    at com.sun.enterprise.web.WebApplication.start(WebApplication.java:136)
    at org.glassfish.internal.data.EngineRef.start(EngineRef.java:123)
    at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:280)
    at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:344)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.initialize(ApplicationLifecycle.java:584)
    at fish.payara.deployment.admin.InitializeAllApplicationsCommand.execute(InitializeAllApplicationsCommand.java:75)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:558)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:554)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:553)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:584)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:576)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:360)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:575)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1496)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:120)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1878)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1754)
    at com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl.executeCommand(CommandExecutorImpl.java:183)
    at com.sun.enterprise.admin.cli.embeddable.CommandExecutorImpl.run(CommandExecutorImpl.java:96)
    at fish.payara.micro.impl.PayaraMicroImpl.bootStrap(PayaraMicroImpl.java:1063)
    at fish.payara.micro.impl.PayaraMicroImpl.create(PayaraMicroImpl.java:211)
    at fish.payara.micro.impl.PayaraMicroImpl.main(PayaraMicroImpl.java:200)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at fish.payara.micro.boot.loader.MainMethodRunner.run(MainMethodRunner.java:50)
    at fish.payara.micro.boot.loader.Launcher.launch(Launcher.java:114)
    at fish.payara.micro.boot.loader.Launcher.launch(Launcher.java:73)
    at fish.payara.micro.boot.PayaraMicroLauncher.create(PayaraMicroLauncher.java:87)
    at fish.payara.micro.boot.PayaraMicroLauncher.main(PayaraMicroLauncher.java:71)
    at fish.payara.micro.PayaraMicro.main(PayaraMicro.java:397)
]]
4

1 回答 1

0

首先,您不应该仅仅因为您将应用程序重命名为 ROOT.war 而出现错误。如果在最新版本的 Payara Micro 上发生这种情况,您应该提出一个 github 问题:https ://github.com/payara/Payara/issues

现在回到问题。--contextroot您可以使用设置为的命令行选项设置上下文根/

java -jar payara-micro.jar --contextroot / app.war

如果您部署多个应用程序或资源,您可以在部署文件的名称中指定上下文根,用冒号(或 Windows 上的分号)分隔,例如:

java -jar payara-micro.jar app.war:/

这是关于此的完整文档:https ://docs.payara.fish/community/docs/5.2020.4/documentation/payara-micro/deploying/deploy-cmd-line.html#define-context-root

于 2020-08-24T08:05:54.720 回答