OpenJDK 8: can't resolve hostname - java-8

I'm trying to run slf4j with log4j 2.8 on openJDK 8 (latest version on Ubuntu 8u131-b11-0ubuntu1.17.04.1).
When running simple java class via maven openjdk is unable to resolve local hostname:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchFieldError: preferIPv6Address
at java.base/java.net.InetAddress.init(Native Method)
at java.base/java.net.InetAddress.init(Native Method)
at java.base/java.net.InetAddress.<clinit>(InetAddress.java:333)
at org.apache.logging.log4j.core.util.NetUtils.getLocalHostname(NetUtils.java:53)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:539)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:617)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:634)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:229)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:152)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:194)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:122)
at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:43)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
looks like the method
public static InetAddress getLocalHost() throws UnknownHostException
is implemented differently than in Oracle java.
/etc/hosts contains ipv6 record:
::1 ip6-localhost ip6-loopback

The problem was caused by JDK9 installed on the system. Log4j 2.8 is not compatible with Java 9 yet.
Either removing JDK9 or setting preference to JDK8 should solve the issue. On Debian:
sudo update-alternatives --config java

Related

Install Grails on Windows 10

I am trying to install Grails on Windows, which is an easy process. But, I got an error which I can't understand its reason? I configure java home and grails home properly. Any idea why grails isn't installed?
C:\Users\admin>java -version
java version "14" 2020-03-17
Java(TM) SE Runtime Environment (build 14+36-1461)
Java HotSpot(TM) 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)
C:\Users\admin>echo %grails_home%
C:\grails-4.0.0
C:\Users\admin>grails -version
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
at org.codehaus.groovy.vmplugin.VMPluginFactory.<clinit>(VMPluginFactory.java:43)
at org.codehaus.groovy.reflection.GroovyClassValueFactory.<clinit>(GroovyClassValueFactory.java:35)
at org.codehaus.groovy.reflection.ClassInfo.<clinit>(ClassInfo.java:107)
at org.codehaus.groovy.reflection.ReflectionCache.getCachedClass(ReflectionCache.java:95)
at org.codehaus.groovy.reflection.ReflectionCache.<clinit>(ReflectionCache.java:39)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:209)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:107)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:85)
at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:36)
at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:86)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.bitwiseNegate(ScriptBytecodeAdapter.java:842)
at org.grails.config.NavigableMap.<clinit>(NavigableMap.groovy)
at org.grails.cli.GrailsCli.<clinit>(GrailsCli.groovy:77)
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
at org.codehaus.groovy.runtime.dgmimpl.NumberNumberMetaMethod.<clinit>(NumberNumberMetaMethod.java:33)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:124)
at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:346)
at java.base/java.lang.Class.newInstance(Class.java:604)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.createMetaMethodFromClass(MetaClassRegistryImpl.java:257)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:110)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:85)
at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:36)
at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:86)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.bitwiseNegate(ScriptBytecodeAdapter.java:842)
at org.grails.config.NavigableMap.<clinit>(NavigableMap.groovy)
at org.grails.cli.GrailsCli.<clinit>(GrailsCli.groovy:77)
You're using JDK14 which is not supported by grails 4.0.x. Use a LTS such as Java 11. wait until grails updates to the latest
Spring-boot, which Grails is based on, added support for JDK 14 4 days ago (March 26th 2020). JDK 14 will likely be supported in Grails 4.1.x series.

Java 12 JMeter 5 HTTP/2 request java.lang.NoClassDefFoundError: org/eclipse/jetty/alpn/client/ALPNClientConnectionFactory

