Convert a postman form-data post request to a java request - java

I want to "transform" the below form-data request in postman into java code (within a java caller). More precisely, I`m trying to implement a caller to the below displayed api so i can access the endpoint through a jar. The problem is that I have 2 String arrays, to and cc , and 2 Strings, content and subject (obviously the api sends an email / ignore the attachment field for now) and I have no idea how I can set those parameters to my form-data in java.
Here my post method in Main class
public static void myPostRequest() throws IOException {
URL object = new URL(POST_ENDPOINT);
HttpURLConnection postConnection = (HttpURLConnection) object.openConnection();
postConnection.setRequestMethod("POST");
postConnection.setRequestProperty("to", "alice#example.com");
postConnection.setRequestProperty("to", "bob#anotherex.com");
postConnection.setRequestProperty("cc", "alice#example.com");
postConnection.setRequestProperty("cc", "bob#anotherex.com");
postConnection.setRequestProperty("subject", "randomsubject");
postConnection.setRequestProperty("content", "randomContent");
// postConnection.setRequestProperty("contentType", "text/html");
// postConnection.setRequestProperty("Content-Type", "application/json");
postConnection.setDoOutput(true);
OutputStream os = postConnection.getOutputStream();
os.flush();
os.close();
int responseCode = postConnection.getResponseCode();
System.out.println("POST response code " + responseCode);
System.out.println("POST response message" + postConnection.getResponseMessage());
if (responseCode == HttpURLConnection.HTTP_OK) { //success
BufferedReader in = new BufferedReader(new InputStreamReader(postConnection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println("RESPONSE: " + response.toString());
} else {
System.out.println("POST DIDN`T WORK");
}
}
And the controller method in the other application (that works in postman):
#ApiOperation("Send notification email")
#RequestMapping(path = "/email", method = RequestMethod.POST, consumes = {"multipart/form-data"})
private String sendNotificationEmail(#RequestParam("to") String[] to,
#RequestParam("cc") String[] cc,
#RequestParam("subject") String subject,
#RequestParam("content") String content) String contentType,
#RequestParam(name = "attachments") MultipartFile[] attachements
) {
EmailSender.sendMail(new EmailSettings(to, cc, subject, content, null), attachements);
return "Email sent";
}
Log:
"C:\Program Files\Java\jdk1.8.0_211\bin\java.exe" "-javaagent:C:\Program Files\Java\jdk1.8.0_211\jre\lib\rt.jar;C:\GIT\ocademo\target\classes;C:\Users\MARIUS1.POP\.m2\repository\org\springframework\spring-web\5.3.2\spring-web-5.3.2.jar;C:\Users\MARIUS1.POP\.m2\repository\org\springframework\spring-beans\5.3.2\spring-beans-5.3.2.jar;C:\Users\MARIUS1.POP\.m2\repository\org\springframework\spring-core\5.3.2\spring-core-5.3.2.jar;C:\Users\MARIUS1.POP\.m2\repository\org\springframework\spring-jcl\5.3.2\spring-jcl-5.3.2.jar;C:\Users\MARIUS1.POP\.m2\repository\org\apache\httpcomponents\httpclient\4.5.2\httpclient-4.5.2.jar;C:\Users\MARIUS1.POP\.m2\repository\org\apache\httpcomponents\httpcore\4.4.14\httpcore-4.4.14.jar;C:\Users\MARIUS1.POP\.m2\repository\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;C:\Users\MARIUS1.POP\.m2\repository\org\springframework\spring-webflux\5.3.2\spring-webflux-5.3.2.jar;C:\Users\MARIUS1.POP\.m2\repository\io\projectreactor\reactor-core\3.4.1\reactor-core-3.4.1.jar;C:\Users\MARIUS1.POP\.m2\repository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;C:\Users\MARIUS1.POP\.m2\repository\io\projectreactor\netty\reactor-netty\1.0.2\reactor-netty-1.0.2.jar;C:\Users\MARIUS1.POP\.m2\repository\io\projectreactor\netty\reactor-netty-core\1.0.2\reactor-netty-core-1.0.2.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-handler\4.1.55.Final\netty-handler-4.1.55.Final.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-common\4.1.55.Final\netty-common-4.1.55.Final.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-resolver\4.1.55.Final\netty-resolver-4.1.55.Final.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-buffer\4.1.55.Final\netty-buffer-4.1.55.Final.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-transport\4.1.55.Final\netty-transport-4.1.55.Final.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-codec\4.1.55.Final\netty-codec-4.1.55.Final.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-handler-proxy\4.1.55.Final\netty-handler-proxy-4.1.55.Final.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-codec-socks\4.1.55.Final\netty-codec-socks-4.1.55.Final.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-resolver-dns\4.1.55.Final\netty-resolver-dns-4.1.55.Final.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-codec-dns\4.1.55.Final\netty-codec-dns-4.1.55.Final.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-transport-native-epoll\4.1.55.Final\netty-transport-native-epoll-4.1.55.Final-linux-x86_64.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-transport-native-unix-common\4.1.55.Final\netty-transport-native-unix-common-4.1.55.Final.jar;C:\Users\MARIUS1.POP\.m2\repository\io\projectreactor\netty\reactor-netty-http\1.0.2\reactor-netty-http-1.0.2.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-codec-http\4.1.55.Final\netty-codec-http-4.1.55.Final.jar;C:\Users\MARIUS1.POP\.m2\repository\io\netty\netty-codec-http2\4.1.55.Final\netty-codec-http2-4.1.55.Final.jar;C:\Users\MARIUS1.POP\.m2\repository\io\projectreactor\netty\reactor-netty-http-brave\1.0.2\reactor-netty-http-brave-1.0.2.jar;C:\Users\MARIUS1.POP\.m2\repository\io\zipkin\brave\brave-instrumentation-http\5.13.2\brave-instrumentation-http-5.13.2.jar;C:\Users\MARIUS1.POP\.m2\repository\io\zipkin\brave\brave\5.13.2\brave-5.13.2.jar;C:\Users\MARIUS1.POP\.m2\repository\io\zipkin\reporter2\zipkin-reporter-brave\2.16.1\zipkin-reporter-brave-2.16.1.jar;C:\Users\MARIUS1.POP\.m2\repository\io\zipkin\reporter2\zipkin-reporter\2.16.1\zipkin-reporter-2.16.1.jar;C:\Users\MARIUS1.POP\.m2\repository\io\zipkin\zipkin2\zipkin\2.23.0\zipkin-2.23.0.jar;C:\Users\MARIUS1.POP\.m2\repository\com\github\Cloudmersive\Cloudmersive.APIClient.Java\v3.62\Cloudmersive.APIClient.Java-v3.62.jar;C:\Users\MARIUS1.POP\.m2\repository\org\threeten\threetenbp\1.3.5\threetenbp-1.3.5.jar;C:\Users\MARIUS1.POP\.m2\repository\com\squareup\okhttp\okhttp\2.7.5\okhttp-2.7.5.jar;C:\Users\MARIUS1.POP\.m2\repository\com\squareup\okio\okio\1.6.0\okio-1.6.0.jar;C:\Users\MARIUS1.POP\.m2\repository\com\google\code\gson\gson\2.8.6\gson-2.8.6.jar;C:\Users\MARIUS1.POP\.m2\repository\io\gsonfire\gson-fire\1.8.0\gson-fire-1.8.0.jar;C:\Users\MARIUS1.POP\.m2\repository\com\squareup\okhttp\logging-interceptor\2.7.5\logging-interceptor-2.7.5.jar;C:\Users\MARIUS1.POP\.m2\repository\io\swagger\swagger-annotations\1.5.15\swagger-annotations-1.5.15.jar;C:\Users\MARIUS1.POP\.m2\repository\org\springframework\boot\spring-boot-starter\2.4.1\spring-boot-starter-2.4.1.jar;C:\Users\MARIUS1.POP\.m2\repository\org\springframework\boot\spring-boot\2.4.1\spring-boot-2.4.1.jar;C:\Users\MARIUS1.POP\.m2\repository\org\springframework\spring-context\5.3.2\spring-context-5.3.2.jar;C:\Users\MARIUS1.POP\.m2\repository\org\springframework\spring-aop\5.3.2\spring-aop-5.3.2.jar;C:\Users\MARIUS1.POP\.m2\repository\org\springframework\spring-expression\5.3.2\spring-expression-5.3.2.jar;C:\Users\MARIUS1.POP\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.4.1\spring-boot-autoconfigure-2.4.1.jar;C:\Users\MARIUS1.POP\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.4.1\spring-boot-starter-logging-2.4.1.jar;C:\Users\MARIUS1.POP\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\MARIUS1.POP\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\MARIUS1.POP\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;C:\Users\MARIUS1.POP\.m2\repository\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;C:\Users\MARIUS1.POP\.m2\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;C:\Users\MARIUS1.POP\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\MARIUS1.POP\.m2\repository\org\yaml\snakeyaml\1.27\snakeyaml-1.27.jar;C:\Users\MARIUS1.POP\.m2\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar" oca.demo.ocademo.Main
14:37:03.760 [main] DEBUG reactor.util.Loggers - Using Slf4j logging framework
14:37:03.789 [main] DEBUG io.netty.util.internal.logging.InternalLoggerFactory - Using SLF4J as the default logging framework
14:37:03.789 [main] DEBUG io.netty.util.internal.PlatformDependent - Platform: Windows
14:37:03.791 [main] DEBUG io.netty.util.internal.PlatformDependent0 - -Dio.netty.noUnsafe: false
14:37:03.791 [main] DEBUG io.netty.util.internal.PlatformDependent0 - Java version: 8
14:37:03.792 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.theUnsafe: available
14:37:03.793 [main] DEBUG io.netty.util.internal.PlatformDependent0 - sun.misc.Unsafe.copyMemory: available
14:37:03.793 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Buffer.address: available
14:37:03.793 [main] DEBUG io.netty.util.internal.PlatformDependent0 - direct buffer constructor: available
14:37:03.794 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.Bits.unaligned: available, true
14:37:03.794 [main] DEBUG io.netty.util.internal.PlatformDependent0 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable prior to Java9
14:37:03.794 [main] DEBUG io.netty.util.internal.PlatformDependent0 - java.nio.DirectByteBuffer.<init>(long, int): available
14:37:03.794 [main] DEBUG io.netty.util.internal.PlatformDependent - sun.misc.Unsafe: available
14:37:03.794 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.tmpdir: C:\Users\MARIUS1.POP\AppData\Local\Temp (java.io.tmpdir)
14:37:03.794 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.bitMode: 64 (sun.arch.data.model)
14:37:03.795 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: 3791650816 bytes
14:37:03.795 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1
14:37:03.796 [main] DEBUG io.netty.util.internal.CleanerJava6 - java.nio.ByteBuffer.cleaner(): available
14:37:03.796 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
14:37:03.809 [main] DEBUG reactor.netty.tcp.TcpResources - [http] resources will use the default LoopResources: DefaultLoopResources {prefix=reactor-http, daemon=true, selectCount=12, workerCount=12}
14:37:03.809 [main] DEBUG reactor.netty.tcp.TcpResources - [http] resources will use the default ConnectionProvider: reactor.netty.resources.DefaultPooledConnectionProvider#614c5515
14:37:03.843 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.level: simple
14:37:03.843 [main] DEBUG io.netty.util.ResourceLeakDetector - -Dio.netty.leakDetection.targetRecords: 4
14:37:04.070 [main] DEBUG org.springframework.web.reactive.function.client.ExchangeFunctions - [7e0b85f9] HTTP POST http://mdl07cj001.bt.wan:7003/MIS/Notification/Email/api/notification/email
14:37:04.135 [main] DEBUG reactor.netty.resources.DefaultLoopEpoll - Default Epoll support : false
14:37:04.136 [main] DEBUG reactor.netty.resources.DefaultLoopKQueue - Default KQueue support : false
14:37:04.139 [main] DEBUG io.netty.channel.MultithreadEventLoopGroup - -Dio.netty.eventLoopThreads: 24
14:37:04.152 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.initialSize: 1024
14:37:04.152 [main] DEBUG io.netty.util.internal.InternalThreadLocalMap - -Dio.netty.threadLocalMap.stringBuilder.maxSize: 4096
14:37:04.156 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.noKeySetOptimization: false
14:37:04.157 [main] DEBUG io.netty.channel.nio.NioEventLoop - -Dio.netty.selectorAutoRebuildThreshold: 512
14:37:04.162 [main] DEBUG io.netty.util.internal.PlatformDependent - org.jctools-core.MpscChunkedArrayQueue: available
14:37:04.194 [main] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false
14:37:04.194 [main] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false
14:37:04.228 [main] DEBUG io.netty.util.NetUtilInitializations - Loopback interface: lo (Software Loopback Interface 1, 127.0.0.1)
14:37:04.229 [main] DEBUG io.netty.util.NetUtil - Failed to get SOMAXCONN from sysctl and file \proc\sys\net\core\somaxconn. Default: 200
14:37:04.278 [main] DEBUG io.netty.resolver.dns.DefaultDnsServerAddressStreamProvider - Default DNS servers: [/10.100.101.50:53, /10.100.101.51:53] (sun.net.dns.ResolverConfiguration)
14:37:04.283 [main] DEBUG reactor.netty.resources.PooledConnectionProvider - Creating a new [http] client pool [PoolFactory{evictionInterval=PT0S, leasingStrategy=fifo, maxConnections=500, maxIdleTime=-1, maxLifeTime=-1, metricsEnabled=false, pendingAcquireMaxCount=1000, pendingAcquireTimeout=45000}] for [mdl07cj001.bt.wan:7003]
14:37:04.317 [main] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.processId: 15532 (auto-detected)
14:37:04.356 [main] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.machineId: f4:93:9f:ff:fe:f6:06:8a (auto-detected)
14:37:04.373 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numHeapArenas: 24
14:37:04.373 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.numDirectArenas: 24
14:37:04.373 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.pageSize: 8192
14:37:04.373 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxOrder: 11
14:37:04.373 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.chunkSize: 16777216
14:37:04.373 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.smallCacheSize: 256
14:37:04.373 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.normalCacheSize: 64
14:37:04.373 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
14:37:04.373 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimInterval: 8192
14:37:04.373 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.cacheTrimIntervalMillis: 0
14:37:04.373 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.useCacheForAllThreads: true
14:37:04.373 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedByteBuffersPerChunk: 1023
14:37:04.379 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled
14:37:04.379 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 0
14:37:04.379 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384
14:37:04.392 [reactor-http-nio-2] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [id: 0xacaa8747] Created a new pooled channel, now 1 active connections and 0 inactive connections
14:37:04.409 [reactor-http-nio-2] DEBUG io.netty.buffer.AbstractByteBuf - -Dio.netty.buffer.checkAccessible: true
14:37:04.409 [reactor-http-nio-2] DEBUG io.netty.buffer.AbstractByteBuf - -Dio.netty.buffer.checkBounds: true
14:37:04.410 [reactor-http-nio-2] DEBUG io.netty.util.ResourceLeakDetectorFactory - Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector#22f23501
14:37:04.413 [reactor-http-nio-2] DEBUG reactor.netty.transport.TransportConfig - [id: 0xacaa8747] Initialized pipeline DefaultChannelPipeline{(reactor.left.httpCodec = io.netty.handler.codec.http.HttpClientCodec), (reactor.left.httpDecompressor = io.netty.handler.codec.http.HttpContentDecompressor), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)}
14:37:04.438 [reactor-http-nio-1] DEBUG io.netty.util.ResourceLeakDetectorFactory - Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector#492aff7f
14:37:04.439 [reactor-http-nio-1] DEBUG io.netty.resolver.dns.DnsQueryContext - [id: 0xa3a7d02f] WRITE: UDP, [23067: /10.100.101.50:53], DefaultDnsQuestion(mdl07cj001.bt.wan. IN A)
14:37:04.443 [reactor-http-nio-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.maxCapacityPerThread: 4096
14:37:04.443 [reactor-http-nio-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.maxSharedCapacityFactor: 2
14:37:04.443 [reactor-http-nio-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.linkCapacity: 16
14:37:04.443 [reactor-http-nio-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.ratio: 8
14:37:04.443 [reactor-http-nio-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.delayedQueue.ratio: 8
14:37:04.456 [reactor-http-nio-1] DEBUG io.netty.resolver.dns.DnsNameResolver - [id: 0xa3a7d02f] RECEIVED: UDP [23067: /10.100.101.50:53], DatagramDnsResponse(from: /10.100.101.50:53, to: /0:0:0:0:0:0:0:0:55442, 23067, QUERY(0), NoError(0), RD AA RA)
DefaultDnsQuestion(mdl07cj001.bt.wan. IN A)
DefaultDnsRawRecord(mdl07cj001.bt.wan. 3600 IN A 4B)
DefaultDnsRawRecord(OPT flags:0 udp:4000 0B)
14:37:04.460 [reactor-http-nio-2] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] Registering pool release on close event for channel
14:37:04.460 [reactor-http-nio-2] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] Channel connected, now 1 active connections and 0 inactive connections
14:37:04.461 [reactor-http-nio-2] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] onStateChange(PooledConnection{channel=[id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003]}, [connected])
14:37:04.467 [reactor-http-nio-2] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] onStateChange(GET{uri=/, connection=PooledConnection{channel=[id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003]}}, [configured])
14:37:04.468 [reactor-http-nio-2] DEBUG reactor.netty.http.client.HttpClientConnect - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] Handler is being applied: {uri=http://mdl07cj001.bt.wan:7003/MIS/Notification/Email/api/notification/email, method=POST}
14:37:04.470 [reactor-http-nio-2] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] onStateChange(POST{uri=/MIS/Notification/Email/api/notification/email, connection=PooledConnection{channel=[id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003]}}, [request_prepared])
14:37:04.474 [reactor-http-nio-2] DEBUG org.springframework.http.codec.FormHttpMessageWriter - [7e0b85f9] Writing form fields [to, cc, subject, content, contentType] (content masked)
14:37:04.488 [reactor-http-nio-2] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] onStateChange(POST{uri=/MIS/Notification/Email/api/notification/email, connection=PooledConnection{channel=[id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003]}}, [request_sent])
14:37:04.517 [reactor-http-nio-2] DEBUG reactor.netty.http.client.HttpClientOperations - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] Received response (auto-read:false) : [Cache-Control=no-cache, no-store, max-age=0, must-revalidate, Date=Mon, 18 Jan 2021 12:37:04 GMT, Pragma=no-cache, Transfer-Encoding=chunked, Expires=0, X-ORACLE-DMS-ECID=57445be9-bcb8-496b-bd25-4986e33f3e23-00000135, X-ORACLE-DMS-RID=0, X-Frame-Options=DENY, Accept=multipart/form-data, X-Content-Type-Options=nosniff, X-XSS-Protection=1; mode=block]
14:37:04.517 [reactor-http-nio-2] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] onStateChange(POST{uri=/MIS/Notification/Email/api/notification/email, connection=PooledConnection{channel=[id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003]}}, [response_received])
14:37:04.519 [reactor-http-nio-2] DEBUG org.springframework.web.reactive.function.client.ExchangeFunctions - [7e0b85f9] Response 415 UNSUPPORTED_MEDIA_TYPE
14:37:04.530 [reactor-http-nio-2] DEBUG reactor.netty.channel.FluxReceive - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] FluxReceive{pending=0, cancelled=false, inboundDone=false, inboundError=null}: subscribing inbound receiver
14:37:04.531 [reactor-http-nio-2] DEBUG reactor.netty.http.client.HttpClientOperations - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] Received last HTTP packet
14:37:04.540 [reactor-http-nio-2] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] onStateChange(POST{uri=/MIS/Notification/Email/api/notification/email, connection=PooledConnection{channel=[id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003]}}, [response_completed])
Exception in thread "main" org.springframework.web.reactive.function.client.WebClientResponseException$UnsupportedMediaType: 415 Unsupported Media Type from POST http://mdl07cj001.bt.wan:7003/MIS/Notification/Email/api/notification/email
at org.springframework.web.reactive.function.client.WebClientResponseException.create(WebClientResponseException.java:195)
14:37:04.541 [reactor-http-nio-2] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] onStateChange(POST{uri=/MIS/Notification/Email/api/notification/email, connection=PooledConnection{channel=[id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003]}}, [disconnecting])
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
14:37:04.541 [reactor-http-nio-2] DEBUG reactor.netty.resources.DefaultPooledConnectionProvider - [id: 0xacaa8747, L:/10.0.69.115:49384 - R:mdl07cj001.bt.wan/10.100.139.63:7003] Releasing channel
|_ checkpoint ⇢ 415 from POST http://mdl07cj001.bt.wan:7003/MIS/Notification/Email/api/notification/email [DefaultWebClient]
Stack trace:
at org.springframework.web.reactive.function.client.WebClientResponseException.create(WebClientResponseException.java:195)
at org.springframework.web.reactive.function.client.DefaultClientResponse.lambda$createException$1(DefaultClientResponse.java:216)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:106)
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)
at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1784)
at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.onComplete(FluxDefaultIfEmpty.java:107)
at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onComplete(FluxMapFuseable.java:150)
at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onComplete(FluxContextWrite.java:126)
at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onComplete(FluxMapFuseable.java:344)
at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onComplete(FluxFilterFuseable.java:391)
at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1785)
at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:159)
at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:142)
at reactor.core.publisher.FluxPeek$PeekSubscriber.onComplete(FluxPeek.java:259)
at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:142)
at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:383)
at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:396)
at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:452)
at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:664)
at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:94)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:324)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:296)
at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
Suppressed: java.lang.Exception: #block terminated with an error
at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
at reactor.core.publisher.Mono.block(Mono.java:1703)
at oca.demo.ocademo.GetAndPost.newPostMethod(GetAndPost.java:120)
at oca.demo.ocademo.Main.main(Main.java:8)
Process finished with exit code 1

