在码头嵌入战争,websocket没有工厂升级



我有两场战争,我正试图在嵌入码头的uberjar中运行。其中一个使用websocket。使用浏览器,除了websocket之外,我可以很好地获得两场战争的响应。当我降低日志记录级别进行调试时,我会看到以下错误。是否有我没有在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}2020-09-09 10:35:10.204:DBUG:oejs.HttpChannelOverHttp:qtp38997010-16:没有升级工厂:中的websocketServerConnector@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);
}
}

在服务器级别启用字节码扫描。

Server server = new Server();
Configuration.ClassList classlist = Configuration.ClassList
.setServerDefault(server);
classlist.addBefore(
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
"org.eclipse.jetty.annotations.AnnotationConfiguration");

这将把AnnotationConfiguration应用于所有部署的WebAppContext。

最新更新