I am using Java 12, JMeter 5.1.1 on Ubuntu 9.0.4 and bumps into the following exception when trying to send HTTP/2 request:
Response code: Non HTTP response code: java.util.concurrent.ExecutionException
Response message: Non HTTP response message: java.lang.IllegalStateException: No Client ALPNProcessors!
And this stack trace in the response body:
java.util.concurrent.ExecutionException: java.lang.IllegalStateException: No Client ALPNProcessors!
at org.eclipse.jetty.util.FuturePromise.get(FuturePromise.java:138)
at com.blazemeter.jmeter.http2.sampler.HTTP2Connection.connect(HTTP2Connection.java:68)
at com.blazemeter.jmeter.http2.sampler.HTTP2Request.setConnection(HTTP2Request.java:278)
at com.blazemeter.jmeter.http2.sampler.HTTP2Request.sample(HTTP2Request.java:138)
at com.blazemeter.jmeter.http2.sampler.HTTP2Request.sample(HTTP2Request.java:115)
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253)
at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.lang.IllegalStateException: No Client ALPNProcessors!
at org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory.<init>(ALPNClientConnectionFactory.java:54)
at org.eclipse.jetty.http2.client.HTTP2Client.lambda$doStart$1(HTTP2Client.java:155)
at org.eclipse.jetty.http2.client.HTTP2Client$ClientSelectorManager.newConnection(HTTP2Client.java:438)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:222)
at org.eclipse.jetty.io.ManagedSelector.access$1500(ManagedSelector.java:60)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:825)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:754)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:672)
... 1 more
JMeter 5.1.1 comes with jetty-alpn-client-9.4.9.v20180320.jar by default.
I then download the jetty alpn java client library from http://central.maven.org/maven2/org/eclipse/jetty/jetty-alpn-java-client/ and put that into jmeter installed lib/ folder and results in this exception:
java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: org/eclipse/jetty/alpn/client/ALPNClientConnectionFactory
at org.eclipse.jetty.util.FuturePromise.get(FuturePromise.java:138)
at com.blazemeter.jmeter.http2.sampler.HTTP2Connection.connect(HTTP2Connection.java:68)
at com.blazemeter.jmeter.http2.sampler.HTTP2Request.setConnection(HTTP2Request.java:278)
at com.blazemeter.jmeter.http2.sampler.HTTP2Request.sample(HTTP2Request.java:138)
at com.blazemeter.jmeter.http2.sampler.HTTP2Request.sample(HTTP2Request.java:115)
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:622)
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:546)
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:486)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:253)
at java.base/java.lang.Thread.run(Thread.java:835)
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jetty/alpn/client/ALPNClientConnectionFactory
at org.eclipse.jetty.http2.client.HTTP2Client.lambda$doStart$1(HTTP2Client.java:155)
at org.eclipse.jetty.http2.client.HTTP2Client$ClientSelectorManager.newConnection(HTTP2Client.java:438)
at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:222)
at org.eclipse.jetty.io.ManagedSelector.access$1500(ManagedSelector.java:60)
at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:825)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:754)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:672)
... 1 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:436)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 8 more
I switched to Java 11 but get the same error.
Any advice and insight is appreciated.
No Client ALPNProcessors! is a message from the Jetty libraries that handle ALPN.
Because you are running in JDK 12 (and I don't think there is any big difference with JDK 11, so JDK 12 should be fine), you must have the jetty-alpn-java-client jar in the classpath, so that the Jetty libraries will find an implementation of the ALPNProcessor.Client class (via the ServiceLoader mechanism) that, as the error shows, cannot be found.
You don't detail how you are setting up TLS, etc. and I would have expected JMeter to have the jetty-alpn-java-client jar in the classpath already, but evidently there is something wrong in your setup (or in JMeter's).
I would double check how JMeter configures TLS; if it is using the standard JDK implementation, then it must have the jetty-alpn-java-client jar in the classpath.
If JMeter is using other TLS implementations (e.g. Conscrypt), then the Jetty project provides similar libraries (e.g. jetty-alpn-conscrypt-client jar) that similarly should be in the classpath.
JMeter 5 doesn't officially support Java 12
JMeter 5.0 officially requires Java 8 or 9, although later versions may be unofficially compatible. From our internal testing, JMeter will run on Java 11
Also in JMeter group announcement:
JMeter 5.0 is tested on Java 8 to 10, Java 11 should also work.
Notice also Java 12 isn't Long-Term-Support release
Java SE 11 however is an LTS release, and therefore Oracle Customers will receive Oracle Premier Support and periodic update releases, even though Java SE 12 was released
Solution: Download http://central.maven.org/maven2/org/eclipse/jetty/jetty-alpn-java-client/ and put in the installed jmeter lib/ folder. JMeter only comes installed with jetty-alpn-client which is not enough.

Problem installing WebLogic Server on Mac OS

When I run the java -jar command java -jar fmw_12.2.1.2.0_wls.jar in a WebLogic/ directory I created for the installation, I receive this error:
akh#akhs-MacBook-Pro ~/WebLogic: java -jar fmw_12.2.1.2.0_wls.jar
Exception in thread "main" java.util.ServiceConfigurationError: com.oracle.cie.common.dao.DataHandlerSpi: com.oracle.cie.common.dao.jaxb.JaxbDataHandlerSpiImpl Unable to get public no-arg constructor
at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:581)
at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:672)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1232)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1264)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1299)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1384)
at com.oracle.cie.common.dao.DataHandlerSpi.getDataHandlerProvider(DataHandlerSpi.java:81)
at com.oracle.cie.gdr.helpers.DaoHelper.getDataHandlerProvider(DaoHelper.java:123)
at com.oracle.cie.gdr.helpers.DaoHelper.parse(DaoHelper.java:170)
at com.oracle.cie.gdr.helpers.DaoHelper.getRootWrapper(DaoHelper.java:398)
at com.oracle.cie.nextgen.common.inputs.parser.OptionsParser.getOptionsInfoDao(OptionsParser.java:516)
at com.oracle.cie.nextgen.common.inputs.parser.OptionsParser.parseOptionsDao(OptionsParser.java:189)
at com.oracle.cie.nextgen.common.inputs.parser.OptionsParser.<init>(OptionsParser.java:136)
at com.oracle.cie.nextgen.common.inputs.parser.OptionsParser.getInstance(OptionsParser.java:123)
at com.oracle.cie.nextgen.common.inputs.impl.OUIOptions.<init>(OUIOptions.java:58)
at com.oracle.cie.nextgen.common.inputs.impl.InputsImpl.<init>(InputsImpl.java:53)
at com.oracle.cie.nextgen.common.inputs.impl.InputsImpl.<clinit>(InputsImpl.java:37)
at com.oracle.cie.nextgen.common.inputs.helpers.InputHandler.getInputs(InputHandler.java:41)
at com.oracle.cie.nextgen.launcher.Launcher.processCommandLineArgs(Launcher.java:3135)
at com.oracle.cie.nextgen.launcher.Launcher.execute(Launcher.java:3840)
at com.oracle.cie.nextgen.launcher.Launcher.main(Launcher.java:3801)
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3138)
at java.base/java.lang.Class.getConstructor0(Class.java:3343)
at java.base/java.lang.Class.getConstructor(Class.java:2152)
at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:659)
at java.base/java.util.ServiceLoader$1.run(ServiceLoader.java:656)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.util.ServiceLoader.getConstructor(ServiceLoader.java:667)
... 19 more
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 27 more
I have set up my JAVA_HOME in .bash_profile. Echo for $JAVA_HOME is: "/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home". I have tested and run "java --version" and I get
openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
I am running on macOS Mojave version 10.14.5, my JDK is 8 at path /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java.
I don't know why the Java is breaking and the installer is not running.
first you must install correct jdk, not openjdk.

