I have two wars that I am trying to run in a jetty embedded uberjar. One of which uses websockets. Using a browser, I can get responses for the two wars just fine except for the websockets. When I drop the logging level to debug, I see the following errors. Is there a factory that I have not configured on my WebAppContexts?
2020-09-09 10:35:10.204:DBUG:oejs.HttpChannelOverHttp:qtp38997010-16: upgrade 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} Upgrade: websocket 2020-09-09 10:35:10.204:DBUG:oejs.HttpChannelOverHttp:qtp38997010-16: No factory for Upgrade: websocket in ServerConnector@6073f712{HTTP/1.1, (http/1.1)}{0.0.0.0:9191}
Source:
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);
}
}
Enable bytecode scanning, at the server level.
Server server = new Server();
Configuration.ClassList classlist = Configuration.ClassList
.setServerDefault(server);
classlist.addBefore(
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
"org.eclipse.jetty.annotations.AnnotationConfiguration");
That will apply the AnnotationConfiguration to all deployed WebAppContexts.