Postman allow converting request to other languages, just click code link below the request url.

If you are using spring, as I see with RequestMapping anotation, why dont you use restTemplate or webclient? (Depnding on the spring version you are using). It will be much easier.
Rest Template for Spring 4 and below, imperative style
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> map= new LinkedMultiValueMap<>();
map.add("to", "alice#example.com");
map.add("to", "bob#anotherex.com");
map.add("cc", "alice#example.com");
map.add("cc", "bob#anotherex.com");
map.add("subject", "randomsubject");
map.add("content", "randomContent");
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, headers);
RestTemplate restTemplate= new RestTemplateBuilder().rootUri("http://localhost:8080").build();
restTemplate.postForLocation( "url", request);
WebClient for Spring 5+, reactive style Requires WebFlux
WebClient client = WebClient.builder()
.baseUrl("http://localhost:8080")
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE)
.build();
client.post()
.uri("/api/notification/email...")
.body(BodyInserters.fromFormData("to", "alice#example.com")
.with("to", "bob#anotherex.com")
.with("cc", "alice#example.com")
.with("cc", "bob#anotherex.com")
.with("subject", "randomsubject")
.with("content", "randomContent"))
.retrieve()
.toBodilessEntity()
.block();
In both cases uses internally a multivalue map, so you can add various values with the same key, such as to and cc

