Open jerseyrobot opened 8 years ago
@glassfishrobot Commented Reported by survivant
@glassfishrobot Commented survivant said: here my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo</groupId>
<artifactId>jerseyssldemo</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<jersey.version>2.22.1</jersey.version>
</properties>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.connectors</groupId>
<artifactId>jersey-apache-connector</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-jaxb</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.fastinfoset</groupId>
<artifactId>FastInfoset</artifactId>
<version>1.2.13</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
My demo
package com.demo;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.HttpClientConnectionManager;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.glassfish.jersey.apache.connector.ApacheClientProperties;
import org.glassfish.jersey.apache.connector.ApacheConnectorProvider;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
import org.glassfish.jersey.client.filter.EncodingFeature;
import org.glassfish.jersey.message.GZipEncoder;
import javax.net.ssl.*;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
/**
* @author Sebastien Dionne
*/
public class Jersey2Client {
public static final int defaultMaxPerRoute = 2;
public static final int maxPool = 20;
public static final int timeout = 30000;
public static final boolean sslEnabled = false;
public static final String username = "admin";
public static final String password = "password";
public static final String host = "http://xx.xx.xx.xx";
public static final String path = "/basic";
public static final String acceptType = "application/fastinfoset";
private static WebTarget webTarget = null;
public static Client createClientForcePoolingHttpClientConnectionManagerWithSSL() throws Exception {
return createClient(true);
}
/**
* Creates the Jersey Client Configuration
* @return
*/
public static Client createClient() throws Exception {
return createClient(false);
}
/**
* Creates the Jersey Client Configuration
* @return
*/
public static Client createClient(boolean forceSSLFactory) throws Exception {
Client client = null;
ClientConfig clientConfig = new ClientConfig();
clientConfig.property(ClientProperties.ASYNC_THREADPOOL_SIZE, maxPool);
clientConfig.property(ClientProperties.CONNECT_TIMEOUT, timeout);
clientConfig.property(ClientProperties.READ_TIMEOUT, timeout);
clientConfig.register(MyBeanMessageBodyReader.class);
// ApacheConnectorProvider configuration
clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER, makeConnectionManager(defaultMaxPerRoute, maxPool));
clientConfig.connectorProvider(new ApacheConnectorProvider());
// requires authentication, have the client automatically send the credentials
clientConfig.property(ApacheClientProperties.PREEMPTIVE_BASIC_AUTHENTICATION, true);
HttpAuthenticationFeature authenticationFeature = HttpAuthenticationFeature.basicBuilder().nonPreemptive().credentials(username, password).build();
clientConfig.register(authenticationFeature);
clientConfig.register(new EncodingFeature("gzip", GZipEncoder.class));
// SSL configuration
if (sslEnabled) {
TrustManager[ ] certs = new TrustManager[ ] {
new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
}
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
}
}
};
HostnameVerifier allHostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String s, SSLSession sslSession) {
return true;
}
};
SSLContext sslContext = null;
try {
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, certs, new SecureRandom());
// HACK..why !
if(forceSSLFactory){
Registry r = RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", new SSLConnectionSocketFactory(sslContext, allHostnameVerifier)) // force
.build();
PoolingHttpClientConnectionManager pool = new PoolingHttpClientConnectionManager(r);
pool.setMaxTotal(maxPool);
pool.setDefaultMaxPerRoute(defaultMaxPerRoute);
clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER, pool);
}
} catch (GeneralSecurityException ex) {
System.err.println("Could not configure Jersey to accept all SSL Certificates.");
throw ex;
}
client = ClientBuilder.newBuilder().sslContext(sslContext).hostnameVerifier(allHostnameVerifier).withConfig(clientConfig).build();
} else {
// no SSL
client = ClientBuilder.newClient(clientConfig);
}
return client;
}
private static HttpClientConnectionManager makeConnectionManager(int defaultMaxPerRoute, int maxConnections) {
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setMaxTotal(maxConnections);
connectionManager.setDefaultMaxPerRoute(defaultMaxPerRoute);
return connectionManager;
}
public static void main(String[] args) throws Exception {
System.out.println("Starting demo");
String value = null;
Client client = createClient();
WebTarget webTarget = client.target(host).path(path);
// GET
try {
value = webTarget.request(acceptType).method("GET", String.class);
} catch (Exception e){
e.printStackTrace();
}
System.out.println("Value = " + value);
System.out.println("");
System.out.println("");
System.out.println(" another request");
webTarget = client.target(host).path(path);
// GET
try {
value = webTarget.request(acceptType).method("GET", String.class); //THAT WILL TIMEOUT
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Value = " + value);
}
}
My Reader
package com.demo;
import com.sun.xml.fastinfoset.stax.StAXDocumentParser;
import javax.ws.rs.Consumes;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.Provider;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
/**
* @author Sebastien Dionne
*/
@Provider
@Consumes("application/fastinfoset")
public class MyBeanMessageBodyReader implements MessageBodyReader<Object> {
@Override
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
if(!this.supportsMediaType(mediaType)) {
return false;
}
return true;
}
protected boolean supportsMediaType(MediaType mediaType) {
if(null == mediaType) {
return true;
}
String subtype = mediaType.getSubtype();
return subtype.equals("fastinfoset");
}
@Override
public Object readFrom(Class<Object> type,
Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String, String> httpHeaders,
InputStream entityStream) throws IOException, WebApplicationException {
try {
// It is assumed that it should be a Status OK if we are here
JAXBContext jaxbContext = JAXBContext.newInstance(String.class, type);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StAXDocumentParser p = new StAXDocumentParser(entityStream);
return type.isAnnotationPresent(XmlRootElement.class) ? unmarshaller.unmarshal(p) : unmarshaller.unmarshal(p, type).getValue();
} catch(Exception e){
e.printStackTrace();
}
return null;
}
}
The output
Starting demo Value = hello
another request // SHOULD RECEIVED HELLO AGAIN, but stalled there
Here is what happen :
in ApacheConnector
line : 300 -> this.client = clientBuilder.build();
later -> response = client.execute(getHost(request), request, context); //do the request
after that, org.glassfish.jersey.client.authentication.BasicAuthenticator will open a new request
filterResponseAndAuthenticate line 126 -> return HttpAuthenticationFilter.repeatRequest(request, response, calculateAuthentication(credentials));
that will call : Client client = ClientBuilder.newClient(request.getConfiguration());
@glassfishrobot Commented survivant said: here the log (I masked the IP and port)
Starting demo
2016-02-11 08:21:38,362 [INFO ] {main} (RestLoggingFilter.java:209) 1* Sending client request on thread main
1> GET http://xx.xx.xx.xx:xx/demo
1> Accept: application/fastinfoset
2016-02-11 08:21:38,414 [DEBUG] {main} (RequestAddCookies.java:122) CookieSpec selected: default
2016-02-11 08:21:38,422 [DEBUG] {main} (RequestAuthCache.java:130) Re-using cached 'basic' auth scheme for http://xxxxxxxxx:xxxx
2016-02-11 08:21:38,423 [DEBUG] {main} (RequestAuthCache.java:144) No credentials for preemptive authentication
2016-02-11 08:21:38,424 [DEBUG] {main} (PoolingHttpClientConnectionManager.java:249) Connection request: [route: {}->http://xxxxxxxxx:xxxx][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
2016-02-11 08:21:38,434 [DEBUG] {main} (PoolingHttpClientConnectionManager.java:282) Connection leased: [id: 0][route: {}->http://xxxxxxxxx:xxxx][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
2016-02-11 08:21:38,435 [DEBUG] {main} (MainClientExec.java:234) Opening connection {}->http://xxxxxxxxx:xxxx
2016-02-11 08:21:38,437 [DEBUG] {main} (DefaultHttpClientConnectionOperator.java:131) Connecting to /xxxxxxxxx:xxxx
2016-02-11 08:21:38,443 [DEBUG] {main} (DefaultHttpClientConnectionOperator.java:138) Connection established xxxxxxxxx:xxxx:49601<->xxxxxxxxx:xxxx:10080
2016-02-11 08:21:38,444 [DEBUG] {main} (MainClientExec.java:255) Executing request GET /demo HTTP/1.1
2016-02-11 08:21:38,444 [DEBUG] {main} (MainClientExec.java:260) Target auth state: UNCHALLENGED
2016-02-11 08:21:38,444 [DEBUG] {main} (MainClientExec.java:266) Proxy auth state: UNCHALLENGED
2016-02-11 08:21:38,445 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:124) http-outgoing-0 >> GET /demo HTTP/1.1
2016-02-11 08:21:38,446 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-0 >> Accept: application/fastinfoset
2016-02-11 08:21:38,446 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-0 >> User-Agent: Jersey/2.22.1 (Apache HttpClient 4.5)
2016-02-11 08:21:38,446 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-0 >> Host: 10.2.254.31:10080
2016-02-11 08:21:38,446 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-0 >> Connection: Keep-Alive
2016-02-11 08:21:38,446 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-0 >> Accept-Encoding: gzip,deflate
2016-02-11 08:21:38,446 [DEBUG] {main} (Wire.java:72) http-outgoing-0 >> "GET /demo HTTP/1.1[\r][\n]"
2016-02-11 08:21:38,446 [DEBUG] {main} (Wire.java:72) http-outgoing-0 >> "Accept: application/fastinfoset[\r][\n]"
2016-02-11 08:21:38,446 [DEBUG] {main} (Wire.java:72) http-outgoing-0 >> "User-Agent: Jersey/2.22.1 (Apache HttpClient 4.5)[\r][\n]"
2016-02-11 08:21:38,446 [DEBUG] {main} (Wire.java:72) http-outgoing-0 >> "Host: xxxxxxxxx:xxxx[\r][\n]"
2016-02-11 08:21:38,447 [DEBUG] {main} (Wire.java:72) http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
2016-02-11 08:21:38,447 [DEBUG] {main} (Wire.java:72) http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
2016-02-11 08:21:38,447 [DEBUG] {main} (Wire.java:72) http-outgoing-0 >> "[\r][\n]"
2016-02-11 08:21:38,452 [DEBUG] {main} (Wire.java:72) http-outgoing-0 << "HTTP/1.1 401 Full authentication is required to access this resource[\r][\n]"
2016-02-11 08:21:38,452 [DEBUG] {main} (Wire.java:72) http-outgoing-0 << "X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)[\r][\n]"
2016-02-11 08:21:38,452 [DEBUG] {main} (Wire.java:72) http-outgoing-0 << "Server: GlassFish Server Open Source Edition 3.1.2.2[\r][\n]"
2016-02-11 08:21:38,452 [DEBUG] {main} (Wire.java:72) http-outgoing-0 << "Set-Cookie: JSESSIONID=07e88e48ee0f7f379251a73cc4b9; Path=/ucp-cmtsmetrics-ws; HttpOnly[\r][\n]"
2016-02-11 08:21:38,452 [DEBUG] {main} (Wire.java:72) http-outgoing-0 << "WWW-Authenticate: Basic realm="DEMO Specific Web Service"[\r][\n]"
2016-02-11 08:21:38,452 [DEBUG] {main} (Wire.java:72) http-outgoing-0 << "Content-Type: text/html[\r][\n]"
2016-02-11 08:21:38,453 [DEBUG] {main} (Wire.java:72) http-outgoing-0 << "Content-Length: 1238[\r][\n]"
2016-02-11 08:21:38,453 [DEBUG] {main} (Wire.java:72) http-outgoing-0 << "Date: Thu, 11 Feb 2016 13:21:39 GMT[\r][\n]"
2016-02-11 08:21:38,453 [DEBUG] {main} (Wire.java:72) http-outgoing-0 << "[\r][\n]"
2016-02-11 08:21:38,453 [DEBUG] {main} (Wire.java:86) http-outgoing-0 << "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>GlassFish Server Open Source Edition 3.1.2.2 - Error report</title><style type="text/css"><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - Full authentication is required to access this resource</h1><hr/><p><b>type</b> Status report</p><p><b>message"
2016-02-11 08:21:38,455 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:113) http-outgoing-0 << HTTP/1.1 401 Full authentication is required to access this resource
2016-02-11 08:21:38,455 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-0 << X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)
2016-02-11 08:21:38,455 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-0 << Server: GlassFish Server Open Source Edition 3.1.2.2
2016-02-11 08:21:38,456 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-0 << Set-Cookie: JSESSIONID=07e88e48ee0f7f379251a73cc4b9; Path=/demo; HttpOnly
2016-02-11 08:21:38,456 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-0 << WWW-Authenticate: Basic realm="DEMO Specific Web Service"
2016-02-11 08:21:38,456 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-0 << Content-Type: text/html
2016-02-11 08:21:38,456 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-0 << Content-Length: 1238
2016-02-11 08:21:38,456 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-0 << Date: Thu, 11 Feb 2016 13:21:39 GMT
2016-02-11 08:21:38,458 [DEBUG] {main} (MainClientExec.java:284) Connection can be kept alive indefinitely
2016-02-11 08:21:38,459 [DEBUG] {main} (HttpAuthenticator.java:77) Authentication required
2016-02-11 08:21:38,459 [DEBUG] {main} (HttpAuthenticator.java:107) xxxxxxxxx:xxxx requested authentication
2016-02-11 08:21:38,459 [DEBUG] {main} (AuthenticationStrategyImpl.java:174) Authentication schemes in the order of preference: [Negotiate, Kerberos, NTLM, Digest, Basic]
2016-02-11 08:21:38,459 [DEBUG] {main} (AuthenticationStrategyImpl.java:203) Challenge for Negotiate authentication scheme not available
2016-02-11 08:21:38,459 [DEBUG] {main} (AuthenticationStrategyImpl.java:203) Challenge for Kerberos authentication scheme not available
2016-02-11 08:21:38,459 [DEBUG] {main} (AuthenticationStrategyImpl.java:203) Challenge for NTLM authentication scheme not available
2016-02-11 08:21:38,459 [DEBUG] {main} (AuthenticationStrategyImpl.java:203) Challenge for Digest authentication scheme not available
2016-02-11 08:21:38,463 [DEBUG] {main} (ResponseProcessCookies.java:118) Cookie accepted [JSESSIONID="07e88e48ee0f7f379251a73cc4b9", version:0, domain:xx.xx.xx.xx, path:/demo, expiry:null]
2016-02-11 08:21:38,511 [INFO ] {main} (RestLoggingFilter.java:209) 2* Sending client request on thread main
2> GET http://xxxxxxxxx:xxxx/demo
2> Accept: application/fastinfoset
2> Authorization: Basic YWRtaW46cGFzc3dvcmQ=
2> User-Agent: Jersey/2.22.1 (Apache HttpClient 4.5)
2016-02-11 08:21:38,512 [DEBUG] {main} (RequestAddCookies.java:122) CookieSpec selected: default
2016-02-11 08:21:38,512 [DEBUG] {main} (RequestAuthCache.java:130) Re-using cached 'basic' auth scheme for http://xxxxxxxxx:xxxx
2016-02-11 08:21:38,512 [DEBUG] {main} (RequestAuthCache.java:144) No credentials for preemptive authentication
2016-02-11 08:21:38,512 [DEBUG] {main} (PoolingHttpClientConnectionManager.java:249) Connection request: [route: {}->http://xxxxxxxxx:xxxx][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
2016-02-11 08:21:38,513 [DEBUG] {main} (PoolingHttpClientConnectionManager.java:282) Connection leased: [id: 1][route: {}->http://xxxxxxxxx:xxxx][total kept alive: 0; route allocated: 2 of 2; total allocated: 2 of 20]
2016-02-11 08:21:38,513 [DEBUG] {main} (MainClientExec.java:234) Opening connection {}->http://xxxxxxxxx:xxxx
2016-02-11 08:21:38,513 [DEBUG] {main} (DefaultHttpClientConnectionOperator.java:131) Connecting to /xxxxxxxxx:xxxx
2016-02-11 08:21:38,517 [DEBUG] {main} (DefaultHttpClientConnectionOperator.java:138) Connection established xxxxxxxxx:xxxx<->xxxxxxxxx:xxxx
2016-02-11 08:21:38,517 [DEBUG] {main} (MainClientExec.java:255) Executing request GET /demo HTTP/1.1
2016-02-11 08:21:38,517 [DEBUG] {main} (MainClientExec.java:266) Proxy auth state: UNCHALLENGED
2016-02-11 08:21:38,518 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:124) http-outgoing-1 >> GET /demo HTTP/1.1
2016-02-11 08:21:38,518 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-1 >> Authorization: Basic YWRtaW46cGFzc3dvcmQ=
2016-02-11 08:21:38,518 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-1 >> User-Agent: Jersey/2.22.1 (Apache HttpClient 4.5)
2016-02-11 08:21:38,518 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-1 >> Accept: application/fastinfoset
2016-02-11 08:21:38,518 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-1 >> Host: 10.2.254.31:10080
2016-02-11 08:21:38,518 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-1 >> Connection: Keep-Alive
2016-02-11 08:21:38,518 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-1 >> Accept-Encoding: gzip,deflate
2016-02-11 08:21:38,518 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "GET /demo HTTP/1.1[\r][\n]"
2016-02-11 08:21:38,518 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "Authorization: Basic YWRtaW46cGFzc3dvcmQ=[\r][\n]"
2016-02-11 08:21:38,518 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "User-Agent: Jersey/2.22.1 (Apache HttpClient 4.5)[\r][\n]"
2016-02-11 08:21:38,519 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "Accept: application/fastinfoset[\r][\n]"
2016-02-11 08:21:38,519 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "Host: xxxxxxxxx:xxxx[\r][\n]"
2016-02-11 08:21:38,519 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "Connection: Keep-Alive[\r][\n]"
2016-02-11 08:21:38,519 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "Accept-Encoding: gzip,deflate[\r][\n]"
2016-02-11 08:21:38,519 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "[\r][\n]"
2016-02-11 08:21:38,527 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "HTTP/1.1 200 OK[\r][\n]"
2016-02-11 08:21:38,527 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)[\r][\n]"
2016-02-11 08:21:38,527 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "Server: GlassFish Server Open Source Edition 3.1.2.2[\r][\n]"
2016-02-11 08:21:38,527 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "Set-Cookie: JSESSIONID=07e892d4afe3e65dc53dc4238906; Path=demo; HttpOnly[\r][\n]"
2016-02-11 08:21:38,527 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "Content-Encoding: gzip[\r][\n]"
2016-02-11 08:21:38,527 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "Content-Type: application/fastinfoset[\r][\n]"
2016-02-11 08:21:38,528 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "Transfer-Encoding: chunked[\r][\n]"
2016-02-11 08:21:38,528 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "Date: Thu, 11 Feb 2016 13:21:39 GMT[\r][\n]"
2016-02-11 08:21:38,528 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "[\r][\n]"
2016-02-11 08:21:38,528 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "a[\r][\n]"
2016-02-11 08:21:38,528 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "[0x1f][0x8b][0x8][0x0][0x0][0x0][0x0][0x0][0x0][0x0][\r][\n]"
2016-02-11 08:21:38,528 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:113) http-outgoing-1 << HTTP/1.1 200 OK
2016-02-11 08:21:38,528 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-1 << X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)
2016-02-11 08:21:38,528 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-1 << Server: GlassFish Server Open Source Edition 3.1.2.2
2016-02-11 08:21:38,529 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-1 << Set-Cookie: JSESSIONID=07e892d4afe3e65dc53dc4238906; Path=/demo; HttpOnly
2016-02-11 08:21:38,529 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-1 << Content-Encoding: gzip
2016-02-11 08:21:38,529 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-1 << Content-Type: application/fastinfoset
2016-02-11 08:21:38,529 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-1 << Transfer-Encoding: chunked
2016-02-11 08:21:38,529 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-1 << Date: Thu, 11 Feb 2016 13:21:39 GMT
2016-02-11 08:21:38,530 [DEBUG] {main} (MainClientExec.java:284) Connection can be kept alive indefinitely
2016-02-11 08:21:38,530 [DEBUG] {main} (ResponseProcessCookies.java:118) Cookie accepted [JSESSIONID="07e892d4afe3e65dc53dc4238906", version:0, domain:xxxxxxxxx:xxxx, path:/demo, expiry:null]
2016-02-11 08:21:38,532 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "11c[\r][\n]"
2016-02-11 08:21:38,532 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "[0x85][0x8e]=N[0xc3]0[0x18][0x86][0xed]8[0x81]c[0xb0][0xb2][0xd0][0xfc]6TU&T$[0x6][0x98]XXMb[0xa5][0x16][0xc4]Mc[0x97][0x4][0xb1][0x90][0x1b]T>A[0xa1][0xc0][0xc2]az[0x5][0x8e][0xe0][0x1b][0x84]4HI*E[0xc2][0xd3][0xa7][0xf7]{[0x1e][0xbf][0xdf][0xf][0x0][0x10]LvZ[0xc1][0xe9][0xe9]\[0x88]tj[0x9a]y[0x9e][0x8f]rw[0xb4][0xc8]b[0xd3][0xb1],[0xdb][0xbc][0xbb][0xb9][0xbe][\r][0xe7]$[0xc1]g[0x94]q[0x81]YHv[0xb0][0xe0]'[0xff][0xd1]*8[0xbe][0xa0]"[0xc3][0x82][0xf0][0x0]EX[0xe0][0x0][0xa6]I[0x0]i[0xb4][0xb6]T[0xa0]?[0xe1][0xc7][0x15][0x9]@[0x8a][0xe4]QD3[0x12][\n]"
2016-02-11 08:21:38,532 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "[0xba]`j[0xf6]R[0x96]H<[0xa7][0xe4][0xb2][0xe0]S[0xca][0x84][0xda]T[0x6][0x92][0x90][0xe1][0x84][0xa8][0x19][0xb8][0x2]u[0xca]EFY[0xac]$X[0xc5]|[0xbf][0xd4][0xef][0xff]:[0xea][0xfd][0xab][0x92][0xc8][0xb6][0xf6][0xaf][0xaa]4[0xb4][0xb6][0x95]n[0xa0][0xb7]&[0xff][0xaa][0xc9][0xf7]z*[0xd5][0xb6][0x9e]>[0x9a][0xec][0xb3][0x81][0x9c][0xe][0xda][0xb4][0x90][0x84][0xcb][0x94]?[0xb4][0xa4][0xd4]=[0xab][0xfb][0xd6][0x1d]44[0xdf][[0xe2][0xa4]S[0xc][0xdb][0xe9]9[0xde][0xd0])[0xdf]=[0xda]9[0xef][0xd1][0xe3][0xe1][0x6][0xdb]?h[0xd0]'=[0xc5][0x1f]*[0x90][0xc8][0x19][0x1f]:[0x86][0xdb]J[0x95][0xfa][0x5]$[0x10][0xb7]([0xfa][0x1][0x0][0x0][\r][\n]"
2016-02-11 08:21:38,532 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "0[\r][\n]"
2016-02-11 08:21:38,532 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "[\r][\n]"
2016-02-11 08:21:38,533 [INFO ] {main} (RestLoggingFilter.java:209) 2* Client response received on thread main
2< 200
2< Content-Length: -1
2< Content-Type: application/fastinfoset
2< Date: Thu, 11 Feb 2016 13:21:39 GMT
2< Server: GlassFish Server Open Source Edition 3.1.2.2
2< Set-Cookie: JSESSIONID=07e892d4afe3e65dc53dc4238906; Path=/demo; HttpOnly
2< Transfer-Encoding: chunked
2< X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)
� � 8��xsi(http://www.w3.org/2001/XMLSchema-instance��xs�http://www.w3.org/2001/XMLSchema�<�Bitrates<�data<�pm<�id�0�<�value< p���direction�D{���typeExs:int������name�D H xs:string� ugs�����bitrate�D ���100000�����1������D �������D �������D �������2������D �������D ���qpsk�����D ���4000000�����3������D �������D ���64qam�����D ���12000000�����4������D �������D �������D ���27000000�����5������D �������D ���16qam�����D ���8000000�����6������D �������D ���256qam�����D ���38000000����
2016-02-11 08:21:38,541 [INFO ] {main} (RestLoggingFilter.java:209) 1* Client response received on thread main
1< 200
1< Content-Length: -1
1< Content-Type: application/fastinfoset
1< Date: Thu, 11 Feb 2016 13:21:39 GMT
1< Server: GlassFish Server Open Source Edition 3.1.2.2
1< Set-Cookie: JSESSIONID=07e892d4afe3e65dc53dc4238906; Path=/demo; HttpOnly
1< Transfer-Encoding: chunked
1< X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)
� � 8��xsi(http://www.w3.org/2001/XMLSchema-instance��xs�http://www.w3.org/2001/XMLSchema�<�Bitrates<�data<�pm<�id�0�<�value< p���direction�D{���typeExs:int������name�D H xs:string� ugs�����bitrate�D ���100000�����1������D �������D �������D �������2������D �������D ���qpsk�����D ���4000000�����3������D �������D ���64qam�����D ���12000000�����4������D �������D �������D ���27000000�����5������D �������D ���16qam�����D ���8000000�����6������D �������D ���256qam�����D ���38000000����
2016-02-11 08:21:38,542 [DEBUG] {main} (PoolingHttpClientConnectionManager.java:314) Connection [id: 1][route: {}->http://xxxxxxxxx:xxxx] can be kept alive indefinitely
2016-02-11 08:21:38,543 [DEBUG] {main} (PoolingHttpClientConnectionManager.java:320) Connection released: [id: 1][route: {}->http://xxxxxxxxx:xxxx][total kept alive: 1; route allocated: 2 of 2; total allocated: 2 of 20]
Value = � � 8��xsi(http://www.w3.org/2001/XMLSchema-instance��xs�http://www.w3.org/2001/XMLSchema�<�Bitrates<�data<�pm<�id�0�<�value< p���direction�D{���typeExs:int������name�D H xs:string� ugs�����bitrate�D ���100000�����1������D �������D �������D �������2������D �������D ���qpsk�����D ���4000000�����3������D �������D ���64qam�����D ���12000000�����4������D �������D �������D ���27000000�����5������D �������D ���16qam�����D ���8000000�����6������D �������D ���256qam�����D ���38000000����
another request
2016-02-11 08:21:38,543 [INFO ] {main} (RestLoggingFilter.java:209) 3* Sending client request on thread main
3> GET http://xxxxxxxxx:xxxx/demo
3> Accept: application/fastinfoset
2016-02-11 08:21:38,544 [DEBUG] {main} (RequestAddCookies.java:122) CookieSpec selected: default
2016-02-11 08:21:38,607 [DEBUG] {main} (RequestAddCookies.java:167) Cookie [version: 0][name: JSESSIONID][value: 07e88e48ee0f7f379251a73cc4b9][domain: xxxxxxxxx:xxxx][path: /demo][expiry: null] match [xxxxxxxxx:xxxx/demo]
2016-02-11 08:21:38,609 [DEBUG] {main} (RequestAuthCache.java:130) Re-using cached 'basic' auth scheme for http://xxxxxxxxx:xxxx
2016-02-11 08:21:38,609 [DEBUG] {main} (RequestAuthCache.java:144) No credentials for preemptive authentication
2016-02-11 08:21:38,609 [DEBUG] {main} (PoolingHttpClientConnectionManager.java:249) Connection request: [route: {}->http://xxxxxxxxx:xxxx][total kept alive: 1; route allocated: 2 of 2; total allocated: 2 of 20]
2016-02-11 08:21:38,609 [DEBUG] {main} (PoolingHttpClientConnectionManager.java:282) Connection leased: [id: 1][route: {}->http://xxxxxxxxx:xxxx][total kept alive: 0; route allocated: 2 of 2; total allocated: 2 of 20]
2016-02-11 08:21:38,609 [DEBUG] {main} (MainClientExec.java:255) Executing request GET /demo HTTP/1.1
2016-02-11 08:21:38,609 [DEBUG] {main} (MainClientExec.java:260) Target auth state: UNCHALLENGED
2016-02-11 08:21:38,609 [DEBUG] {main} (MainClientExec.java:266) Proxy auth state: UNCHALLENGED
2016-02-11 08:21:38,610 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:124) http-outgoing-1 >> GET /demo HTTP/1.1
2016-02-11 08:21:38,610 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-1 >> Accept: application/fastinfoset
2016-02-11 08:21:38,610 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-1 >> User-Agent: Jersey/2.22.1 (Apache HttpClient 4.5)
2016-02-11 08:21:38,610 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-1 >> Host: xxxxxxxxx:xxxx
2016-02-11 08:21:38,610 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-1 >> Connection: Keep-Alive
2016-02-11 08:21:38,610 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-1 >> Cookie: JSESSIONID=07e88e48ee0f7f379251a73cc4b9
2016-02-11 08:21:38,610 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:127) http-outgoing-1 >> Accept-Encoding: gzip,deflate
2016-02-11 08:21:38,610 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "GET /demo HTTP/1.1[\r][\n]"
2016-02-11 08:21:38,610 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "Accept: application/fastinfoset[\r][\n]"
2016-02-11 08:21:38,610 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "User-Agent: Jersey/2.22.1 (Apache HttpClient 4.5)[\r][\n]"
2016-02-11 08:21:38,610 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "Host: xxxxxxxxx:xxxx[\r][\n]"
2016-02-11 08:21:38,610 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "Connection: Keep-Alive[\r][\n]"
2016-02-11 08:21:38,611 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "Cookie: JSESSIONID=07e88e48ee0f7f379251a73cc4b9[\r][\n]"
2016-02-11 08:21:38,611 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "Accept-Encoding: gzip,deflate[\r][\n]"
2016-02-11 08:21:38,611 [DEBUG] {main} (Wire.java:72) http-outgoing-1 >> "[\r][\n]"
2016-02-11 08:21:38,620 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "HTTP/1.1 401 Full authentication is required to access this resource[\r][\n]"
2016-02-11 08:21:38,620 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)[\r][\n]"
2016-02-11 08:21:38,620 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "Server: GlassFish Server Open Source Edition 3.1.2.2[\r][\n]"
2016-02-11 08:21:38,620 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "WWW-Authenticate: Basic realm="DEMO Specific Web Service"[\r][\n]"
2016-02-11 08:21:38,620 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "Content-Type: text/html[\r][\n]"
2016-02-11 08:21:38,620 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "Content-Length: 1238[\r][\n]"
2016-02-11 08:21:38,620 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "Date: Thu, 11 Feb 2016 13:21:39 GMT[\r][\n]"
2016-02-11 08:21:38,621 [DEBUG] {main} (Wire.java:72) http-outgoing-1 << "[\r][\n]"
2016-02-11 08:21:38,621 [DEBUG] {main} (Wire.java:86) http-outgoing-1 << "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>GlassFish Server Open Source Edition 3.1.2.2 - Error report</title><style type="text/css"><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 401 - Full authentication is required to access this resource</h1><hr/><p><b>type</b> Status report</p><p><b>message</b>Full authentication is required to access this resource</p><p><b>description</b>This request requires HTTP authentication (Full authentication is required to access this resource).</p><hr/><h3>GlassFish Server Open Source Edition 3.1.2.2</h3></body></html>"
2016-02-11 08:21:38,621 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:113) http-outgoing-1 << HTTP/1.1 401 Full authentication is required to access this resource
2016-02-11 08:21:38,621 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-1 << X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 3.1.2.2 Java/Oracle Corporation/1.7)
2016-02-11 08:21:38,621 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-1 << Server: GlassFish Server Open Source Edition 3.1.2.2
2016-02-11 08:21:38,621 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-1 << WWW-Authenticate: Basic realm="DEMO Specific Web Service"
2016-02-11 08:21:38,621 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-1 << Content-Type: text/html
2016-02-11 08:21:38,621 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-1 << Content-Length: 1238
2016-02-11 08:21:38,621 [DEBUG] {main} (LoggingManagedHttpClientConnection.java:116) http-outgoing-1 << Date: Thu, 11 Feb 2016 13:21:39 GMT
2016-02-11 08:21:38,622 [DEBUG] {main} (MainClientExec.java:284) Connection can be kept alive indefinitely
2016-02-11 08:21:38,622 [DEBUG] {main} (HttpAuthenticator.java:77) Authentication required
2016-02-11 08:21:38,622 [DEBUG] {main} (HttpAuthenticator.java:107) 10.2.254.31:10080 requested authentication
2016-02-11 08:21:38,622 [DEBUG] {main} (AuthenticationStrategyImpl.java:174) Authentication schemes in the order of preference: [Negotiate, Kerberos, NTLM, Digest, Basic]
2016-02-11 08:21:38,622 [DEBUG] {main} (AuthenticationStrategyImpl.java:203) Challenge for Negotiate authentication scheme not available
2016-02-11 08:21:38,622 [DEBUG] {main} (AuthenticationStrategyImpl.java:203) Challenge for Kerberos authentication scheme not available
2016-02-11 08:21:38,623 [DEBUG] {main} (AuthenticationStrategyImpl.java:203) Challenge for NTLM authentication scheme not available
2016-02-11 08:21:38,623 [DEBUG] {main} (AuthenticationStrategyImpl.java:203) Challenge for Digest authentication scheme not available
2016-02-11 08:21:38,668 [INFO ] {main} (RestLoggingFilter.java:209) 4* Sending client request on thread main
4> GET http://xxxxxxxxx:xxxx/demo
4> Accept: application/fastinfoset
4> Authorization: Basic YWRtaW46cGFzc3dvcmQ=
4> User-Agent: Jersey/2.22.1 (Apache HttpClient 4.5)
2016-02-11 08:21:38,669 [DEBUG] {main} (RequestAddCookies.java:122) CookieSpec selected: default
2016-02-11 08:21:38,670 [DEBUG] {main} (RequestAuthCache.java:130) Re-using cached 'basic' auth scheme for http://xxxxxxxxx:xxxx
2016-02-11 08:21:38,670 [DEBUG] {main} (RequestAuthCache.java:144) No credentials for preemptive authentication
2016-02-11 08:21:38,670 [DEBUG] {main} (PoolingHttpClientConnectionManager.java:249) Connection request: [route: {}->http://xxxxxxxxx:xxxx][total kept alive: 0; route allocated: 2 of 2; total allocated: 2 of 20]
Process finished with exit code -1
@glassfishrobot Commented This issue was imported from java.net JIRA JERSEY-3053
I create a basic get call to a server with Basic authentification. I use 2 max connections for a client and 20 max connection in the pool.
My demo make 2 calls, the first one I received a response, but the second stall there because I setted 2 connections max, and the first request took 2 connections instead of one.
Affected Versions
[2.22.1]