【发布时间】:2020-09-09 15:36:44
【问题描述】:
我有两场战争,我试图在码头嵌入式 uberjar 中运行。其中之一使用 websockets。使用浏览器,除了 websockets 之外,我可以很好地获得两场战争的响应。当我将日志记录级别降至调试时,我看到以下错误。是否有我没有在我的 WebAppContexts 上配置的工厂?
2020-09-09 10:35:10.204:DBUG:oejs.HttpChannelOverHttp:qtp38997010-16:升级 HttpChannelOverHttp@3627c323{s=HttpChannelState@42e23fe6{s=IDLE rs=BLOCKING os=OPEN is=IDLE awp=false se=false i=true al=0},r=0,c=false/false,a=IDLE,uri=null,age=0} 升级:websocket 2020-09-09 10:35:10.204:DBUG:oejs.HttpChannelOverHttp:qtp38997010-16:无升级工厂:ServerConnector@6073f712{HTTP/1.1, (http/1.1)}{0.0.0.0:9191}
来源:
public static void main(String[] args) throws Exception {
Server server = new Server();
ServerConnector connector = new ServerConnector(server);
server.setConnectors(new Connector[]{connector});
// war #1
WebAppContext portalContext = new WebAppContext();
portalContext.setContextPath("/portal");
portalContext.setWar("/path/to/war/file/app1.war")
// war #2 (war with websocket)
WebAppContext hubContext = new WebAppContext();
hubContext.setContextPath("/hub");
hubContext.setWar("/path/to/war/file/app2.war")
HandlerCollection handlerCollection = new HandlerCollection();
handlerCollection.setHandlers(new Handler[]{hubContext, portalContext});
server.setHandler(handlerCollection);
try {
server.start();
System.in.read();
server.stop();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(100);
}
}
【问题讨论】:
-
请编辑您的问题并包含有关您如何为这些war 文件创建(和配置)WebAppContext 的代码sn-p。您似乎缺少一些
Configuration类型和/或字节码扫描。 -
更新了正在使用的源代码。