Related

Read time out in Apache HTTP Client but request runs fine with curl

I have a PUT requests that is done by a dependency scanner we are using
I'm behind a corporate proxy
Request is done with Apache HTTP Client 4
I get a "read time out" after the configured timeout
I recreated the request with curl and this works fine (with the same proxy) and finishes within seconds
It works fine with Apache HTTP Client without the proxy.
So I'm trying to find out what config is missing in the HTTP client config or what else could be the error. Unfortunately neither our networking team nor the product vendor could help me out :-(
This is the curl request:
curl --connect-timeout 60 -m 60 -v -X PUT --data-binary #test.json
https://someblackduckserver/api/developer-scans/12345
-H "Content-type: application/vnd.blackducksoftware.developer-scan-1-ld-2+json"
-H "X-BD-DOCUMENT-COUNT: 1"
-H "Accept: application/vnd.blackducksoftware.scan-4+json"
-H "X-BD-MODE: append"
-H "X-BD-RAPID-SCAN-MODE: ALL" -H "X-BD-VERSION-NAME: scan-test"
-H "User-Agent: synopsys_detect/8.1.0-SNAPSHOT BlackDuckCommon/65.0.0 ..."
-H "X-BD-PROJECT-NAME: scan-test"
-H "Authorization: Bearer ..... left out ....."
Where test.json is a json file with about 1.3MB.
Minified code when using Apache HTTP Client:
RequestBuilder requestBuilder = RequestBuilder.create("PUT");
URIBuilder uriBuilder = new URIBuilder(new URI("https://someblackduckserver/api/developer-scans/12345"));
requestBuilder.setUri(uriBuilder.build());
Charset bodyEncoding = StandardCharsets.UTF_8;
requestBuilder.setCharset(bodyEncoding);
requestBuilder.addHeader("Content-type", "application/vnd.blackducksoftware.developer-scan-1-ld-2+json");
requestBuilder.addHeader("X-BD-DOCUMENT-COUNT", "1");
requestBuilder.addHeader("Accept", "application/vnd.blackducksoftware.scan-4+json");
requestBuilder.addHeader("X-BD-MODE", "append");
requestBuilder.addHeader("X-BD-RAPID-SCAN-MODE", "ALL");
requestBuilder.addHeader("X-BD-VERSION-NAME", "scan-test");
requestBuilder.addHeader("User-Agent", "synopsys_detect/8.1.0-SNAPSHOT BlackDuckCommon/65.0.0 ...");
requestBuilder.addHeader("X-BD-PROJECT-NAME", "scan-test");
requestBuilder.addHeader("Authorization", "Bearer ..... left out .....");
HttpEntity httpEntity = new FileEntity(new File("test.json"));
requestBuilder.setEntity(httpEntity);
HttpUriRequest request = requestBuilder.build();
HttpContext httpContext = new BasicHttpContext();
HttpClientBuilder clientBuilder = HttpClientBuilder.create();
RequestConfig.Builder defaultRequestConfigBuilder = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD);
// set our proxy
defaultRequestConfigBuilder.setProxy(new HttpHost("..... (left out)", 8080));
// set timeout
int timeoutInSeconds = 60;
defaultRequestConfigBuilder.setConnectTimeout(timeoutInSeconds * 1000);
defaultRequestConfigBuilder.setSocketTimeout(timeoutInSeconds * 1000);
defaultRequestConfigBuilder.setConnectionRequestTimeout(timeoutInSeconds * 1000);
clientBuilder.setDefaultRequestConfig(defaultRequestConfigBuilder.build());
// for testing: ignore ssl
HostnameVerifier hostnameVerifier;
SSLContext sslContext = SSLContextBuilder.create().loadTrustMaterial(new TrustAllStrategy()).build();
hostnameVerifier = new NoopHostnameVerifier();
SSLConnectionSocketFactory connectionFactory = new SSLConnectionSocketFactory(sslContext, hostnameVerifier);
clientBuilder.setSSLSocketFactory(connectionFactory);
try (CloseableHttpClient client = clientBuilder.build()) {
CloseableHttpResponse closeableHttpResponse = client.execute(request, httpContext);
System.out.println(closeableHttpResponse);
}
I removed some sensitive details from the request.
Any idea what I'm missing here or what could go wrong?
Logs from a sample the call:
2022-07-25 10:38:38.201 [main] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default
2022-07-25 10:38:38.206 [main] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
2022-07-25 10:38:38.207 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {tls}->http://our.proxy.ip.address:8080->https://someblackduckserver.com:443][total available: 0; route allocated: 0 of 2; total allocated: 0 of 20]
2022-07-25 10:38:38.259 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {tls}->http://our.proxy.ip.address:8080->https://someblackduckserver.com:443][total available: 0; route allocated: 1 of 2; total allocated: 1 of 20]
2022-07-25 10:38:38.260 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {tls}->http://our.proxy.ip.address:8080->https://someblackduckserver.com:443
2022-07-25 10:38:38.261 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to /our.proxy.ip.address:8080
2022-07-25 10:38:38.301 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connection established 10.17.10.44:34272<->our.proxy.ip.address:8080
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> CONNECT someblackduckserver.com:443 HTTP/1.1
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: someblackduckserver.com
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.5.13 (Java/11.0.13)
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "CONNECT someblackduckserver.com:443 HTTP/1.1[\r][\n]"
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: someblackduckserver.com[\r][\n]"
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.13 (Java/11.0.13)[\r][\n]"
2022-07-25 10:38:38.317 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
2022-07-25 10:38:38.346 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 200 Connection established[\r][\n]"
2022-07-25 10:38:38.346 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Proxy-Agent: Proxy-Vendor-Proxy/1.0[\r][\n]"
2022-07-25 10:38:38.346 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
2022-07-25 10:38:38.347 [main] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 200 Connection established
2022-07-25 10:38:38.347 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Proxy-Agent: Proxy-Vendor-Proxy/1.0
2022-07-25 10:38:38.347 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Tunnel to target created.
2022-07-25 10:38:38.432 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Enabled protocols: [TLSv1.3, TLSv1.2]
2022-07-25 10:38:38.440 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Enabled cipher suites:[TLS_AES_256_GCM_SHA384, TLS_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
2022-07-25 10:38:38.440 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Starting handshake
2022-07-25 10:38:39.252 [main] DEBUG jdk.event.security - X509Certificate: ... our ssl inspect certificate ...
2022-07-25 10:38:39.252 [main] DEBUG jdk.event.security - X509Certificate: ... our internal certificate ...
2022-07-25 10:38:39.275 [main] DEBUG jdk.event.security - TLSHandshake: someblackduckserver.com:8080, TLSv1.2, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 1942523025
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Secure session established
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - negotiated protocol: TLSv1.2
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - peer principal: CN=*.someblackduckserver.com, O="Synopsys, Inc.", L=Mountain View, ST=California, C=US
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - peer alternative names: [*.someblackduckserver.com]
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - issuer principal: ... our ssl inspect certificate ...
2022-07-25 10:38:39.276 [main] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 60000
2022-07-25 10:38:39.277 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request PUT /api/developer-scans/12345 HTTP/1.1
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> PUT /api/developer-scans/12345 HTTP/1.1
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-type: application/vnd.blackducksoftware.developer-scan-1-ld-2+json
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> X-BD-DOCUMENT-COUNT: 1
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept: application/vnd.blackducksoftware.scan-4+json
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> X-BD-MODE: append
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> X-BD-RAPID-SCAN-MODE: ALL
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> X-BD-VERSION-NAME: rapid-scan-test-igl-2
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: synopsys_detect/8.1.0-SNAPSHOT BlackDuckCommon/65.0.0 (Eclipse Foundation 11.0.12 amd64 Windows 10 10.0)
2022-07-25 10:38:39.277 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> X-BD-PROJECT-NAME: project_name
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Authorization: Bearer ...
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 287381
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: someblackduckserver.com
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "PUT /api/developer-scans/12345 HTTP/1.1[\r][\n]"
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-type: application/vnd.blackducksoftware.developer-scan-1-ld-2+json[\r][\n]"
2022-07-25 10:38:39.278 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "X-BD-DOCUMENT-COUNT: 1[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept: application/vnd.blackducksoftware.scan-4+json[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "X-BD-MODE: append[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "X-BD-RAPID-SCAN-MODE: ALL[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "X-BD-VERSION-NAME: rapid-scan-test-igl-2[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: synopsys_detect/8.1.0-SNAPSHOT BlackDuckCommon/65.0.0 (Eclipse Foundation 11.0.12 amd64 Windows 10 10.0)[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "X-BD-PROJECT-NAME: project_name[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Authorization: Bearer ...[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Length: 287381[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: someblackduckserver.com[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
2022-07-25 10:38:39.279 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
2022-07-25 10:38:39.423 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> .... all the logs for file content ....
2022-07-25 10:39:39.483 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[read] I/O error: Read timed out"
2022-07-25 10:39:39.483 [main] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: Close connection
2022-07-25 10:39:39.483 [main] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-0: Shutdown connection
2022-07-25 10:39:39.483 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Connection discarded
2022-07-25 10:39:39.483 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {tls}->http://our.proxy.ip.address:8080->https://someblackduckserver.com:443][total available: 0; route allocated: 0 of 2; total allocated: 0 of 20]
2022-07-25 10:39:39.484 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection manager is shutting down
2022-07-25 10:39:39.484 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection manager shut down
Exception in thread "main" java.net.SocketTimeoutException: Read timed out
at java.base/java.net.SocketInputStream.socketRead0(Native Method)
at java.base/java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:168)
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:478)
at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:472)
at java.base/sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:70)
at java.base/sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1318)
at java.base/sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:959)
at org.apache.http.impl.conn.LoggingInputStream.read(LoggingInputStream.java:84)
at org.apache.http.impl.io.SessionInputBufferImpl.streamRead(SessionInputBufferImpl.java:137)
at org.apache.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:153)
at org.apache.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:138)
at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:56)
at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:259)
at org.apache.http.impl.DefaultBHttpClientConnection.receiveResponseHeader(DefaultBHttpClientConnection.java:163)
at org.apache.http.impl.conn.CPoolProxy.receiveResponseHeader(CPoolProxy.java:157)
at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:273)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.example.BdTest.main(BdTest.java:93)
May be not a solution but a workaround if it works. I wrote my own Http client that is much simpler than Apache Http client. The reason I wrote it is that in many cases you just need a simplistic functionality so using a thin library lessens complexity and allows you to debug it if need be and it would allow you easier way to get to the bottom of the problem. So, may be you can give it a shot. At may even work or if not than it would be much easier to debug than Apache Http client. My Http client is part of MgntUtils Open-Source library written and maintained by me. Here is HttpClient Javadoc. The library can be obtained as Maven artifact from Maven Central and from Github (including source code and Javadoc)

