Tuesday, October 30, 2018

Netty NoClassDefFoundError JdkAlpnApplicationProtocolNegotiator

PROBLEM:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class io.netty.handler.ssl.JdkAlpnApplicationProtocolNegotiator
 at io.netty.handler.ssl.JdkSslContext.toNegotiator(JdkSslContext.java:285)
 at io.netty.handler.ssl.JdkSslClientContext.(JdkSslClientContext.java:261)
 at io.netty.handler.ssl.SslContext.newClientContextInternal(SslContext.java:751)
 at io.netty.handler.ssl.SslContextBuilder.build(SslContextBuilder.java:418)
 at com.relayrides.pushy.apns.ApnsClientBuilder.build(ApnsClientBuilder.java:408)

c.r.p.a.ApnsClientBuilder Native SSL provider not available; will use JDK SSL provider.

OpenSSL available? false
ALPN supported?    false
Reason for unavailability:
java.lang.IllegalArgumentException: Failed to load any of the given libraries: [netty-tcnative-linux-x86_32, netty-tcnative-linux-x86_32-fedora, netty-tcnative]
        at io.netty.util.internal.NativeLibraryLoader.loadFirstAvailable(NativeLibraryLoader.java:178)
        at io.netty.handler.ssl.OpenSsl.loadTcNative(OpenSsl.java:384)
        at io.netty.handler.ssl.OpenSsl.(OpenSsl.java:84)
        at OpenSslZav.main(OpenSslZav.java:7)


JDK vs OPENSSL
new JdkSslClientContext
new OpenSslClientContext

netty-tcnative-boringssl-static-2.0.0.Final.jar

netty-tcnative-boringssl-static-2.0.0.Final.jar\META-INF\native\
libnetty-tcnative-linux-x86_64.so
libnetty-tcnative-osx-x86_64.jnilib
netty-tcnative-windows-x86_64.dll

SOLUTION:
Update Java to arch 64
ONLY WORKS IN JAVA 64 !!!


Monday, October 29, 2018

Wednesday, October 24, 2018

YourKit on remote server

https://www.yourkit.com/docs/java/help/profiling_j2ee_remote.jsp



export PROFILER="-agentpath:/opt/yjp/bin/linux-x86-64/libyjpagent.so=disablestacktelemetry,disableexceptiontelemetry,delay=10000,listen=all"

export JAVA_OPTS="-Xmx3G -Xms3G -Xmn1G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/xxx/log/xxx-oom.hpref $GC_OPTS $PROFILER $JMX_OPTS"

Wednesday, October 17, 2018

Docker: Error response from daemon, Exception caught, Bad Request - FOR PROXY USERS


PROBLEM:
C:\Users\alexeyz> docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: Bad Request.
See 'docker run --help'.
-OR-
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.10:build (myproject.all) on project com.myproject.docker: Exception caught: Get https://registry-1.docker.io/v2/: Bad Request

SOLUTION:
1. Switch off proxy in Docker
2. Find non-proxy internet.


Friday, October 12, 2018

Mongo notes

use admin
db.runCommand( {buildInfo: 1} )
db.adminCommand({setParameter: 1, internalQueryExecMaxBlockingSortBytes:67108864})

Friday, October 5, 2018

Mask credit card number in java


String result;
if (string.length() > 4) {
result = string.replaceAll("(?<=.{4})(\\w)", "*");
} else {
result = string.replaceAll("(\\w)", "*");
}