SonarQube 6.7.1 WEB not work with JDBC 42.1.4 [default]

OS: Uduntu 16.04 64-bit LTS
SonarQube: 6.7.1
PostgreSql: 9.5
Java: 1.8.0_144
Default SonarQube has JDBC 42.1.4 and the following error in web.log:
ERROR web[][o.postgresql.Driver] Connection error:
org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:275)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:194)
at org.postgresql.Driver.makeConnection(Driver.java:450)
at org.postgresql.Driver.connect(Driver.java:252)
at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
at org.apache.commons.pool.impl.GenericObjectPool.addObject(GenericObjectPool.java:1617)
at org.apache.commons.pool.impl.GenericObjectPool.ensureMinIdle(GenericObjectPool.java:1575)
at org.apache.commons.pool.impl.GenericObjectPool.access$700(GenericObjectPool.java:190)
at org.apache.commons.pool.impl.GenericObjectPool$Evictor.run(GenericObjectPool.java:1709)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: java.net.UnknownHostException: localhost
but when i update to JDBC 4.2 Driver, 42.2.1 work well.
Maybe someone from sonarqube see and fix it.
Indeed the version of PostgreSQL driver packaged in SonarQube 6.7.1 has some bugs. Driver is upgraded in SonarQube 6.7.2, not released at the time of writing.
See a related ticket: https://jira.sonarsource.com/browse/SONAR-10296

Gradle throws: Unable to establish loopback connection

Gradle throws exception with message "Unable to establish loopback connection". The following is the stack trace thrown at the console.
java.io.IOException: Unable to establish loopback connection
org.gradle.internal.UncheckedException: java.io.IOException: Unable to establish loopback connection
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:39)
at org.gradle.messaging.remote.internal.inet.SocketConnection.<init>(SocketConnection.java:58)
at org.gradle.messaging.remote.internal.inet.SocketConnectCompletion.create(SocketConnectCompletion.java:43)
at org.gradle.messaging.remote.internal.hub.MessageHubBackedObjectConnection.connect(MessageHubBackedObjectConnection.java:92)
at org.gradle.api.internal.tasks.testing.worker.ForkingTestClassProcessor.forkProcess(ForkingTestClassProcessor.java:78)
at org.gradle.api.internal.tasks.testing.worker.ForkingTestClassProcessor.processTestClass(ForkingTestClassProcessor.java:56)
at org.gradle.api.internal.tasks.testing.processors.RestartEveryNTestClassProcessor.processTestClass(RestartEveryNTestClassProcessor.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.dispatch.FailureHandlingDispatch.dispatch(FailureHandlingDispatch.java:29)
at org.gradle.messaging.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:132)
at org.gradle.messaging.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33)
at org.gradle.messaging.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:72)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Gradle version :
Gradle 1.12
Build time: 2014-04-29 09:24:31 UTC
Build number: none
Revision: a831fa866d46cbee94e61a09af15f9dd95987421
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy: 2.2.0
JVM: 1.7.0_45 (Oracle Corporation 24.45-b08)
OS: Windows 7 6.1 x86
Jdk is 1.7.45.
Is there any help? I tried stopping the anti virus assuming the connection are getting terminated by AV. However, the issue re-occurred when the AV was turned off.
I assume this is a problem where Gradle cannot connect to the gradle Daemon. Your machine probably has an issue with its networking config, which needs to be worked out.
A possible workaround would be to run without the Daemon, using the --no-daemon option. If that still doesn't work, there is some other reason why it tries to establish a connection, probably due to a custom plugin or build script.
I was using JDK v1.7.0_45 and I now use 1.7.0_79. Ever since the upgrade I am not observing this issue. I switched back to v1.7.0_45 this morning and I am already noticed "Unable to establish loopback connection" twice out of six iterations.

Resources