在嵌入式码头中使用战争,websocket 没有工厂进行升级
Using wars in jetty embedded, websocket getting no factory for upgrade
我试图在码头嵌入式 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 中的 websocket{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。
我试图在码头嵌入式 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 中的 websocket{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。