TestContainers - Can't connect to MySQLContainer Docker - Integration Test

I'm Trying to run my Integration Test using MySQLContainer in Docker, however when i run the tests, the application gets caught in a loop trying to establish a JDBC Connection, find bellow my integration Test class and the log of the Spring Boot Application.
Integration Test Class
package com.recargaslda.multiplatform.repositorios;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import java.time.LocalDate;
import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.testcontainers.containers.MySQLContainer;
import com.recargaslda.multiplatform.entidades.Album;
#SpringBootTest
#ContextConfiguration(initializers = { AlbumRepositorioTesteIntegracao.Initializer.class })
public class AlbumRepositorioTesteIntegracao {
// Even When i change the image version to 5.5 it still fails to connect
#Rule
private static MySQLContainer sqlContainer = new MySQLContainer<>("mysql:8.0");
static {
sqlContainer.withDatabaseName("teste-integração-album-repositorio").withUsername("root").withPassword("root");
sqlContainer.start();
}
static class Initializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
#Override
public void initialize(ConfigurableApplicationContext applicationContext) {
TestPropertyValues.of("spring.datasource.url=" + sqlContainer.getJdbcUrl(),
"spring.datasource.username=" + sqlContainer.getUsername(),
"spring.datasource.password=" + sqlContainer.getPassword()).applyTo(applicationContext);
}
}
#Autowired
AlbumRepositorio albumRepositorio;
#Test
public void DevePersistirUmNovoAlbumSemImagens() {
Album album = new Album("album", LocalDate.now(), "Capa");
albumRepositorio.save(album);
Album albumEncontrado = albumRepositorio.findByNome("album");
assertThat(album.getNome(), is(albumEncontrado.getNome()));
}
}
The Console Log During the loop:
13:48:00.676 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.recargaslda.multiplatform.repositorios.AlbumRepositorioTesteIntegracao]: no resource found for suffixes {-context.xml, Context.groovy}.
13:48:00.678 [main] DEBUG org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Ignoring class [com.recargaslda.multiplatform.repositorios.AlbumRepositorioTesteIntegracao$Initializer]; it must be static, non-private, non-final, and annotated with #Configuration to be considered a default configuration class.
13:48:00.678 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.recargaslda.multiplatform.repositorios.AlbumRepositorioTesteIntegracao]: AlbumRepositorioTesteIntegracao does not declare any static, non-private, non-final, nested classes annotated with #Configuration.
13:48:00.770 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.recargaslda.multiplatform.repositorios.AlbumRepositorioTesteIntegracao]
13:48:00.990 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [C:\Users\Pete\Documents\Workspace\MultiPlatformAplicacao\target\classes\com\recargaslda\multiplatform\MultiPlatformApplication.class]
13:48:00.993 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found #SpringBootConfiguration com.recargaslda.multiplatform.MultiPlatformApplication for test class com.recargaslda.multiplatform.repositorios.AlbumRepositorioTesteIntegracao
13:48:01.216 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - #TestExecutionListeners is not present for class [com.recargaslda.multiplatform.repositorios.AlbumRepositorioTesteIntegracao]: using defaults.
13:48:01.217 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener, org.springframework.security.test.context.support.WithSecurityContextTestExecutionListener, org.springframework.security.test.context.support.ReactorContextTestExecutionListener]
13:48:01.269 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener#2eae8e6e, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener#8f2ef19, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener#470734c3, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener#2cf3d63b, org.springframework.test.context.support.DirtiesContextTestExecutionListener#7674f035, org.springframework.test.context.transaction.TransactionalTestExecutionListener#69e153c5, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener#173ed316, org.springframework.test.context.event.EventPublishingTestExecutionListener#25ce9dc4, org.springframework.security.test.context.support.WithSecurityContextTestExecutionListener#74ea2410, org.springframework.security.test.context.support.ReactorContextTestExecutionListener#17f62e33, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener#76b1e9b8, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener#27406a17, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener#2af004b, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener#248e319b, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener#5d0bf09b]
13:48:01.737 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Loaded org.testcontainers.dockerclient.NpipeSocketClientProviderStrategy from ~/.testcontainers.properties, will try it first
13:48:02.995 [ducttape-0] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - Pinging docker daemon...
13:48:03.311 [ducttape-0] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: org.testcontainers.dockerclient.transport.okhttp.OkHttpDockerCmdExecFactory$1#298aadd0
13:48:03.418 [main] INFO org.testcontainers.dockerclient.NpipeSocketClientProviderStrategy - Accessing docker with local Npipe socket (npipe:////./pipe/docker_engine)
13:48:03.419 [main] INFO org.testcontainers.dockerclient.DockerClientProviderStrategy - Found Docker environment with local Npipe socket (npipe:////./pipe/docker_engine)
13:48:03.419 [main] DEBUG org.testcontainers.dockerclient.DockerClientProviderStrategy - Checking Docker OS type for local Npipe socket (npipe:////./pipe/docker_engine)
13:48:03.421 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.exec.InfoCmdExec#1115ec15
13:48:03.715 [main] INFO org.testcontainers.DockerClientFactory - Docker host IP address is localhost
13:48:03.717 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.exec.InfoCmdExec#6155d082
13:48:03.738 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.exec.VersionCmdExec#7803bfd
13:48:03.770 [main] INFO org.testcontainers.DockerClientFactory - Connected to docker:
Server Version: 19.03.8
API Version: 1.40
Operating System: Docker Desktop
Total Memory: 1989 MB
13:48:03.770 [main] DEBUG org.testcontainers.DockerClientFactory - Ryuk is enabled
13:48:03.776 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ListImagesCmdImpl[imageNameFilter=quay.io/testcontainers/ryuk:0.2.3,showAll=false,filters=com.github.dockerjava.core.util.FiltersBuilder#0,execution=com.github.dockerjava.core.exec.ListImagesCmdExec#4f25b795]
13:48:03.851 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Looking up auth config for image: quay.io/testcontainers/ryuk:0.2.3
13:48:03.851 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - RegistryAuthLocator has configFile: C:\Users\Pete\.docker\config.json (exists) and commandPathPrefix:
13:48:03.860 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - registryName [quay.io] for dockerImageName [quay.io/testcontainers/ryuk:0.2.3]
13:48:03.861 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Executing docker credential provider: docker-credential-desktop to locate auth config for: quay.io
13:48:03.878 [main] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.ProcessExecutor - Executing [docker-credential-desktop, get].
13:48:03.885 [main] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.ProcessExecutor - Started java.lang.ProcessImpl#3212a8d7
13:48:04.044 [WaitForProcess-java.lang.ProcessImpl#3212a8d7] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.WaitForProcess - java.lang.ProcessImpl#3212a8d7 stopped with exit code 1
13:48:04.048 [main] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.ProcessExecutor - Executing [docker-credential-desktop, get].
13:48:04.053 [main] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.ProcessExecutor - Started java.lang.ProcessImpl#71454b9d
13:48:04.188 [WaitForProcess-java.lang.ProcessImpl#71454b9d] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.WaitForProcess - java.lang.ProcessImpl#71454b9d stopped with exit code 1
13:48:04.190 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Got credentials not found error message from docker credential helper - credentials not found in native keychain
13:48:04.192 [main] INFO org.testcontainers.utility.RegistryAuthLocator - Credential helper/store (docker-credential-desktop) does not have credentials for quay.io
13:48:04.195 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - no matching Auth Configs - falling back to defaultAuthConfig [null]
13:48:04.195 [main] DEBUG org.testcontainers.dockerclient.auth.AuthDelegatingDockerClientConfig - Effective auth config [null]
13:48:04.239 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.command.CreateContainerCmdImpl#584f54e6[name=testcontainers-ryuk-c9db393d-d0ec-4740-848a-134abfe549c5,hostName=<null>,domainName=<null>,user=<null>,attachStdin=<null>,attachStdout=<null>,attachStderr=<null>,portSpecs=<null>,tty=<null>,stdinOpen=<null>,stdInOnce=<null>,env=<null>,cmd=<null>,healthcheck=<null>,argsEscaped=<null>,entrypoint=<null>,image=quay.io/testcontainers/ryuk:0.2.3,volumes=com.github.dockerjava.api.model.Volumes#23aa363a,workingDir=<null>,macAddress=<null>,onBuild=<null>,networkDisabled=<null>,exposedPorts=com.github.dockerjava.api.model.ExposedPorts#5ef6ae06,stopSignal=<null>,stopTimeout=<null>,hostConfig=com.github.dockerjava.api.model.HostConfig#55dfebeb[binds=com.github.dockerjava.api.model.Binds#604f2bd2,blkioWeight=<null>,blkioWeightDevice=<null>,blkioDeviceReadBps=<null>,blkioDeviceWriteBps=<null>,blkioDeviceReadIOps=<null>,blkioDeviceWriteIOps=<null>,memorySwappiness=<null>,nanoCPUs=<null>,capAdd=<null>,capDrop=<null>,containerIDFile=<null>,cpuPeriod=<null>,cpuRealtimePeriod=<null>,cpuRealtimeRuntime=<null>,cpuShares=<null>,cpuQuota=<null>,cpusetCpus=<null>,cpusetMems=<null>,devices=<null>,deviceCgroupRules=<null>,diskQuota=<null>,dns=<null>,dnsOptions=<null>,dnsSearch=<null>,extraHosts=<null>,groupAdd=<null>,ipcMode=<null>,cgroup=<null>,links=<null>,logConfig=<null>,lxcConf=<null>,memory=<null>,memorySwap=<null>,memoryReservation=<null>,kernelMemory=<null>,networkMode=<null>,oomKillDisable=<null>,init=<null>,autoRemove=true,oomScoreAdj=<null>,portBindings=<null>,privileged=false,publishAllPorts=true,readonlyRootfs=<null>,restartPolicy=<null>,ulimits=<null>,cpuCount=<null>,cpuPercent=<null>,ioMaximumIOps=<null>,ioMaximumBandwidth=<null>,volumesFrom=<null>,mounts=<null>,pidMode=<null>,isolation=<null>,securityOpts=<null>,storageOpt=<null>,cgroupParent=<null>,volumeDriver=<null>,shmSize=<null>,pidsLimit=<null>,runtime=<null>,tmpFs=<null>,utSMode=<null>,usernsMode=<null>,sysctls=<null>,consoleSize=<null>],labels={org.testcontainers=true},shell=<null>,networkingConfig=<null>,ipv4Address=<null>,ipv6Address=<null>,aliases=<null>,authConfig=<null>,execution=com.github.dockerjava.core.exec.CreateContainerCmdExec#1d3ac898]
13:48:05.184 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: 63eb180f9f28ccc0ef8215d62d80d404de21b3841411a9ba29492c5dab3e42e0,com.github.dockerjava.core.exec.StartContainerCmdExec#56e8b606
13:48:06.714 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: 63eb180f9f28ccc0ef8215d62d80d404de21b3841411a9ba29492c5dab3e42e0,false,com.github.dockerjava.core.exec.InspectContainerCmdExec#366c4480
13:48:06.718 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient#2c7b5824, baseUrl=http://docker.socket/, path=[/containers/63eb180f9f28ccc0ef8215d62d80d404de21b3841411a9ba29492c5dab3e42e0/json], queryParams={})
13:48:06.892 [testcontainers-ryuk] DEBUG org.testcontainers.utility.ResourceReaper - Sending 'label=org.testcontainers%3Dtrue&label=org.testcontainers.sessionId%3Dc9db393d-d0ec-4740-848a-134abfe549c5' to Ryuk
13:48:06.895 [testcontainers-ryuk] DEBUG org.testcontainers.utility.ResourceReaper - Received 'ACK' from Ryuk
13:48:06.895 [main] INFO org.testcontainers.DockerClientFactory - Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
13:48:06.895 [main] DEBUG org.testcontainers.DockerClientFactory - Checks are enabled
13:48:06.895 [main] INFO org.testcontainers.DockerClientFactory - Checking the system...
13:48:06.896 [main] INFO org.testcontainers.DockerClientFactory - ✔︎ Docker server version should be at least 1.6.0
13:48:06.899 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: 63eb180f9f28ccc0ef8215d62d80d404de21b3841411a9ba29492c5dab3e42e0,<null>,true,<null>,<null>,<null>,<null>,{df,-P},<null>,<null>,com.github.dockerjava.core.exec.ExecCreateCmdExec#2a79d4b1
13:48:07.015 [tc-okhttp-stream-1130346421] DEBUG com.github.dockerjava.core.command.ExecStartResultCallback - STDOUT: Filesystem 1024-blocks Used Available Capacity Mounted on
overlay 61255652 3271272 54843048 6% /
tmpfs 65536 0 65536 0% /dev
tmpfs 1018508 0 1018508 0% /sys/fs/cgroup
shm 65536 0 65536 0% /dev/shm
/dev/sda1 61255652 3271272 54843048 6% /etc/resolv.conf
/dev/sda1 61255652 3271272 54843048 6% /etc/hostname
/dev/sda1 61255652 3271272 54843048 6% /etc/hosts
overlay 1018508 400 1018108 0% /run/docker.sock
tmpfs 1018508 0 1018508 0% /proc/acpi
tmpfs 65536 0 65536 0% /proc/kcore
tmpfs 65536 0 65536 0% /proc/keys
tmpfs 65536 0 65536 0% /proc/timer_list
tmpfs 65536 0 65536 0% /proc/sched_debug
tmpfs 1018508 0 1018508 0% /sys/firmware
13:48:07.045 [main] INFO org.testcontainers.DockerClientFactory - ✔︎ Docker environment should have more than 2GB free disk space
13:48:07.046 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ListImagesCmdImpl[imageNameFilter=<null>,showAll=false,filters=com.github.dockerjava.core.util.FiltersBuilder#0,execution=com.github.dockerjava.core.exec.ListImagesCmdExec#56c698e3]
13:48:07.091 [main] DEBUG org.testcontainers.images.AbstractImagePullPolicy - Using locally available and not pulling image: mysql:8.0
13:48:07.091 [main] DEBUG 🐳 [mysql:8.0] - Starting container: mysql:8.0
13:48:07.092 [main] DEBUG 🐳 [mysql:8.0] - Trying to start container: mysql:8.0
13:48:07.092 [main] DEBUG 🐳 [mysql:8.0] - Trying to start container: mysql:8.0 (attempt 1/3)
13:48:07.092 [main] DEBUG 🐳 [mysql:8.0] - Starting container: mysql:8.0
13:48:07.092 [main] INFO 🐳 [mysql:8.0] - Creating container for image: mysql:8.0
13:48:07.093 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Looking up auth config for image: mysql:8.0
13:48:07.093 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - RegistryAuthLocator has configFile: C:\Users\Pete\.docker\config.json (exists) and commandPathPrefix:
13:48:07.093 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - registryName [index.docker.io] for dockerImageName [mysql:8.0]
13:48:07.093 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Executing docker credential provider: docker-credential-desktop to locate auth config for: index.docker.io
13:48:07.093 [main] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.ProcessExecutor - Executing [docker-credential-desktop, get].
13:48:07.097 [main] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.ProcessExecutor - Started java.lang.ProcessImpl#5c8504fd
13:48:07.224 [WaitForProcess-java.lang.ProcessImpl#5c8504fd] DEBUG org.testcontainers.shaded.org.zeroturnaround.exec.WaitForProcess - java.lang.ProcessImpl#5c8504fd stopped with exit code 0
13:48:07.225 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - Credential helper/store provided auth config for: index.docker.io
13:48:07.232 [main] DEBUG org.testcontainers.utility.RegistryAuthLocator - found creds store auth config [AuthConfig{username=petechiboleca, password=hidden non-blank value, auth=blank, email=null, registryAddress=index.docker.io, registryToken=blank}]
13:48:07.232 [main] DEBUG org.testcontainers.dockerclient.auth.AuthDelegatingDockerClientConfig - Effective auth config [AuthConfig{username=petechiboleca, password=hidden non-blank value, auth=blank, email=null, registryAddress=index.docker.io, registryToken=blank}]
13:48:07.243 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.command.CreateContainerCmdImpl#5c153b9e[name=<null>,hostName=<null>,domainName=<null>,user=<null>,attachStdin=<null>,attachStdout=<null>,attachStderr=<null>,portSpecs=<null>,tty=<null>,stdinOpen=<null>,stdInOnce=<null>,env={MYSQL_DATABASE=teste-integração-album-repositorio,MYSQL_PASSWORD=root,MYSQL_USER=root,MYSQL_ROOT_PASSWORD=root},cmd={},healthcheck=<null>,argsEscaped=<null>,entrypoint=<null>,image=mysql:8.0,volumes=com.github.dockerjava.api.model.Volumes#2a7686a7,workingDir=<null>,macAddress=<null>,onBuild=<null>,networkDisabled=<null>,exposedPorts=com.github.dockerjava.api.model.ExposedPorts#758a34ce,stopSignal=<null>,stopTimeout=<null>,hostConfig=com.github.dockerjava.api.model.HostConfig#7ec3394b[binds=com.github.dockerjava.api.model.Binds#bff34c6,blkioWeight=<null>,blkioWeightDevice=<null>,blkioDeviceReadBps=<null>,blkioDeviceWriteBps=<null>,blkioDeviceReadIOps=<null>,blkioDeviceWriteIOps=<null>,memorySwappiness=<null>,nanoCPUs=<null>,capAdd=<null>,capDrop=<null>,containerIDFile=<null>,cpuPeriod=<null>,cpuRealtimePeriod=<null>,cpuRealtimeRuntime=<null>,cpuShares=<null>,cpuQuota=<null>,cpusetCpus=<null>,cpusetMems=<null>,devices=<null>,deviceCgroupRules=<null>,diskQuota=<null>,dns=<null>,dnsOptions=<null>,dnsSearch=<null>,extraHosts={},groupAdd=<null>,ipcMode=<null>,cgroup=<null>,links=com.github.dockerjava.api.model.Links#1522d8a0,logConfig=<null>,lxcConf=<null>,memory=<null>,memorySwap=<null>,memoryReservation=<null>,kernelMemory=<null>,networkMode=<null>,oomKillDisable=<null>,init=<null>,autoRemove=<null>,oomScoreAdj=<null>,portBindings={},privileged=<null>,publishAllPorts=true,readonlyRootfs=<null>,restartPolicy=<null>,ulimits=<null>,cpuCount=<null>,cpuPercent=<null>,ioMaximumIOps=<null>,ioMaximumBandwidth=<null>,volumesFrom={},mounts=<null>,pidMode=<null>,isolation=<null>,securityOpts=<null>,storageOpt=<null>,cgroupParent=<null>,volumeDriver=<null>,shmSize=<null>,pidsLimit=<null>,runtime=<null>,tmpFs=<null>,utSMode=<null>,usernsMode=<null>,sysctls=<null>,consoleSize=<null>],labels={org.testcontainers=true, org.testcontainers.sessionId=c9db393d-d0ec-4740-848a-134abfe549c5},shell=<null>,networkingConfig=<null>,ipv4Address=<null>,ipv6Address=<null>,aliases=<null>,authConfig=AuthConfig[username=petechiboleca,password=tWindrifter12345,email=<null>,registryAddress=index.docker.io,auth=<null>,registrytoken=<null>,identitytoken=<null>,stackOrchestrator=<null>],execution=com.github.dockerjava.core.exec.CreateContainerCmdExec#5644dc81]
13:48:08.194 [main] DEBUG org.testcontainers.utility.MountableFile - Copying classpath resource(s) from jar:file:/C:/Users/Pete/.m2/repository/org/testcontainers/mysql/1.13.0/mysql-1.13.0.jar!/mysql-default-conf to C:\Users\Pete\AppData\Local\Temp\.testcontainers-tmp-5095191207689237918 to permit Docker to bind
13:48:08.194 [main] DEBUG org.testcontainers.utility.MountableFile - Copying resource mysql-default-conf from JAR file C:\Users\Pete\.m2\repository\org\testcontainers\mysql\1.13.0\mysql-1.13.0.jar
13:48:08.194 [main] DEBUG org.testcontainers.utility.MountableFile - Copying classpath resource(s) from jar:file:/C:/Users/Pete/.m2/repository/org/testcontainers/mysql/1.13.0/mysql-1.13.0.jar!/mysql-default-conf to C:\Users\Pete\AppData\Local\Temp\.testcontainers-tmp-5095191207689237918 to permit Docker to bind
13:48:08.195 [main] DEBUG org.testcontainers.utility.MountableFile - Copying resource mysql-default-conf from JAR file C:\Users\Pete\.m2\repository\org\testcontainers\mysql\1.13.0\mysql-1.13.0.jar
13:48:08.202 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec#57fd91c9
13:48:08.203 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient#2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:08.234 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: com.github.dockerjava.core.command.CopyArchiveToContainerCmdImpl#25e2a451[cp ,<null>, ,ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,:,/]
13:48:08.379 [main] INFO 🐳 [mysql:8.0] - Starting container with ID: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d
13:48:08.379 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,com.github.dockerjava.core.exec.StartContainerCmdExec#63b1d4fa
13:48:09.716 [main] INFO 🐳 [mysql:8.0] - Container mysql:8.0 is starting: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d
13:48:09.718 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec#75459c75
13:48:09.718 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient#2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:09.735 [ducttape-0] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec#410298f0
13:48:09.737 [ducttape-0] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient#2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:09.753 [main] INFO 🐳 [mysql:8.0] - Waiting for database connection to become available at jdbc:mysql://localhost:32851/teste-integração-album-repositorio using query 'SELECT 1'
13:48:09.753 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec#2a3c96e3
13:48:09.753 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient#2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:09.792 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec#a8e6492
13:48:09.792 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient#2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:09.799 [main] DEBUG 🐳 [mysql:8.0] - Trying to create JDBC connection using com.mysql.cj.jdbc.Driver to jdbc:mysql://localhost:32851/teste-integração-album-repositorio?useSSL=false&allowPublicKeyRetrieval=true with properties: {user=root, password=root}
13:48:10.233 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec#1e5f4170
13:48:10.233 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient#2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:10.240 [main] DEBUG 🐳 [mysql:8.0] - Trying to create JDBC connection using com.mysql.cj.jdbc.Driver to jdbc:mysql://localhost:32851/teste-integração-album-repositorio?useSSL=false&allowPublicKeyRetrieval=true with properties: {user=root, password=root}
13:48:09.799 [main] DEBUG 🐳 [mysql:8.0] - Trying to create JDBC connection using com.mysql.cj.jdbc.Driver to jdbc:mysql://localhost:32851/teste-integração-album-repositorio?useSSL=false&allowPublicKeyRetrieval=true with properties: {user=root, password=root}
13:48:10.233 [main] DEBUG com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d,false,com.github.dockerjava.core.exec.InspectContainerCmdExec#1e5f4170
13:48:10.233 [main] DEBUG com.github.dockerjava.core.exec.InspectContainerCmdExec - GET: OkHttpWebTarget(okHttpClient=org.testcontainers.shaded.okhttp3.OkHttpClient#2c7b5824, baseUrl=http://docker.socket/, path=[/containers/ce913f5a3ea48d499b6882d31da0c9c37bb004b8036e321f6420ef5d2bd5b73d/json], queryParams={})
13:48:10.240 [main] DEBUG 🐳 [mysql:8.0] - Trying to create JDBC connection using com.mysql.cj.jdbc.Driver to jdbc:mysql://localhost:32851/teste-integração-album-repositorio?useSSL=false&allowPublicKeyRetrieval=true with properties: {user=root, password=root}
MySQL Container Docker Dependency and MySQL Connector 8.0 Dependency (Spring Boot is managing my connector)
<groupId>org.testcontainers</groupId>
<artifactId>mysql</artifactId>
version>1.13.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
Note: When i use PostgreSQLContainer, The test passes succesfully
Note 2: When the loop breaks it Says *Communications link failure
You cannot create a user called "root" in mysql, since it already exists. Remove this part, and see if it helps:
.withUsername("root")

Apache HttpClient v5.0 doesn't authenticate with NTLM on Windows

I'm trying to make a request through a NTLM proxy like this:
try (CloseableHttpClient httpClient = WinHttpClients.createDefault()) {
HttpHost target = HttpHost.create("http://example.com");
HttpHost proxy = new HttpHost("http", "localhost", 80);
RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
HttpGet request = new HttpGet("/");
request.setConfig(config);
try (CloseableHttpResponse response = httpClient.execute(target, request)) {
StatusLine statusLine = new StatusLine(response);
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
System.out.println("Test OK");
} else if (statusLine.getStatusCode() == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
throw new CredentialException(statusLine.getReasonPhrase());
}
}
} catch (Exception e) {
e.printStackTrace();
}
but it fails, here is the log:
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ex-00000001: preparing request execution
[main] DEBUG org.apache.hc.client5.http.protocol.RequestAddCookies - Cookie spec selected: strict
[main] DEBUG org.apache.hc.client5.http.protocol.RequestAuthCache - Auth cache not set in the context
[main] DEBUG org.apache.hc.client5.http.impl.classic.ProtocolExec - ex-00000001: target auth state: UNCHALLENGED
[main] DEBUG org.apache.hc.client5.http.impl.classic.ProtocolExec - ex-00000001: proxy auth state: UNCHALLENGED
[main] DEBUG org.apache.hc.client5.http.impl.classic.ConnectExec - ex-00000001: acquiring connection with route {}->http://localhost:80->http://example.com:80
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ex-00000001: acquiring endpoint (3 MINUTES)
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ex-00000001: endpoint lease request (3 MINUTES) [route: {}->http://localhost:80->http://example.com:80][total available: 0; route allocated: 0 of 5; total allocated: 0 of 25]
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ex-00000001: endpoint leased [route: {}->http://localhost:80->http://example.com:80][total available: 0; route allocated: 1 of 5; total allocated: 1 of 25]
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ex-00000001: acquired ep-00000000
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ex-00000001: acquired endpoint ep-00000000
[main] DEBUG org.apache.hc.client5.http.impl.classic.ConnectExec - ex-00000001: opening connection {}->http://localhost:80->http://example.com:80
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-00000000: connecting endpoint (3 MINUTES)
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-00000000: connecting endpoint to http://localhost:80 (3 MINUTES)
[main] DEBUG org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator - http-outgoing-0: connecting to localhost/127.0.0.1:80
[main] DEBUG org.apache.hc.client5.http.impl.io.DefaultHttpClientConnectionOperator - http-outgoing-0: connection established 127.0.0.1:57194<->127.0.0.1:80
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-00000000: connected http-outgoing-0
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-00000000: endpoint connected
[main] DEBUG org.apache.hc.client5.http.impl.classic.MainClientExec - ex-00000001: executing GET http://example.com/ HTTP/1.1
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-00000000: start execution ex-00000001
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-00000000: executing exchange ex-00000001 over http-outgoing-0
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 >> GET http://example.com/ HTTP/1.1
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 >> Accept-Encoding: gzip, x-gzip, deflate
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 >> Host: example.com
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/5.0 (Java/1.8.0_222)
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 >> "GET http://example.com/ HTTP/1.1[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip, x-gzip, deflate[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 >> "Host: example.com[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/5.0 (Java/1.8.0_222)[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 >> "[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "HTTP/1.1 407 Proxy authorization required[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Proxy-Authenticate: NTLM[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Proxy-Authenticate: Basic realm="/", charset="UTF-8"[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Proxy-Support: session-based-authentication[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Cache-control: no-store, no-cache[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Content-Type: text/html; charset=utf-8[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Content-Length: 855[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Date: Sun, 05 Apr 2020 06:15:20 GMT[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Server: WinGate Engine[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "Connection: Keep-Alive[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><title>Proxy authorization required</title>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "<style>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "body { font-family:helvetica; font-size:11pt; color:#0071BB; margin:30px; padding:0px; }[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "h1 { color:#005395; margin:0px 0px 0px 0px; }[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "h2 { color:#005395; }[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "p { margin:6px 0px 6px 0px;}[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "p.footer { font-size:8pt; margin:3px 0px 0px 0px;}[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "b { font-weight:550; color:#7F7F7F; }[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "</style>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "</head>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "<body><h1>Proxy authorization required</h1>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "<div style="margin:12px 0px 12px 0px; padding:12px 0px 12px 0px; min-height:300px; border-top:1px solid #0071BB; border-bottom:1px solid #0071BB;">You must authenticate to gain access to this resource</div>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "<p class="footer">WinGate™ © Qbik New Zealand Limited 1995-2020[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.wire - http-outgoing-0 << "</p></body></html>[\r][\n]"
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << HTTP/1.1 407 Proxy authorization required
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Proxy-Authenticate: NTLM
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Proxy-Authenticate: Basic realm="/", charset="UTF-8"
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Proxy-Support: session-based-authentication
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Cache-control: no-store, no-cache
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Content-Type: text/html; charset=utf-8
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Content-Length: 855
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Date: Sun, 05 Apr 2020 06:15:20 GMT
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Server: WinGate Engine
[main] DEBUG org.apache.hc.client5.http.headers - http-outgoing-0 << Connection: Keep-Alive
[main] DEBUG org.apache.hc.client5.http.impl.classic.MainClientExec - ex-00000001: connection can be kept alive for 3 MINUTES
[main] DEBUG org.apache.hc.client5.http.impl.classic.ProtocolExec - Authentication required
[main] DEBUG org.apache.hc.client5.http.impl.classic.ProtocolExec - localhost:80 requested authentication
[main] DEBUG org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy - Authentication schemes in the order of preference: [Negotiate, Kerberos, NTLM, Digest, Basic]
[main] DEBUG org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy - Challenge for Negotiate authentication scheme not available
[main] DEBUG org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy - Challenge for Kerberos authentication scheme not available
[main] DEBUG org.apache.hc.client5.http.impl.win.WindowsNegotiateScheme - Created WindowsNegotiateScheme using NTLM
[main] DEBUG org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy - Challenge for Digest authentication scheme not available
[main] WARN org.apache.hc.client5.http.impl.classic.ProtocolExec - Missing auth challenge
[main] DEBUG org.apache.hc.client5.http.impl.io.DefaultManagedHttpClientConnection - http-outgoing-0: close connection GRACEFUL
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-00000000: endpoint closed
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-00000000: endpoint closed
[main] DEBUG org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-00000000: discarding endpoint
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-00000000: releasing endpoint
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-00000000: connection released [route: {}->http://localhost:80->http://example.com:80][total available: 0; route allocated: 0 of 5; total allocated: 0 of 25]
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - Shutdown connection pool GRACEFUL
[main] DEBUG org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - Connection pool shut down
javax.security.auth.login.CredentialException: Proxy authorization required
at org.kpax.http_client_5_testing.App.main(App.java:47)
Environment
OS: Windows 10
JRE: AdoptOpenJdk v11
Proxy type: NTLM (Wingate)
Question Is there something wrong with the above code?
Obs The same code works fine with Apache Http Client v4.5.12
It is a minor bug, solved now, for v5.0.1.

Cant download ethereum Events with web3j

When i try download Events from blockhain:
<!-- language: lang-js -->
Web3j web3 = Web3j.build(new HttpService("https://rinkeby.infura.io/naqTNN4B2QavbM4vZI3q"));
Credentials credentials =Credentials.create("94b5486c4657faf6d3834c2efd70d90a3cc746db101de32b997206e0ddb5234e");
TenderFactory factory = TenderFactory.load("0x16606f347cf1b36c08690b150b96dba2031d6729", web3, credentials, GAS_PRICE, GAS_LIMIT);
final Event event = new Event("NewContract",
Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
}),
Arrays.<TypeReference<?>>asList(new TypeReference<Utf8String>() {
}));
EthFilter filter = new EthFilter(DefaultBlockParameterName.EARLIEST,
DefaultBlockParameterName.EARLIEST, factory.getContractAddress());
filter.addSingleTopic(EventEncoder.encode(event));
Toolkit.getDefaultToolkit().beep();
web3.ethLogObservable(filter).subscribe(log -> {
LOG.info("log.getTopics=" + log.getTopics());
});
I got exeption:
17:43:05.719 [main] INFO r.s.tenderchain.Download - contractAddress = 0x16606f347cf1b36c08690b150b96dba2031d6729
17:43:07.097 [main] DEBUG org.web3j.protocol.http.HttpService - --> POST https://rinkeby.infura.io/naqTNN4B2QavbM4vZI3q http/1.1
17:43:07.098 [main] DEBUG org.web3j.protocol.http.HttpService - Content-Type: application/json; charset=utf-8
17:43:07.098 [main] DEBUG org.web3j.protocol.http.HttpService - Content-Length: 243
17:43:07.102 [main] DEBUG org.web3j.protocol.http.HttpService -
17:43:07.103 [main] DEBUG org.web3j.protocol.http.HttpService - {"jsonrpc":"2.0","method":"eth_newFilter","params":[{"topics":["0xa291e5980c03d23637198189ac50f67cecef9d808328c0420a23fa32fc16084a"],"fromBlock":"earliest","toBlock":"earliest","address":["0x16606f347cf1b36c08690b150b96dba2031d6729"]}],"id":0}
17:43:07.104 [main] DEBUG org.web3j.protocol.http.HttpService - --> END POST (243-byte body)
17:43:08.688 [main] DEBUG org.web3j.protocol.http.HttpService - <-- 405 Method Not Allowed https://rinkeby.infura.io/naqTNN4B2QavbM4vZI3q (1582ms)
17:43:08.689 [main] DEBUG org.web3j.protocol.http.HttpService - Date: Wed, 20 Dec 2017 14:43:08 GMT
17:43:08.694 [main] DEBUG org.web3j.protocol.http.HttpService - Content-Type: text/plain; charset=utf-8
17:43:08.694 [main] DEBUG org.web3j.protocol.http.HttpService - Content-Length: 0
17:43:08.694 [main] DEBUG org.web3j.protocol.http.HttpService - Connection: keep-alive
17:43:08.694 [main] DEBUG org.web3j.protocol.http.HttpService - Server: nginx/1.10.3 (Ubuntu)
17:43:08.695 [main] DEBUG org.web3j.protocol.http.HttpService - Vary: Origin
17:43:08.698 [main] DEBUG org.web3j.protocol.http.HttpService - <-- END HTTP (0-byte body)
Exception in thread "main" rx.exceptions.OnErrorNotImplementedException: Invalid response received: okhttp3.internal.http.RealResponseBody#437e951d
at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:386)
at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:383)
at rx.internal.util.ActionSubscriber.onError(ActionSubscriber.java:44)
at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:153)
at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:115)
at rx.Observable.subscribe(Observable.java:10249)
at rx.Observable.subscribe(Observable.java:10205)
at rx.Observable.subscribe(Observable.java:10010)
at ru.simplex_software.tenderchain.Download.main(Download.java:82)
Caused by: org.web3j.protocol.exceptions.ClientConnectionException: Invalid response received: okhttp3.internal.http.RealResponseBody#437e951d
at org.web3j.protocol.http.HttpService.performIO(HttpService.java:116)
at org.web3j.protocol.Service.send(Service.java:31)
at org.web3j.protocol.core.Request.send(Request.java:71)
at org.web3j.protocol.core.filters.LogFilter.sendRequest(LogFilter.java:31)
at org.web3j.protocol.core.filters.Filter.run(Filter.java:40)
....
org.web3j.protocol.rx.JsonRpc2_0Rx.lambda$ethLogObservable$10(JsonRpc2_0Rx.java:65)
at rx.Observable.subscribe(Observable.java:10238)
... 3 more
How to fix this and download NewContract events?
infura supports websocket endpoints on mainnet, ropsten and rinkeby now that allow you to listen to events. However, web3j doesn't support until now websockets so you can't use filters in web3 while connected to infura.

Quickbooks integration error number 401

I'm new to quickbooks technology, I want to make an integration between Quick books and (CRUD-SampleApp-Java) application, each time I run "CustomerCreate" class I get this error:
"Error while calling entity add:: message=AuthenticationFailed; errorCode=003200; statusCode=401"
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/kjaber/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/kjaber/.m2/repository/org/slf4j/slf4j-log4j12/1.7.21/slf4j-log4j12-1.7.21.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
0 [main] DEBUG org.apache.commons.configuration.ConfigurationUtils - ConfigurationUtils.locate(): base is null, name is intuit-config.xml
4 [main] DEBUG org.apache.commons.configuration.ConfigurationUtils - Loading configuration from the context classpath (intuit-config.xml)
34 [main] DEBUG org.apache.commons.configuration.ConfigurationUtils - ConfigurationUtils.locate(): base is null, name is intuit-default-config.xml
35 [main] DEBUG org.apache.commons.configuration.ConfigurationUtils - Loading configuration from the context classpath (intuit-default-config.xml)
63 [main] DEBUG com.intuit.logger - Enter PrepareRequestInterceptor...
149 [main] DEBUG com.intuit.logger - Exit PrepareRequestInterceptor.
149 [main] DEBUG com.intuit.logger - Enter SerializeInterceptor...
149 [main] INFO com.intuit.logger - serialization format : json
517 [main] DEBUG com.intuit.logger - Exit SerializeInterceptor.
517 [main] DEBUG com.intuit.logger - Enter CompressionInterceptor...
517 [main] INFO com.intuit.logger - compression format : gzip
519 [main] DEBUG com.intuit.logger - Exit CompressionInterceptor.
519 [main] DEBUG com.intuit.logger - Enter HTTPClientConnectionInterceptor...
856 [main] DEBUG com.intuit.logger - Request URI : https://sandbox-quickbooks.api.intuit.com/v3/company/193514552765139/customer?requestid=aa62bd10e21848f8a1ade7f666e59546&minorversion=12&
856 [main] DEBUG com.intuit.logger - Http Method : POST
856 [main] DEBUG com.intuit.logger - Request Body : {"DisplayName":"0hmQ77"}
868 [main] DEBUG org.apache.http.client.protocol.RequestAddCookies - CookieSpec selected: default
877 [main] DEBUG org.apache.http.client.protocol.RequestAuthCache - Auth cache not set in the context
878 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://sandbox-quickbooks.api.intuit.com:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
891 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {s}->https://sandbox-quickbooks.api.intuit.com:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
892 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {s}->https://sandbox-quickbooks.api.intuit.com:443
1133 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to sandbox-quickbooks.api.intuit.com/12.149.173.155:443
1133 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Connecting socket to sandbox-quickbooks.api.intuit.com/12.149.173.155:443 with timeout 0
1410 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]
1410 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
1410 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Starting handshake
2209 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - Secure session established
2209 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - negotiated protocol: TLSv1.2
2209 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - negotiated cipher suite: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256
2210 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - peer principal: CN=*.api.intuit.com, OU=CTO-DEV-ICS Ops, O=INTUIT INC., L=San Diego, ST=California, C=US
2210 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - peer alternative names: [api.intuit.com, *.api.intuit.com, api.intuit.net, *.api.intuit.net]
2211 [main] DEBUG org.apache.http.conn.ssl.SSLConnectionSocketFactory - issuer principal: CN=Symantec Class 3 Secure Server CA - G4, OU=Symantec Trust Network, O=Symantec Corporation, C=US
2217 [main] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connection established 172.16.1.19:60298<->12.149.173.155:443
2217 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-0: set socket timeout to 0
2217 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Executing request POST /v3/company/193514552765139/customer?requestid=aa62bd10e21848f8a1ade7f666e59546&minorversion=12& HTTP/1.1
2218 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> POST /v3/company/193514552765139/customer?requestid=aa62bd10e21848f8a1ade7f666e59546&minorversion=12& HTTP/1.1
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept: application/json
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Encoding: gzip
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> content-type: application/json
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Accept-Encoding: gzip
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: V3JavaSDK3.0.0
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Authorization: Bearer L011505900548zBbxMrQrmfBnApHFLwR8KslQ7zzVL2fgB0XaJ
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 44
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: sandbox-quickbooks.api.intuit.com
2221 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "POST /v3/company/193514552765139/customer?requestid=aa62bd10e21848f8a1ade7f666e59546&minorversion=12& HTTP/1.1[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept: application/json[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Encoding: gzip[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "content-type: application/json[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Accept-Encoding: gzip[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: V3JavaSDK3.0.0[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Authorization: Bearer L011505900548zBbxMrQrmfBnApHFLwR8KslQ7zzVL2fgB0XaJ[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Length: 44[\r][\n]"
2222 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: sandbox-quickbooks.api.intuit.com[\r][\n]"
2223 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
2223 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"
2223 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[0x1f][0x8b][0x8][0x0][0x0][0x0][0x0][0x0][0x0][0x0][0xab]Vr[0xc9],.[0xc8]I[0xac][0xf4]K[0xcc]MU[0xb2]R2[0xc8][0xc8][\r]47W[0xaa][0x5][0x0]&[0xe6][0xb0][0x18][0x0][0x0][0x0]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 401 Unauthorized[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Server: nginx[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Wed, 20 Sep 2017 09:37:07 GMT[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Type: text/xml[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Length: 388[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Connection: keep-alive[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Keep-Alive: timeout=5[\r][\n]"
2490 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "intuit_tid: 9856d20d-f8ce-d77c-024f-3cdcf258e401[\r][\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "WWW-Authenticate: Bearer realm="Intuit", error="invalid_token"[\r][\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "<?xml version="1.0" encoding="UTF-8" standalone="yes"?>[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "<IntuitResponse time="2017-09-20T02:37:07.562-07:00" xmlns="http://schema.intuit.com/finance/v3">[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << " <Fault type="AUTHENTICATION">[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << " <Error code="3200">[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << " <Message>message=AuthenticationFailed; errorCode=003200; statusCode=401</Message>[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << " <Detail></Detail>[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << " </Error>[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << " </Fault>[\n]"
2491 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "</IntuitResponse>[\n]"
2495 [main] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 401 Unauthorized
2495 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Server: nginx
2495 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Wed, 20 Sep 2017 09:37:07 GMT
2495 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: text/xml
2496 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Length: 388
2496 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Connection: keep-alive
2496 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Keep-Alive: timeout=5
2496 [main] DEBUG org.apache.http.headers - http-outgoing-0 << intuit_tid: 9856d20d-f8ce-d77c-024f-3cdcf258e401
2496 [main] DEBUG org.apache.http.headers - http-outgoing-0 << WWW-Authenticate: Bearer realm="Intuit", error="invalid_token"
2503 [main] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection can be kept alive for 5000 MILLISECONDS
2503 [main] DEBUG org.apache.http.impl.auth.HttpAuthenticator - Authentication required
2503 [main] DEBUG org.apache.http.impl.auth.HttpAuthenticator - sandbox-quickbooks.api.intuit.com:443 requested authentication
2503 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Authentication schemes in the order of preference: [Negotiate, Kerberos, NTLM, Digest, Basic]
2503 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for Negotiate authentication scheme not available
2503 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for Kerberos authentication scheme not available
2504 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for NTLM authentication scheme not available
2504 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for Digest authentication scheme not available
2504 [main] DEBUG org.apache.http.impl.client.TargetAuthenticationStrategy - Challenge for Basic authentication scheme not available
2508 [main] DEBUG com.intuit.logger - Connection status : HTTP/1.1 401 Unauthorized
2509 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection [id: 0][route: {s}->https://sandbox-quickbooks.api.intuit.com:443] can be kept alive for 5.0 seconds
2509 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {s}->https://sandbox-quickbooks.api.intuit.com:443][total kept alive: 1; route allocated: 1 of 2; total allocated: 1 of 20]
2509 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection manager is shutting down
2509 [main] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-0: Close connection
2510 [main] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection manager shut down
2511 [main] DEBUG com.intuit.logger - Exit HTTPClientConnectionInterceptor.
2511 [main] DEBUG com.intuit.logger - Enter DecompressInterceptor...
2511 [main] DEBUG com.intuit.logger - Decompressed Response Body : <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<IntuitResponse time="2017-09-20T02:37:07.562-07:00" xmlns="http://schema.intuit.com/finance/v3">
<Fault type="AUTHENTICATION">
<Error code="3200">
<Message>message=AuthenticationFailed; errorCode=003200; statusCode=401</Message>
<Detail></Detail>
</Error>
</Fault>
</IntuitResponse>
2511 [main] DEBUG com.intuit.logger - Exit DecompressInterceptor.
2511 [main] DEBUG com.intuit.logger - Enter DeserializeInterceptor...
2511 [main] INFO com.intuit.logger - HttpResponse content-type (deserialization format) : xml
2512 [main] DEBUG com.intuit.logger - HttpResponse content-type (deserialization format) : xml
3585 [main] DEBUG com.intuit.logger - Exit DeserializeInterceptor.
3585 [main] DEBUG com.intuit.logger - Enter HandleResponseInterceptor...
3586 [main] ERROR com.intuit.logger - Error while calling entity add:: message=AuthenticationFailed; errorCode=003200; statusCode=401
notice that I did the following configurations:
In intuit-config.xml>>
<?xml version="1.0" encoding="UTF-8"?>
<intuit-config>
<baseURL>
<qbo>https://sandbox-quickbooks.api.intuit.com/v3/company</qbo>
</baseURL>
</intuit-config>
In config.properties
I used https://developer.intuit.com/v2/ui#/playground to get this information from.
>
#For OAuth2 app set oauth.type=2
oauth.type=2
#OAuth2 access token
oauth2.accessToken =L011505900548zBbxMrQrmfBnApHFLwR8KslQ7zzVL2fgB0XaJ
#company id or realmId
company.id=193514552765139
#OAuth1 keys
app.token=
consumer.key=
consumer.secret=
oauth.accessToken=
oauth.accessTokenSecret=
Java build : 1.8.0_144
And i have added (ipp-v3-java-data,ipp-v3-java-devkit,oauth2-platform-api) to make the project build successfully

Categories

Resources