Refine search
@Override public Session connectToServer(Object obj, URI path) throws DeploymentException, IOException { try { return connectToServer(obj, null, path.toString(), true).get(); } catch (InterruptedException e) { throw new DeploymentException(e.getMessage(), e); } catch (ExecutionException e) { final Throwable cause = e.getCause(); if (cause instanceof DeploymentException) { throw (DeploymentException) cause; } else if (cause instanceof IOException) { throw (IOException) cause; } else { throw new DeploymentException(cause.getMessage(), cause); } } }
@WebListener public class MyListener_V7 implements ServletContextListener { private static final Logger LOG = LoggerFactory.getLogger(MyListener_V7.class); @Override public void contextInitialized(ServletContextEvent servletContextEvent) { final ServerContainer serverContainer = (ServerContainer) servletContextEvent.getServletContext() .getAttribute("javax.websocket.server.ServerContainer"); try { serverContainer.addEndpoint(MyWebsocket_V7.class); //Generates exception when the plug-in is updated } catch (DeploymentException e) { LOG.error("Error adding endpoint to the servercontainer: " + e.getMessage()); } } @Override public void contextDestroyed(ServletContextEvent servletContextEvent) { LOG.error("CONTEXT DESTROYED!"); } } @ServerEndpoint(value = "/websocket_V7/{myPathParam}") public class MyWebsocket_V7 { private static final Logger LOG = LoggerFactory.getLogger(MyWebsocket.class);
private void connect(String url, String clentid) { WebSocketContainer container = ContainerProvider.getWebSocketContainer(); if (!url.endsWith("/")) { url += "/" + clentid; } else { url += clentid; } logger.info("Connecting to " + url); try { clientid = clentid; session = container.connectToServer(MessageClient.class, URI.create(url)); } catch (DeploymentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
} else { throw new DeploymentException(sm.getString( "wsWebSocketContainer.pathWrongScheme", scheme)); throw new DeploymentException( sm.getString("wsWebSocketContainer.pathNoHost")); socketChannel = AsynchronousSocketChannel.open(getAsynchronousChannelGroup()); } catch (IOException ioe) { throw new DeploymentException(sm.getString( "wsWebSocketContainer.asynchronousSocketChannelFail"), ioe); HttpResponse httpResponse = processResponse(response, channel, timeout); if (httpResponse.getStatus() != 200) { throw new DeploymentException(sm.getString( "wsWebSocketContainer.proxyConnectFail", selectedProxy, Integer.toString(httpResponse.getStatus()))); throw new DeploymentException( throw new DeploymentException(sm.getString( "wsWebSocketContainer.missingLocationHeader", Integer.toString(httpResponse.status))); throw new DeploymentException(sm.getString( "wsWebSocketContainer.redirectThreshold", redirectLocation, Integer.toString(redirectSet.size()), throw new DeploymentException(sm.getString(
wlsProxyHost = (String) value; } else { throw new DeploymentException(ClientManager.WLS_PROXY_HOST + " only accept String values."); wlsProxyPort = (Integer) value; } else { throw new DeploymentException(ClientManager.WLS_PROXY_PORT + " only accept Integer values."); URI proxyUri; if (proxyString != null) { proxyUri = new URI(proxyString.toString()); if (proxyUri.getHost() == null) { LOGGER.log(Level.WARNING, String.format("Invalid proxy '%s'.", proxyString)); } else { int proxyPort = proxyUri.getPort() == -1 ? 80 : proxyUri.getPort(); proxies.add(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyUri.getHost(), proxyPort)));
@Override public TyrusClientSocket openClientSocket(String url, ClientEndpointConfig cec, SPIEndpoint endpoint, SPIHandshakeListener listener, Map<String, Object> properties) throws DeploymentException { URI uri; try { uri = new URI(url); } catch (URISyntaxException e) { throw new DeploymentException("Invalid URI.", e); } SSLEngineConfigurator sslEngineConfigurator = (properties == null ? null : (SSLEngineConfigurator) properties.get(SSL_ENGINE_CONFIGURATOR)); // if we are trying to access "wss" scheme and we don't have sslEngineConfigurator instance // we should try to create ssl connection using JVM properties. if(uri.getScheme().equalsIgnoreCase("wss") && sslEngineConfigurator == null) { SSLContextConfigurator defaultConfig = new SSLContextConfigurator(); defaultConfig.retrieve(System.getProperties()); sslEngineConfigurator = new SSLEngineConfigurator(defaultConfig, true, false, false); } GrizzlyClientSocket clientSocket = new GrizzlyClientSocket(endpoint, uri, cec, CLIENT_SOCKET_TIMEOUT, listener, properties == null ? null : sslEngineConfigurator, properties == null ? null : (String) properties.get(GrizzlyClientSocket.PROXY_URI), properties == null ? null : (ThreadPoolConfig) properties.get(GrizzlyClientSocket.WORKER_THREAD_POOL_CONFIG), properties == null ? null : (ThreadPoolConfig) properties.get(GrizzlyClientSocket.SELECTOR_THREAD_POOL_CONFIG)); clientSocket.connect(); return clientSocket; } }
String scheme = path.getScheme(); if (!("ws".equalsIgnoreCase(scheme) || "wss".equalsIgnoreCase(scheme))) { throw new DeploymentException(sm.getString( "wsWebSocketContainer.pathWrongScheme", scheme)); String host = path.getHost(); if (host == null) { throw new DeploymentException( sm.getString("wsWebSocketContainer.pathNoHost")); secure = true; } else { throw new DeploymentException( sm.getString("wsWebSocketContainer.invalidScheme")); AsynchronousSocketChannel.open(asynchronousChannelGroup); } catch (IOException ioe) { throw new DeploymentException(sm.getString( "wsWebSocketContainer.asynchronousSocketChannelFail"), ioe); subProtocol = values.get(0); } else { throw new DeploymentException( sm.getString("Sec-WebSocket-Protocol")); throw new DeploymentException( sm.getString("wsWebSocketContainer.httpRequestFailed"), e);
sb.append(upgradeRequest.getRequestURI().getPath()); if (upgradeRequest.getRequestURI().getQuery() != null) { sb.append('?').append(upgradeRequest.getRequestURI().getQuery()); case HANDSHAKE_FAILED: tyrusServerContainer.shutdown(); throw new DeploymentException(""); case NOT_APPLICABLE: tyrusServerContainer.shutdown(); throw new DeploymentException(""); case SUCCESS: throw new DeploymentException("");
private static void connectToURI(final ConsoleReader console, final String uri, final WebSocketContainer webSocketContainer) throws IOException { // Use a local copy so that we don't get odd race conditions // Session localCopy = session; if (localCopy != null) { ClientCli.print(console, null, String.format("Closing session %s", localCopy.getId()), false); localCopy.close(); } ClientCli.print(console, null, String.format("Connecting to %s...", uri), false); try { // TODO support sub protocols localCopy = webSocketContainer.connectToServer(new ClientEndpoint(console), new URI(uri)); session = localCopy; ClientCli.print(console, null, String.format("Connected in session %s", localCopy.getId()), false); } catch (URISyntaxException ex) { ClientCli.print(console, null, String.format("Problem parsing uri %s beause of %s", uri, ex.getMessage()), false); } catch (DeploymentException ex) { ClientCli.print(console, null, String.format("Failed to connect to %s due to %s", uri, ex.getMessage()), false); } }
private SocketAddress getServerAddress(URI uri) throws DeploymentException { int port = Utils.getWsPort(uri); try { return new InetSocketAddress(uri.getHost(), port); } catch (IllegalArgumentException e) { throw new DeploymentException(e.getMessage(), e); } }
final boolean secure = "wss".equalsIgnoreCase(uri.getScheme()); throw new DeploymentException("Connection failed.", exception);
private RemoteEndpoint.Async getEndpoint() { try { Session session = sessionFuture.get(CONNECTION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS); if (session == null) throw new CucumberException("Couldn't connect to " + uri); return session.getAsyncRemote(); } catch (ExecutionException e) { if (e.getCause() instanceof DeploymentException) { DeploymentException de = (DeploymentException) e.getCause(); if (de.getCause() instanceof HandshakeException) { HandshakeException he = (HandshakeException) de.getCause(); switch (he.getHttpStatusCode()) { case 401: throw new CucumberException("Couldn't authenticate user: " + uri.getQuery()); case 403: throw new CucumberException("Access denied: " + uri.getQuery()); default: throw he; } } else { throw new CucumberException(e); } } else { throw new CucumberException(e); } } catch (TimeoutException e) { throw new CucumberException("Timed out connecting to " + uri, e); } catch (Exception e) { throw new CucumberException(e); } }
private void parseStatus(String line) throws DeploymentException { // This client only understands HTTP 1.1 // RFC2616 is case specific if (!line.startsWith("HTTP/1.1 101")) { throw new DeploymentException(sm.getString( "wsWebSocketContainer.invalidStatus", line)); } }
/** * Create {@link DeploymentException} with message concatenated from collected exceptions. * * @return comprehensive exception. */ public DeploymentException composeComprehensiveException() { StringBuilder sb = new StringBuilder(); for (Exception exception : exceptionsToPublish) { sb.append(exception.getMessage()); sb.append("\n"); } return new DeploymentException(sb.toString()); }
e.printStackTrace(); } catch (DeploymentException e) { e.printStackTrace();
} else { throw new DeploymentException(sm.getString( "wsWebSocketContainer.pathWrongScheme", scheme)); throw new DeploymentException( sm.getString("wsWebSocketContainer.pathNoHost")); socketChannel = AsynchronousSocketChannel.open(getAsynchronousChannelGroup()); } catch (IOException ioe) { throw new DeploymentException(sm.getString( "wsWebSocketContainer.asynchronousSocketChannelFail"), ioe); HttpResponse httpResponse = processResponse(response, channel, timeout); if (httpResponse.getStatus() != 200) { throw new DeploymentException(sm.getString( "wsWebSocketContainer.proxyConnectFail", selectedProxy, Integer.toString(httpResponse.getStatus()))); throw new DeploymentException( throw new DeploymentException(sm.getString( "wsWebSocketContainer.missingLocationHeader", Integer.toString(httpResponse.status))); throw new DeploymentException(sm.getString( "wsWebSocketContainer.redirectThreshold", redirectLocation, Integer.toString(redirectSet.size()), throw new DeploymentException(sm.getString(
wlsProxyHost = (String) value; } else { throw new DeploymentException(ClientManager.WLS_PROXY_HOST + " only accept String values."); wlsProxyPort = (Integer) value; } else { throw new DeploymentException(ClientManager.WLS_PROXY_PORT + " only accept Integer values."); URI proxyUri; if (proxyString != null) { proxyUri = new URI(proxyString.toString()); if (proxyUri.getHost() == null) { LOGGER.log(Level.WARNING, String.format("Invalid proxy '%s'.", proxyString)); } else { int proxyPort = proxyUri.getPort() == -1 ? 80 : proxyUri.getPort(); proxies.add(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyUri.getHost(), proxyPort)));
URI uri = new URI(url); String scheme = uri.getScheme(); if (scheme == null || !(scheme.equals("ws") || scheme.equals("wss"))) { throw new DeploymentException("Incorrect scheme in WebSocket endpoint URI=" + url); throw new DeploymentException("Incorrect WebSocket endpoint URI=" + url, e); uri = new URI(url); } catch (URISyntaxException e) { throw new DeploymentException("Invalid URI.", e);
String scheme = path.getScheme(); if (!("ws".equalsIgnoreCase(scheme) || "wss".equalsIgnoreCase(scheme))) { throw new DeploymentException(MESSAGES.pathWrongScheme(scheme)); String host = path.getHost(); if (host == null) { throw new DeploymentException(MESSAGES.pathNoHost()); secure = true; } else { throw new DeploymentException(MESSAGES.invalidScheme(scheme)); socketChannel = AsynchronousSocketChannel.open(getAsynchronousChannelGroup()); } catch (IOException ioe) { throw new DeploymentException(MESSAGES.connectionFailed(), ioe); subProtocol = protocolHeaders.get(0); } else { throw new DeploymentException(MESSAGES.invalidProtocolHeader()); Transformation t = factory.create(extension.getName(), wrapper, false); if (t == null) { throw new DeploymentException(MESSAGES.unsupportedParameters()); throw new DeploymentException(MESSAGES.httpRequestFailed(), e); } catch (InterruptedException e) { throw new DeploymentException(MESSAGES.httpRequestFailed(), e); } catch (SSLException e) {
case DIRECT: try { connectAddress = new InetSocketAddress(requestURI.getHost(), Utils.getWsPort(requestURI)); } catch (IllegalArgumentException e) { closeTransport(privateTransport); throw new DeploymentException(e.getMessage(), e); sslHandshakeFuture.get(timeoutMs, TimeUnit.MILLISECONDS); } catch (ExecutionException e) { throw new DeploymentException("SSL handshake has failed", e.getCause()); } catch (Exception e) { throw new DeploymentException(String.format("Connection to '%s' failed.", requestURI), e.getCause()); throw new DeploymentException("Connection failed.", exception);