Tag Archives: java

Error:Abnormal build process termination [How to Solve]

Pre:

Today I close the Firewall and java program failed to start error:

Error:Abnormal build process termination:
“C:\Program Files\Java\jdk1.8.0_152\bin\java.exe” -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs=“” -Djdt.compiler.useSingleThread=true -Dpreload.project.path=D:/tangyuzhongshowtime/springboot-mybatis-token-freemarker -Dpreload.config.path=C:/Users/Administrator/AppData/Roaming/JetBrains/IntelliJIdea2020.1/options -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Dio.netty.initialSeedUniquifier=1508232679689852792 -Dfile.encoding=GBK -Duser.language=zh -Duser.country=CN -Didea.paths.selector=IntelliJIdea2020.1 “-Didea.home.path=D:\Idea\IntelliJ IDEA 2020.1.2” -Didea.config.path=C:\Users\Administrator\AppData\Roaming\JetBrains\IntelliJIdea2020.1 -Didea.plugins.path=C:\Users\Administrator\AppData\Roaming\JetBrains\IntelliJIdea2020.1\plugins -Djps.log.dir=C:/Users/Administrator/AppData/Local/JetBrains/IntelliJIdea2020.1/log/build-log “-Djps.fallback.jdk.home=D:/Idea/IntelliJ IDEA 2020.1.2/jbr” -Djps.fallback.jdk.version=11.0.7 -Dio.netty.noUnsafe=true -Djava.io.tmpdir=C:/Users/Administrator/AppData/Local/JetBrains/IntelliJIdea2020.1/compile-server/springboot-mybatis-token-freemarker_830f3c4b/temp -Djps.backward.ref.index.builder=true -Dkotlin.incremental.compilation=true -Dkotlin.incremental.compilation.js=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=“C:\Users\ADMINI~1\AppData\Local\Temp\kotlin-idea-1545321366046478132-is-running” -classpath “D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/jps-launcher.jar;C:/Program Files/Java/jdk1.8.0_152/lib/tools.jar” org.jetbrains.jps.cmdline.Launcher “D:/Idea/IntelliJ IDEA 2020.1.2/lib/commons-lang3-3.9.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-resolver-impl-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/gson-2.8.6.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/trove4j.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/commons-logging-1.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/maven-resolver-connector-basic-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/asm-all-7.0.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/netty-transport-4.1.47.Final.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-resolver-api-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/plexus-interpolation-1.25.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-repository-metadata-3.6.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/slf4j-api-1.7.25.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/nanoxml-2.2.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-resolver-provider-3.6.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-model-builder-3.6.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/platform-api.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/forms-1.1-preview.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/netty-buffer-4.1.47.Final.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/oro-2.0.8.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/resources_en.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/plexus-utils-3.2.0.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/maven-resolver-transport-file-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/util.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/qdox-2.0-M10.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/lz4-java-1.7.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/plexus-component-annotations-1.7.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-builder-support-3.6.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/javac2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/log4j.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-model-3.6.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/jna-platform.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/jps-builders.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/netty-common-4.1.47.Final.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/guava-28.2-jre.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/netty-codec-4.1.47.Final.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/aether-dependency-resolver.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/idea_rt.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-artifact-3.6.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-resolver-util-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/maven-resolver-spi-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/jps-builders-6.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/netty-resolver-4.1.47.Final.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/jdom.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/httpcore-4.4.13.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/annotations.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/protobuf-java-3.5.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/maven-resolver-transport-http-1.3.3.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/jna.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/jps-model.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/httpclient-4.5.12.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/JavaEE/lib/jasper-v2-rt.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/gson-2.8.6.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/jarutils.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/guava-28.2-jre.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/common-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/gradle/lib/gradle-api-6.1.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/gson-2.8.6.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/jarutils.jar;D:/Idea/IntelliJ IDEA 2020.1.2/lib/guava-28.2-jre.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/common-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/gradle/lib/gradle-api-6.1.1.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/IntelliLang/lib/intellilang-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/eclipse/lib/eclipse-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/eclipse/lib/common-eclipse-util.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/ant/lib/ant-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Groovy/lib/groovy-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Groovy/lib/groovy-rt-constants.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/maven/lib/maven-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/osmorc/lib/osmorc-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/osmorc/lib/biz.aQute.bndlib-5.0.0.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/osmorc/lib/biz.aQute.repository-5.0.0.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/osmorc/lib/biz.aQute.resolve-5.0.0.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/osmorc/lib/bundlor-all.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/aspectj/lib/aspectj-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/gradle-java/lib/gradle-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/javaFX/lib/javaFX-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/javaFX/lib/common-javaFX-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/uiDesigner/lib/jps/ui-designer-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/devkit/lib/devkit-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/flex/lib/flex-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/flex/lib/flex-shared.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/JavaEE/lib/javaee-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/JavaEE/lib/jps/jpa-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Kotlin/lib/jps/kotlin-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Kotlin/lib/kotlin-stdlib.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Kotlin/lib/kotlin-reflect.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Kotlin/lib/kotlin-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/jps/android-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/android-common.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/build-common.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/android-rt.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/android-extensions-ide.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/sdk-common-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/common-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/repository-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/sdklib-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/jarutils.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/layoutlib-api-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/android/lib/manifest-merger-26.6.0.2.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/webSphereIntegration/lib/jps/webSphere-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/weblogicIntegration/lib/jps/weblogic-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/dmServer/lib/dmServer-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/GwtStudio/lib/gwt-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Grails/lib/grails-jps-plugin.jar;D:/Idea/IntelliJ IDEA 2020.1.2/plugins/Grails/lib/grails-compiler-patch.jar” org.jetbrains.jps.cmdline.BuildMain 127.0.0.1 49464 1fa79df5-132b-4c83-a797-a493feea0e28 C:/Users/Administrator/AppData/Local/JetBrains/IntelliJIdea2020.1/compile-server
Build process started. Classpath: D:/Idea/IntelliJ IDEA 2020.1.2/plugins/java/lib/jps-launcher.jar;C:/Program Files/Java/jdk1.8.0_152/lib/tools.jarSLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementationSLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Error connecting to 127.0.0.1:49464; reason: Connection timed out: no further information: /127.0.0.1:49464
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection timed out: no further information: /127.0.0.1:49464
Caused by: java.net.ConnectException: Connection timed out: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:330)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:702)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
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 java.lang.Thread.run(Thread.java:748)
Exiting.

Solution:

Close the WIndows Firewall

If this method above does not work. try:

re-add the jdk of sdk in project structure.

[Solved] Error: A JNI error has occurred, please check your installation and try again Exception in thread

Problem description

When running code. The following error is reported:

"D:\Program Files\Java\jdk1.8.0_301\bin\java.exe" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:54797,suspend=y,server=n -javaagent:C:\Users\Administrator\AppData\Local\JetBrains\IntelliJIdea2020.3\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8 -classpath "D:\program files\Java\jdk1.8.0_301\jre\lib\charsets.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\deploy.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\ext\access-bridge-64.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\ext\cldrdata.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\ext\dnsns.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\ext\jaccess.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\ext\jfxrt.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\ext\localedata.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\ext\nashorn.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\ext\sunec.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\ext\sunjce_provider.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\ext\sunmscapi.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\ext\sunpkcs11.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\ext\zipfs.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\javaws.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\jce.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\jfr.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\jfxswt.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\jsse.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\management-agent.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\plugin.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\resources.jar;D:\program files\Java\jdk1.8.0_301\jre\lib\rt.jar;E:\JetBrains\spring学习\spring-study\spring-study-01-ioc1\target\test-classes;E:\JetBrains\spring学习\spring-study\spring-study-01-ioc1\target\classes;D:\java\maven-3.8.1-bin\apache-maven-3.8.1\maven_repository\org\springframework\spring-webmvc\5.3.10\spring-webmvc-5.3.10.jar;D:\java\maven-3.8.1-bin\apache-maven-3.8.1\maven_repository\org\springframework\spring-aop\5.3.10\spring-aop-5.3.10.jar;D:\java\maven-3.8.1-bin\apache-maven-3.8.1\maven_repository\org\springframework\spring-beans\5.3.10\spring-beans-5.3.10.jar;D:\java\maven-3.8.1-bin\apache-maven-3.8.1\maven_repository\org\springframework\spring-context\5.3.10\spring-context-5.3.10.jar;D:\java\maven-3.8.1-bin\apache-maven-3.8.1\maven_repository\org\springframework\spring-core\5.3.10\spring-core-5.3.10.jar;D:\java\maven-3.8.1-bin\apache-maven-3.8.1\maven_repository\org\springframework\spring-jcl\5.3.10\spring-jcl-5.3.10.jar;D:\java\maven-3.8.1-bin\apache-maven-3.8.1\maven_repository\org\springframework\spring-expression\5.3.10\spring-expression-5.3.10.jar;D:\java\maven-3.8.1-bin\apache-maven-3.8.1\maven_repository\org\springframework\spring-web\5.3.10\spring-web-5.3.10.jar;D:\java\maven-3.8.1-bin\apache-maven-3.8.1\maven_repository\junit\junit\4.13\junit-4.13.jar;D:\java\maven-3.8.1-bin\apache-maven-3.8.1\maven_repository\org\hamcrest\hamcrest-core\1.3\hamcrest-core-1.3.jar;D:\program files\JetBrains\IntelliJ IDEA 2020.3.4\lib\idea_rt.jar" java.MyTest01
Connected to the target VM, address: '127.0.0.1:54797', transport: 'socket'
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.SecurityException: Prohibited package name: java
	at java.lang.ClassLoader.preDefineClass(ClassLoader.java:655)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:754)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
Disconnected from the target VM, address: '127.0.0.1:54797', transport: 'socket'

Process finished with exit code 1


Cause analysis:

Through the analysis of the error, I learned that I wrote that the use of java package’s name is prohibited in Java


Solution:

Delete and modify the name of java package to other

Mac: How to Solve ERROR launching ‘JD-GUI‘

Solution: the app displays the contents of the package, and find universalJavaApplicationStub.sh, then copy the following content and overwrite it

#!/bin/bash
##################################################################################
#                                                                                #
# universalJavaApplicationStub                                                   #
#                                                                                #
# A BASH based JavaApplicationStub for Java Apps on Mac OS X                     #
# that works with both Apple's and Oracle's plist format.                        #
#                                                                                #
# Inspired by Ian Roberts stackoverflow answer                                   #
# at http://stackoverflow.com/a/17546508/1128689                                 #
#                                                                                #
# @author    Tobias Fischer                                                      #
# @url       https://github.com/tofi86/universalJavaApplicationStub              #
# @date      2020-03-19                                                          #
# @version   3.0.6                                                               #
#                                                                                #
##################################################################################
#                                                                                #
# The MIT License (MIT)                                                          #
#                                                                                #
# Copyright (c) 2014-2020 Tobias Fischer                                         #
#                                                                                #
# Permission is hereby granted, free of charge, to any person obtaining a copy   #
# of this software and associated documentation files (the "Software"), to deal  #
# in the Software without restriction, including without limitation the rights   #
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell      #
# copies of the Software, and to permit persons to whom the Software is          #
# furnished to do so, subject to the following conditions:                       #
#                                                                                #
# The above copyright notice and this permission notice shall be included in all #
# copies or substantial portions of the Software.                                #
#                                                                                #
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR     #
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,       #
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE    #
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER         #
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,  #
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE  #
# SOFTWARE.                                                                      #
#                                                                                #
##################################################################################
 
 
 
# function 'stub_logger()'
#
# A logger which logs to the macOS Console.app using the 'syslog' command
#
# @param1  the log message
# @return  void
################################################################################
function stub_logger() {
	syslog -s -k \
		Facility com.apple.console \
		Level Notice \
		Sender "$(basename "$0")" \
		Message "[$$][${CFBundleName:-$(basename "$0")}] $1"
}
 
 
 
# set the directory abspath of the current
# shell script with symlinks being resolved
############################################
 
PRG=$0
while [ -h "$PRG" ]; do
	ls=$(ls -ld "$PRG")
	link=$(expr "$ls" : '^.*-> \(.*\)$' 2>/dev/null)
	if expr "$link" : '^/' 2> /dev/null >/dev/null; then
		PRG="$link"
	else
		PRG="$(dirname "$PRG")/$link"
	fi
done
PROGDIR=$(dirname "$PRG")
stub_logger "[StubDir] $PROGDIR"
 
 
 
# set files and folders
############################################
 
# the absolute path of the app package
cd "$PROGDIR"/../../ || exit 11
AppPackageFolder=$(pwd)
 
# the base path of the app package
cd .. || exit 12
AppPackageRoot=$(pwd)
 
# set Apple's Java folder
AppleJavaFolder="${AppPackageFolder}"/Contents/Resources/Java
 
# set Apple's Resources folder
AppleResourcesFolder="${AppPackageFolder}"/Contents/Resources
 
# set Oracle's Java folder
OracleJavaFolder="${AppPackageFolder}"/Contents/Java
 
# set Oracle's Resources folder
OracleResourcesFolder="${AppPackageFolder}"/Contents/Resources
 
# set path to Info.plist in bundle
InfoPlistFile="${AppPackageFolder}"/Contents/Info.plist
 
# set the default JVM Version to a null string
JVMVersion=""
JVMMaxVersion=""
 
 
 
# function 'plist_get()'
#
# read a specific Plist key with 'PlistBuddy' utility
#
# @param1  the Plist key with leading colon ':'
# @return  the value as String or Array
################################################################################
plist_get(){
	/usr/libexec/PlistBuddy -c "print $1" "${InfoPlistFile}" 2> /dev/null
}
 
# function 'plist_get_java()'
#
# read a specific Plist key with 'PlistBuddy' utility
# in the 'Java' or 'JavaX' dictionary (<dict>)
#
# @param1  the Plist :Java(X):Key with leading colon ':'
# @return  the value as String or Array
################################################################################
plist_get_java(){
	plist_get ${JavaKey:-":Java"}$1
}
 
 
 
# read Info.plist and extract JVM options
############################################
 
# read the program name from CFBundleName
CFBundleName=$(plist_get ':CFBundleName')
 
# read the icon file name
CFBundleIconFile=$(plist_get ':CFBundleIconFile')
 
 
# check Info.plist for Apple style Java keys -> if key :Java is present, parse in apple mode
/usr/libexec/PlistBuddy -c "print :Java" "${InfoPlistFile}" > /dev/null 2>&1
exitcode=$?
JavaKey=":Java"
 
# if no :Java key is present, check Info.plist for universalJavaApplication style JavaX keys -> if key :JavaX is present, parse in apple mode
if [ $exitcode -ne 0 ]; then
	/usr/libexec/PlistBuddy -c "print :JavaX" "${InfoPlistFile}" > /dev/null 2>&1
	exitcode=$?
	JavaKey=":JavaX"
fi
 
 
# read 'Info.plist' file in Apple style if exit code returns 0 (true, ':Java' key is present)
if [ $exitcode -eq 0 ]; then
	stub_logger "[PlistStyle] Apple"
 
	# set Java and Resources folder
	JavaFolder="${AppleJavaFolder}"
	ResourcesFolder="${AppleResourcesFolder}"
 
	APP_PACKAGE="${AppPackageFolder}"
	JAVAROOT="${AppleJavaFolder}"
	USER_HOME="$HOME"
 
 
	# read the Java WorkingDirectory
	JVMWorkDir=$(plist_get_java ':WorkingDirectory' | xargs)
	# set Working Directory based upon PList value
	if [[ ! -z ${JVMWorkDir} ]]; then
		WorkingDirectory="${JVMWorkDir}"
	else
		# AppPackageRoot is the standard WorkingDirectory when the script is started
		WorkingDirectory="${AppPackageRoot}"
	fi
	# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOME
	WorkingDirectory=$(eval echo "${WorkingDirectory}")
 
 
	# read the MainClass name
	JVMMainClass="$(plist_get_java ':MainClass')"
 
	# read the SplashFile name
	JVMSplashFile=$(plist_get_java ':SplashFile')
 
	# read the JVM Properties as an array and retain spaces
	IFS=$'\t\n'
	JVMOptions=($(xargs -n1 <<<$(plist_get_java ':Properties' | grep " =" | sed 's/^ */-D/g' | sed -E 's/ = (.*)$/="\1"/g')))
	unset IFS
	# post processing of the array follows further below...
 
	# read the ClassPath in either Array or String style
	JVMClassPath_RAW=$(plist_get_java ':ClassPath' | xargs)
	if [[ $JVMClassPath_RAW == *Array* ]] ; then
		JVMClassPath=.$(plist_get_java ':ClassPath' | grep "    " | sed 's/^ */:/g' | tr -d '\n' | xargs)
	else
		JVMClassPath=${JVMClassPath_RAW}
	fi
	# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOME
	JVMClassPath=$(eval echo "${JVMClassPath}")
 
	# read the JVM Options in either Array or String style
	JVMDefaultOptions_RAW=$(plist_get_java ':VMOptions' | xargs)
	if [[ $JVMDefaultOptions_RAW == *Array* ]] ; then
		JVMDefaultOptions=$(plist_get_java ':VMOptions' | grep "    " | sed 's/^ */ /g' | tr -d '\n' | xargs)
	else
		JVMDefaultOptions=${JVMDefaultOptions_RAW}
	fi
 
	# read StartOnMainThread and add as -XstartOnFirstThread
	JVMStartOnMainThread=$(plist_get_java ':StartOnMainThread')
	if [ "${JVMStartOnMainThread}" == "true" ]; then
		JVMDefaultOptions+=" -XstartOnFirstThread"
	fi
 
	# read the JVM Arguments in either Array or String style (#76) and retain spaces
	IFS=$'\t\n'
	MainArgs_RAW=$(plist_get_java ':Arguments' | xargs)
	if [[ $MainArgs_RAW == *Array* ]] ; then
		MainArgs=($(xargs -n1 <<<$(plist_get_java ':Arguments' | tr -d '\n' | sed -E 's/Array \{ *(.*) *\}/\1/g' | sed 's/  */ /g')))
	else
		MainArgs=($(xargs -n1 <<<$(plist_get_java ':Arguments')))
	fi
	unset IFS
	# post processing of the array follows further below...
 
	# read the Java version we want to find
	JVMVersion=$(plist_get_java ':JVMVersion' | xargs)
	# post processing of the version string follows below...
 
 
# read 'Info.plist' file in Oracle style
else
	stub_logger "[PlistStyle] Oracle"
 
	# set Working Directory and Java and Resources folder
	JavaFolder="${OracleJavaFolder}"
	ResourcesFolder="${OracleResourcesFolder}"
	WorkingDirectory="${OracleJavaFolder}"
 
	APP_ROOT="${AppPackageFolder}"
 
	# read the MainClass name
	JVMMainClass="$(plist_get ':JVMMainClassName')"
 
	# read the SplashFile name
	JVMSplashFile=$(plist_get ':JVMSplashFile')
 
	# read the JVM Options as an array and retain spaces
	IFS=$'\t\n'
	JVMOptions=($(plist_get ':JVMOptions' | grep "    " | sed 's/^ *//g'))
	unset IFS
	# post processing of the array follows further below...
 
	# read the ClassPath in either Array or String style
	JVMClassPath_RAW=$(plist_get ':JVMClassPath')
	if [[ $JVMClassPath_RAW == *Array* ]] ; then
		JVMClassPath=.$(plist_get ':JVMClassPath' | grep "    " | sed 's/^ */:/g' | tr -d '\n' | xargs)
		# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOME
		JVMClassPath=$(eval echo "${JVMClassPath}")
 
	elif [[ ! -z ${JVMClassPath_RAW} ]] ; then
		JVMClassPath=${JVMClassPath_RAW}
		# expand variables $APP_PACKAGE, $JAVAROOT, $USER_HOME
		JVMClassPath=$(eval echo "${JVMClassPath}")
 
	else
		#default: fallback to OracleJavaFolder
		JVMClassPath="${JavaFolder}/*"
		# Do NOT expand the default 'AppName.app/Contents/Java/*' classpath (#42)
	fi
 
	# read the JVM Default Options
	JVMDefaultOptions=$(plist_get ':JVMDefaultOptions' | grep -o " \-.*" | tr -d '\n' | xargs)
 
	# read the Main Arguments from JVMArguments key as an array and retain spaces (see #46 for naming details)
	IFS=$'\t\n'
	MainArgs=($(xargs -n1 <<<$(plist_get ':JVMArguments' | tr -d '\n' | sed -E 's/Array \{ *(.*) *\}/\1/g' | sed 's/  */ /g')))
	unset IFS
	# post processing of the array follows further below...
 
	# read the Java version we want to find
	JVMVersion=$(plist_get ':JVMVersion' | xargs)
	# post processing of the version string follows below...
fi
 
 
# (#75) check for undefined icons or icon names without .icns extension and prepare
# an osascript statement for those cases when the icon can be shown in the dialog
DialogWithIcon=""
if [ ! -z ${CFBundleIconFile} ]; then
	if [[ ${CFBundleIconFile} == *.icns ]] && [[ -f "${ResourcesFolder}/${CFBundleIconFile}" ]] ; then
		DialogWithIcon=" with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
	elif [[ ${CFBundleIconFile} != *.icns ]] && [[ -f "${ResourcesFolder}/${CFBundleIconFile}.icns" ]] ; then
		CFBundleIconFile+=".icns"
		DialogWithIcon=" with icon path to resource \"${CFBundleIconFile}\" in bundle (path to me)"
	fi
fi
 
 
# JVMVersion: post processing and optional splitting
if [[ ${JVMVersion} == *";"* ]]; then
	minMaxArray=(${JVMVersion//;/ })
	JVMVersion=${minMaxArray[0]//+}
	JVMMaxVersion=${minMaxArray[1]//+}
fi
stub_logger "[JavaRequirement] JVM minimum version: ${JVMVersion}"
stub_logger "[JavaRequirement] JVM maximum version: ${JVMMaxVersion}"
 
# MainArgs: replace occurences of $APP_ROOT with its content
MainArgsArr=()
for i in "${MainArgs[@]}"
do
	MainArgsArr+=("$(eval echo "$i")")
done
 
# JVMOptions: replace occurences of $APP_ROOT with its content
JVMOptionsArr=()
for i in "${JVMOptions[@]}"
do
	JVMOptionsArr+=("$(eval echo "$i")")
done
 
 
# internationalized messages
############################################
 
LANG=$(defaults read -g AppleLocale)
stub_logger "[Language] $LANG"
 
# French localization
if [[ $LANG == fr* ]] ; then
	MSG_ERROR_LAUNCHING="ERREUR au lancement de '${CFBundleName}'."
	MSG_MISSING_MAINCLASS="'MainClass' n'est pas spécifié.\nL'application Java ne peut pas être lancée."
	MSG_JVMVERSION_REQ_INVALID="La syntaxe de la version de Java demandée est invalide: %s\nVeuillez contacter le développeur de l'application."
	MSG_NO_SUITABLE_JAVA="La version de Java installée sur votre système ne convient pas.\nCe programme nécessite Java %s"
	MSG_JAVA_VERSION_OR_LATER="ou ultérieur"
	MSG_JAVA_VERSION_LATEST="(dernière mise à jour)"
	MSG_JAVA_VERSION_MAX="à %s"
	MSG_NO_SUITABLE_JAVA_CHECK="Merci de bien vouloir installer la version de Java requise."
	MSG_INSTALL_JAVA="Java doit être installé sur votre système.\nRendez-vous sur java.com et suivez les instructions d'installation..."
	MSG_LATER="Plus tard"
	MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
	MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
 
# German localization
elif [[ $LANG == de* ]] ; then
	MSG_ERROR_LAUNCHING="FEHLER beim Starten von '${CFBundleName}'."
	MSG_MISSING_MAINCLASS="Die 'MainClass' ist nicht spezifiziert!\nDie Java-Anwendung kann nicht gestartet werden!"
	MSG_JVMVERSION_REQ_INVALID="Die Syntax der angeforderten Java-Version ist ungültig: %s\nBitte kontaktieren Sie den Entwickler der App."
	MSG_NO_SUITABLE_JAVA="Es wurde keine passende Java-Version auf Ihrem System gefunden!\nDieses Programm benötigt Java %s"
	MSG_JAVA_VERSION_OR_LATER="oder neuer"
	MSG_JAVA_VERSION_LATEST="(neuste Unterversion)"
	MSG_JAVA_VERSION_MAX="bis %s"
	MSG_NO_SUITABLE_JAVA_CHECK="Stellen Sie sicher, dass die angeforderte Java-Version installiert ist."
	MSG_INSTALL_JAVA="Auf Ihrem System muss die 'Java'-Software installiert sein.\nBesuchen Sie java.com für weitere Installationshinweise."
	MSG_LATER="Später"
	MSG_VISIT_JAVA_DOT_COM="Java von Oracle"
	MSG_VISIT_ADOPTOPENJDK="Java von AdoptOpenJDK"
 
# Simplifyed Chinese localization
elif [[ $LANG == zh* ]] ; then
	MSG_ERROR_LAUNCHING="无法启动 '${CFBundleName}'."
	MSG_MISSING_MAINCLASS="没有指定 'MainClass'!\nJava程序无法启动!"
	MSG_JVMVERSION_REQ_INVALID="Java版本参数语法错误: %s\n请联系该应用的开发者。"
	MSG_NO_SUITABLE_JAVA="没有在系统中找到合适的Java版本!\n必须安装Java %s才能够使用该程序!"
	MSG_JAVA_VERSION_OR_LATER="及以上版本"
	MSG_JAVA_VERSION_LATEST="(最新版本)"
	MSG_JAVA_VERSION_MAX="最高为 %s"
	MSG_NO_SUITABLE_JAVA_CHECK="请确保系统中安装了所需的Java版本"
	MSG_INSTALL_JAVA="你需要在Mac中安装Java运行环境!\n访问 java.com 了解如何安装。"
	MSG_LATER="稍后"
	MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
	MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
 
# English default localization
else
	MSG_ERROR_LAUNCHING="ERROR launching '${CFBundleName}'."
	MSG_MISSING_MAINCLASS="'MainClass' isn't specified!\nJava application cannot be started!"
	MSG_JVMVERSION_REQ_INVALID="The syntax of the required Java version is invalid: %s\nPlease contact the App developer."
	MSG_NO_SUITABLE_JAVA="No suitable Java version found on your system!\nThis program requires Java %s"
	MSG_JAVA_VERSION_OR_LATER="or later"
	MSG_JAVA_VERSION_LATEST="(latest update)"
	MSG_JAVA_VERSION_MAX="up to %s"
	MSG_NO_SUITABLE_JAVA_CHECK="Make sure you install the required Java version."
	MSG_INSTALL_JAVA="You need to have JAVA installed on your Mac!\nVisit java.com for installation instructions..."
	MSG_LATER="Later"
	MSG_VISIT_JAVA_DOT_COM="Java by Oracle"
	MSG_VISIT_ADOPTOPENJDK="Java by AdoptOpenJDK"
fi
 
 
 
# function 'get_java_version_from_cmd()'
#
# returns Java version string from 'java -version' command
# works for both old (1.8) and new (9) version schema
#
# @param1  path to a java JVM executable
# @return  the Java version number as displayed in 'java -version' command
################################################################################
function get_java_version_from_cmd() {
	# second sed command strips " and -ea from the version string
	echo $("$1" -version 2>&1 | awk '/version/{print $3}' | sed -E 's/"//g;s/-ea//g')
}
 
 
# function 'extract_java_major_version()'
#
# extract Java major version from a version string
#
# @param1  a Java version number ('1.8.0_45') or requirement string ('1.8+')
# @return  the major version (e.g. '7', '8' or '9', etc.)
################################################################################
function extract_java_major_version() {
	echo $(echo "$1" | sed -E 's/^1\.//;s/^([0-9]+)(-ea|(\.[0-9_.]{1,7})?)(-b[0-9]+-[0-9]+)?[+*]?$/\1/')
}
 
 
# function 'get_comparable_java_version()'
#
# return comparable version for a Java version number or requirement string
#
# @param1  a Java version number ('1.8.0_45') or requirement string ('1.8+')
# @return  an 8 digit numeral ('1.8.0_45'->'08000045'; '9.1.13'->'09001013')
################################################################################
function get_comparable_java_version() {
	# cleaning: 1) remove leading '1.'; 2) remove build string (e.g. '-b14-468'); 3) remove 'a-Z' and '-*+' (e.g. '-ea'); 4) replace '_' with '.'
	local cleaned=$(echo "$1" | sed -E 's/^1\.//g;s/-b[0-9]+-[0-9]+$//g;s/[a-zA-Z+*\-]//g;s/_/./g')
	# splitting at '.' into an array
	local arr=( ${cleaned//./ } )
	# echo a string with left padded version numbers
	echo "$(printf '%02s' ${arr[0]})$(printf '%03s' ${arr[1]})$(printf '%03s' ${arr[2]})"
}
 
 
# function 'is_valid_requirement_pattern()'
#
# check whether the Java requirement is a valid requirement pattern
#
# supported requirements are for example:
# - 1.6       requires Java 6 (any update)      [1.6, 1.6.0_45, 1.6.0_88]
# - 1.6*      requires Java 6 (any update)      [1.6, 1.6.0_45, 1.6.0_88]
# - 1.6+      requires Java 6 or higher         [1.6, 1.6.0_45, 1.8, 9, etc.]
# - 1.6.0     requires Java 6 (any update)      [1.6, 1.6.0_45, 1.6.0_88]
# - 1.6.0_45  requires Java 6u45                [1.6.0_45]
# - 1.6.0_45+ requires Java 6u45 or higher      [1.6.0_45, 1.6.0_88, 1.8, etc.]
# - 9         requires Java 9 (any update)      [9.0.*, 9.1, 9.3, etc.]
# - 9*        requires Java 9 (any update)      [9.0.*, 9.1, 9.3, etc.]
# - 9+        requires Java 9 or higher         [9.0, 9.1, 10, etc.]
# - 9.1       requires Java 9.1 (any update)    [9.1.*, 9.1.2, 9.1.13, etc.]
# - 9.1*      requires Java 9.1 (any update)    [9.1.*, 9.1.2, 9.1.13, etc.]
# - 9.1+      requires Java 9.1 or higher       [9.1, 9.2, 10, etc.]
# - 9.1.3     requires Java 9.1.3               [9.1.3]
# - 9.1.3*    requires Java 9.1.3 (any update)  [9.1.3]
# - 9.1.3+    requires Java 9.1.3 or higher     [9.1.3, 9.1.4, 9.2.*, 10, etc.]
# - 10-ea     requires Java 10 (early access release)
#
# unsupported requirement patterns are for example:
# - 1.2, 1.3, 1.9       Java 2, 3 are not supported
# - 1.9                 Java 9 introduced a new versioning scheme
# - 6u45                known versioning syntax, but unsupported
# - 9-ea*, 9-ea+        early access releases paired with */+
# - 9., 9.*, 9.+        version ending with a .
# - 9.1., 9.1.*, 9.1.+  version ending with a .
# - 9.3.5.6             4 part version number is unsupported
#
# @param1  a Java requirement string ('1.8+')
# @return  boolean exit code: 0 (is valid), 1 (is not valid)
################################################################################
function is_valid_requirement_pattern() {
	local java_req=$1
	java8pattern='1\.[4-8](\.[0-9]+)?(\.0_[0-9]+)?[*+]?'
	java9pattern='(9|1[0-9])(-ea|[*+]|(\.[0-9]+){1,2}[*+]?)?'
	# test matches either old Java versioning scheme (up to 1.8) or new scheme (starting with 9)
	if [[ ${java_req} =~ ^(${java8pattern}|${java9pattern})$ ]]; then
		return 0
	else
		return 1
	fi
}
 
 
 
# determine which JVM to use
############################################
 
# default Apple JRE plugin path (< 1.6)
apple_jre_plugin="/Library/Java/Home/bin/java"
apple_jre_version=$(get_java_version_from_cmd "${apple_jre_plugin}")
# default Oracle JRE plugin path (>= 1.7)
oracle_jre_plugin="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java"
oracle_jre_version=$(get_java_version_from_cmd "${oracle_jre_plugin}")
 
 
# first check system variable "$JAVA_HOME" -> has precedence over any other System JVM
stub_logger '[JavaSearch] Checking for $JAVA_HOME ...'
if [ -n "$JAVA_HOME" ] ; then
	stub_logger "[JavaSearch] ... found JAVA_HOME with value $JAVA_HOME"
 
	# PR 26: Allow specifying "$JAVA_HOME" relative to "$AppPackageFolder"
	# which allows for bundling a custom version of Java inside your app!
	if [[ $JAVA_HOME == /* ]] ; then
		# if "$JAVA_HOME" starts with a Slash it's an absolute path
		JAVACMD="$JAVA_HOME/bin/java"
	else
		# otherwise it's a relative path to "$AppPackageFolder"
		JAVACMD="$AppPackageFolder/$JAVA_HOME/bin/java"
	fi
	JAVACMD_version=$(get_comparable_java_version $(get_java_version_from_cmd "${JAVACMD}"))
else
	stub_logger "[JavaSearch] ... didn't found JAVA_HOME"
fi
 
 
# check for any other or a specific Java version
# also if $JAVA_HOME exists but isn't executable
if [ -z "${JAVACMD}" ] || [ ! -x "${JAVACMD}" ] ; then
	stub_logger "[JavaSearch] Checking for JavaVirtualMachines on the system ..."
	# reset variables
	JAVACMD=""
	JAVACMD_version=""
 
	# first check whether JVMVersion string is a valid requirement string
	if [ ! -z "${JVMVersion}" ] && ! is_valid_requirement_pattern ${JVMVersion} ; then
		MSG_JVMVERSION_REQ_INVALID_EXPANDED=$(printf "${MSG_JVMVERSION_REQ_INVALID}" "${JVMVersion}")
		# log exit cause
		stub_logger "[EXIT 4] ${MSG_JVMVERSION_REQ_INVALID_EXPANDED}"
		# display error message with AppleScript
		osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_JVMVERSION_REQ_INVALID_EXPANDED}\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1${DialogWithIcon}"
		# exit with error
		exit 4
	fi
	# then check whether JVMMaxVersion string is a valid requirement string
	if [ ! -z "${JVMMaxVersion}" ] && ! is_valid_requirement_pattern ${JVMMaxVersion} ; then
		MSG_JVMVERSION_REQ_INVALID_EXPANDED=$(printf "${MSG_JVMVERSION_REQ_INVALID}" "${JVMMaxVersion}")
		# log exit cause
		stub_logger "[EXIT 5] ${MSG_JVMVERSION_REQ_INVALID_EXPANDED}"
		# display error message with AppleScript
		osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_JVMVERSION_REQ_INVALID_EXPANDED}\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1${DialogWithIcon}"
		# exit with error
		exit 5
	fi
 
 
	# find installed JavaVirtualMachines (JDK + JRE)
	allJVMs=()
	# read JDK's from '/usr/libexec/java_home -V' command
	while read -r line; do
		version=$(echo $line | awk -F $',' '{print $1;}')
		path=$(echo $line | awk -F $'" ' '{print $2;}')
		path+="/bin/java"
		allJVMs+=("$version:$path")
	done < <(/usr/libexec/java_home -V 2>&1 | grep '^[[:space:]]')
	# unset while loop variables
	unset version path
 
	# add Apple JRE if available
	if [ -x "${apple_jre_plugin}" ] ; then
		allJVMs+=("$apple_jre_version:$apple_jre_plugin")
	fi
 
	# add Oracle JRE if available
	if [ -x "${oracle_jre_plugin}" ] ; then
		allJVMs+=("$oracle_jre_version:$oracle_jre_plugin")
	fi
 
	# debug output
	for i in "${allJVMs[@]}"
	do
		stub_logger "[JavaSearch] ... found JVM: $i"
	done
 
 
	# determine JVMs matching the min/max version requirement
	minC=$(get_comparable_java_version ${JVMVersion})
	maxC=$(get_comparable_java_version ${JVMMaxVersion})
	matchingJVMs=()
 
	for i in "${allJVMs[@]}"
	do
		# split JVM string at ':' delimiter to retain spaces in $path substring
		IFS=: arr=($i) ; unset IFS
		# [0] JVM version number
		ver=${arr[0]}
		# comparable JVM version number
		comp=$(get_comparable_java_version $ver)
		# [1] JVM path
		path="${arr[1]}"
		# construct string item for adding to the "matchingJVMs" array
		item="$comp:$ver:$path"
 
		# pre-requisite: current version number needs to be greater than min version number
		if [ "$comp" -ge "$minC" ] ; then
 
			# perform max version checks if max version requirement is present
			if [ ! -z ${JVMMaxVersion} ] ; then
 
				# max version requirement ends with '*' modifier
				if [[ ${JVMMaxVersion} == *\* ]] ; then
 
					# use the '*' modifier from the max version string as wildcard for a 'starts with' comparison
					# and check whether the current version number starts with the max version wildcard string
					if [[ ${ver} == ${JVMMaxVersion} ]]; then
						matchingJVMs+=("$item")
 
					# or whether the current comparable version is lower than the comparable max version
					elif [ "$comp" -le "$maxC" ] ; then
						matchingJVMs+=("$item")
					fi
 
				# max version requirement ends with '+' modifier -> always add this version if it's greater than $min
				# because a max requirement with + modifier doesn't make sense
				elif [[ ${JVMMaxVersion} == *+ ]] ; then
					matchingJVMs+=("$item")
 
				# matches 6 zeros at the end of the max version string (e.g. for 1.8, 9)
				# -> then the max version string should be treated like with a '*' modifier at the end
				#elif [[ ${maxC} =~ ^[0-9]{2}0{6}$ ]] && [ "$comp" -le $(( ${maxC#0} + 999 )) ] ; then
				#	matchingJVMs+=("$item")
 
				# matches 3 zeros at the end of the max version string (e.g. for 9.1, 10.3)
				# -> then the max version string should be treated like with a '*' modifier at the end
				#elif [[ ${maxC} =~ ^[0-9]{5}0{3}$ ]] && [ "$comp" -le "${maxC}" ] ; then
				#	matchingJVMs+=("$item")
 
				# matches standard requirements without modifier
				elif [ "$comp" -le "$maxC" ]; then
					matchingJVMs+=("$item")
				fi
 
			# no max version requirement:
 
			# min version requirement ends with '+' modifier
			# -> always add the current version because it's greater than $min
			elif [[ ${JVMVersion} == *+ ]] ; then
				matchingJVMs+=("$item")
 
			# min version requirement ends with '*' modifier
			# -> use the '*' modifier from the min version string as wildcard for a 'starts with' comparison
			#    and check whether the current version number starts with the min version wildcard string
			elif [[ ${JVMVersion} == *\* ]] ; then
				if [[ ${ver} == ${JVMVersion} ]] ; then
					matchingJVMs+=("$item")
				fi
 
			# compare the min version against the current version with an additional * wildcard for a 'starts with' comparison
			# -> e.g. add 1.8.0_44 when the requirement is 1.8
			elif [[ ${ver} == ${JVMVersion}* ]] ; then
					matchingJVMs+=("$item")
			fi
		fi
	done
	# unset for loop variables
	unset arr ver comp path item
 
	# debug output
	for i in "${matchingJVMs[@]}"
	do
		stub_logger "[JavaSearch] ... ... matches all requirements: $i"
	done
 
 
	# sort the matching JavaVirtualMachines by version number
	# https://stackoverflow.com/a/11789688/1128689
	IFS=$'\n' matchingJVMs=($(sort -nr <<<"${matchingJVMs[*]}"))
	unset IFS
 
 
	# get the highest matching JVM
	for ((i = 0; i < ${#matchingJVMs[@]}; i++));
	do
		# split JVM string at ':' delimiter to retain spaces in $path substring
		IFS=: arr=(${matchingJVMs[$i]}) ; unset IFS
		# [0] comparable JVM version number
		comp=${arr[0]}
		# [1] JVM version number
		ver=${arr[1]}
		# [2] JVM path
		path="${arr[2]}"
 
		# use current value as JAVACMD if it's executable
		if [ -x "$path" ] ; then
			JAVACMD="$path"
			JAVACMD_version=$comp
			break
		fi
	done
	# unset for loop variables
	unset arr comp ver path
fi
 
# log the Java Command and the extracted version number
stub_logger "[JavaCommand] '$JAVACMD'"
stub_logger "[JavaVersion] $(get_java_version_from_cmd "${JAVACMD}")${JAVACMD_version:+/$JAVACMD_version}"
 
 
 
if [ -z "${JAVACMD}" ] || [ ! -x "${JAVACMD}" ] ; then
 
	# different error messages when a specific JVM was required
	if [ ! -z "${JVMVersion}" ] ; then
		# display human readable java version (#28)
		java_version_hr=$(echo ${JVMVersion} | sed -E 's/^1\.([0-9+*]+)$/ \1/g' | sed "s/+/ ${MSG_JAVA_VERSION_OR_LATER}/;s/*/ ${MSG_JAVA_VERSION_LATEST}/")
		MSG_NO_SUITABLE_JAVA_EXPANDED=$(printf "${MSG_NO_SUITABLE_JAVA}" "${java_version_hr}").
 
		if [ ! -z "${JVMMaxVersion}" ] ; then
			java_version_hr=$(extract_java_major_version ${JVMVersion})
			java_version_max_hr=$(echo ${JVMMaxVersion} | sed -E 's/^1\.([0-9+*]+)$/ \1/g' | sed "s/+//;s/*/ ${MSG_JAVA_VERSION_LATEST}/")
			MSG_NO_SUITABLE_JAVA_EXPANDED="$(printf "${MSG_NO_SUITABLE_JAVA}" "${java_version_hr}") $(printf "${MSG_JAVA_VERSION_MAX}" "${java_version_max_hr}")"
		fi
 
		# log exit cause
		stub_logger "[EXIT 3] ${MSG_NO_SUITABLE_JAVA_EXPANDED}"
 
		# display error message with AppleScript
		osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_NO_SUITABLE_JAVA_EXPANDED}\n${MSG_NO_SUITABLE_JAVA_CHECK}\" with title \"${CFBundleName}\"  buttons {\" OK \", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTOPENJDK}\"} default button 1${DialogWithIcon}" \
				-e "set response to button returned of the result" \
				-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"https://www.java.com/download/\"" \
				-e "if response is \"${MSG_VISIT_ADOPTOPENJDK}\" then open location \"https://adoptopenjdk.net/releases.html\""
		# exit with error
		exit 3
 
	else
		# log exit cause
		stub_logger "[EXIT 1] ${MSG_ERROR_LAUNCHING}"
		# display error message with AppleScript
		osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_INSTALL_JAVA}\" with title \"${CFBundleName}\" buttons {\"${MSG_LATER}\", \"${MSG_VISIT_JAVA_DOT_COM}\", \"${MSG_VISIT_ADOPTOPENJDK}\"} default button 1${DialogWithIcon}" \
					-e "set response to button returned of the result" \
					-e "if response is \"${MSG_VISIT_JAVA_DOT_COM}\" then open location \"https://www.java.com/download/\"" \
					-e "if response is \"${MSG_VISIT_ADOPTOPENJDK}\" then open location \"https://adoptopenjdk.net/releases.html\""
		# exit with error
		exit 1
	fi
fi
 
 
 
# MainClass check
############################################
 
if [ -z "${JVMMainClass}" ]; then
	# log exit cause
	stub_logger "[EXIT 2] ${MSG_MISSING_MAINCLASS}"
	# display error message with AppleScript
	osascript -e "tell application \"System Events\" to display dialog \"${MSG_ERROR_LAUNCHING}\n\n${MSG_MISSING_MAINCLASS}\" with title \"${CFBundleName}\" buttons {\" OK \"} default button 1${DialogWithIcon}"
	# exit with error
	exit 2
fi
 
 
 
# execute $JAVACMD and do some preparation
############################################
 
# enable drag&drop to the dock icon
export CFProcessPath="$0"
 
# remove Apples ProcessSerialNumber from passthru arguments (#39)
if [[ "$*" == -psn* ]] ; then
	ArgsPassthru=()
else
	ArgsPassthru=("$@")
fi
 
# change to Working Directory based upon Apple/Oracle Plist info
cd "${WorkingDirectory}" || exit 13
stub_logger "[WorkingDirectory] ${WorkingDirectory}"
 
# execute Java and set
# - classpath
# - splash image
# - dock icon
# - app name
# - JVM options/properties (-D)
# - JVM default options (-X)
# - main class
# - main class arguments
# - passthrough arguments from Terminal or Drag'n'Drop to Finder icon
stub_logger "[Exec] \"$JAVACMD\" -cp \"${JVMClassPath}\" -splash:\"${ResourcesFolder}/${JVMSplashFile}\" -Xdock:icon=\"${ResourcesFolder}/${CFBundleIconFile}\" -Xdock:name=\"${CFBundleName}\" ${JVMOptionsArr:+$(printf "'%s' " "${JVMOptionsArr[@]}") }${JVMDefaultOptions:+$JVMDefaultOptions }${JVMMainClass}${MainArgsArr:+ $(printf "'%s' " "${MainArgsArr[@]}")}${ArgsPassthru:+ $(printf "'%s' " "${ArgsPassthru[@]}")}"
exec "${JAVACMD}" \
		-cp "${JVMClassPath}" \
		-splash:"${ResourcesFolder}/${JVMSplashFile}" \
		-Xdock:icon="${ResourcesFolder}/${CFBundleIconFile}" \
		-Xdock:name="${CFBundleName}" \
		${JVMOptionsArr:+"${JVMOptionsArr[@]}" }\
		${JVMDefaultOptions:+$JVMDefaultOptions }\
		"${JVMMainClass}"\
		${MainArgsArr:+ "${MainArgsArr[@]}"}\
		${ArgsPassthru:+ "${ArgsPassthru[@]}"}

Tips: https://github.com/java-decompiler/jd-gui/issues/332

[Solved] Redis Client On Error Error connect ECONNREFUSED 11.20.200.6379 Config right

preface

Error when docker installs redis and starts


Solution:

Modify profile

 vim redis.conf 

Comment out??Code

Restart redis:

docker start redis

If the connection using the local client is unsuccessful, you can only enter the redis shell to modify the configuration file:

root@iZ8vb4poq26tme4bwexb4lZ:/usr/local/docker/redis# ps -ef | grep redis
redis     2605     1  1  2020 ?       2-18:12:56 /usr/bin/redis-server *:20000
root      5834 24173  0 21:18 pts/0    00:00:00 grep --color=auto redis
999      20678 20643  0 20:52 ?       00:00:04 redis-server 127.0.0.1:6379

[Solved] Web server failed to start. Port 8080 was already in use.

Problem Description:

Description:

Web server failed to start. Port 8080 was already in use.

Action:

Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port.

Method 1: turn off the process occupying port 8080

    1. 1. keyboard input (Win + R), then enter “cmd” in the run dialog box, enter the command window
  1. 2. enter netstat -ano|findstr “8080”, and press Enter, as shown in the following screenshot:

3. Then enter tasklist|findstr “3516” and press enter to get the process occupying port 8080

4. Open the “task manager”, locate the change process, and then end the process. The occupation of port 8080 is cancelled

Or close with the command: taskkill -PID 3516 -F

Method 2: modify the configuration file and use other available ports

We can modify the port number in application.yml configuration file, as shown below:

View port, process and end process on Linux system

  a,Check port occupancy
    netstat -nap|grep 8080
  b,View port occupied processes
     ps -aux |grep 27672
   c,End a process
    kill -9 pid

[Solved] Project Startup Error: Redis health check failed: Unable to connect to localhost6379

Error reporting details

Analysis and solution

There is no connection of redis in my project, so it’s strange to report an error. Combined with the sentence redis health check failed, guess which thing introduced redis, and then do the health check of redis.

The solution is as follows: configurate as the following in application.yml

# Disable Actuator monitoring of Redis connections
management:
  health:
    redis:
      enabled: false

[Solved] ES Error: Elasticsearch health check failed

Original error report:

2020-11-30 18:39:08.019  WARN 17664 --- [-192.168.113.22] s.b.a.e.ElasticsearchRestHealthIndicator : Elasticsearch health check failed

java.net.ConnectException: Timeout connecting to [localhost/127.0.0.1:9200]
	at org.elasticsearch.client.RestClient$SyncResponseListener.get(RestClient.java:943) ~[elasticsearch-rest-client-6.4.3.jar:6.4.3]
	at org.elasticsearch.client.RestClient.performRequest(RestClient.java:227) ~[elasticsearch-rest-client-6.4.3.jar:6.4.3]
	at org.springframework.boot.actuate.elasticsearch.ElasticsearchRestHealthIndicator.doHealthCheck(ElasticsearchRestHealthIndicator.java:60) ~[spring-boot-actuator-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.actuate.health.AbstractHealthIndicator.health(AbstractHealthIndicator.java:82) ~[spring-boot-actuator-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.actuate.health.CompositeHealthIndicator.health(CompositeHealthIndicator.java:95) [spring-boot-actuator-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.actuate.health.HealthEndpoint.health(HealthEndpoint.java:50) [spring-boot-actuator-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161]
	at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:282) [spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
	at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:76) [spring-boot-actuator-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:60) [spring-boot-actuator-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:121) [spring-boot-actuator-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at org.springframework.boot.actuate.endpoint.jmx.EndpointMBean.invoke(EndpointMBean.java:96) [spring-boot-actuator-2.1.7.RELEASE.jar:2.1.7.RELEASE]
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) [na:1.8.0_161]
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) [na:1.8.0_161]
	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468) [na:1.8.0_161]
	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76) [na:1.8.0_161]
	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309) [na:1.8.0_161]
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1401) [na:1.8.0_161]
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829) [na:1.8.0_161]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_161]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_161]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_161]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_161]
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:361) [na:1.8.0_161]
	at sun.rmi.transport.Transport$1.run(Transport.java:200) [na:1.8.0_161]
	at sun.rmi.transport.Transport$1.run(Transport.java:197) [na:1.8.0_161]
	at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_161]
	at sun.rmi.transport.Transport.serviceCall(Transport.java:196) [na:1.8.0_161]
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568) [na:1.8.0_161]
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826) [na:1.8.0_161]
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683) [na:1.8.0_161]
	at java.security.AccessController.doPrivileged(Native Method) [na:1.8.0_161]
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682) [na:1.8.0_161]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_161]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_161]
	at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_161]
Caused by: java.net.ConnectException: Timeout connecting to [localhost/127.0.0.1:9200]
	at org.apache.http.nio.pool.RouteSpecificPool.timeout(RouteSpecificPool.java:169) ~[httpcore-nio-4.4.11.jar:4.4.11]
	at org.apache.http.nio.pool.AbstractNIOConnPool.requestTimeout(AbstractNIOConnPool.java:628) ~[httpcore-nio-4.4.11.jar:4.4.11]
	at org.apache.http.nio.pool.AbstractNIOConnPool$InternalSessionRequestCallback.timeout(AbstractNIOConnPool.java:894) ~[httpcore-nio-4.4.11.jar:4.4.11]
	at org.apache.http.impl.nio.reactor.SessionRequestImpl.timeout(SessionRequestImpl.java:183) ~[httpcore-nio-4.4.11.jar:4.4.11]
	at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processTimeouts(DefaultConnectingIOReactor.java:210) ~[httpcore-nio-4.4.11.jar:4.4.11]
	at org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor.processEvents(DefaultConnectingIOReactor.java:155) ~[httpcore-nio-4.4.11.jar:4.4.11]
	at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor.execute(AbstractMultiworkerIOReactor.java:351) ~[httpcore-nio-4.4.11.jar:4.4.11]
	at org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager.execute(PoolingNHttpClientConnectionManager.java:221) ~[httpasyncclient-4.1.4.jar:4.1.4]
	at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase$1.run(CloseableHttpAsyncClientBase.java:64) ~[httpasyncclient-4.1.4.jar:4.1.4]
	... 1 common frames omitted

Solution: add the following configuration to solve the problem successfully

  data:
    elasticsearch:
      repositories:
        enabled: true
      cluster-nodes: 192.168.136.137:9300
      cluster-name: docker-cluster
  #      Add the following configuration to pass the health check
  elasticsearch:
    rest:
      uris: ["http://192.168.136.137:9200"]

[Solved] Error:java: Compilation failed: internal java compiler error

Error phenomenon

When using idea to import a new project or upgrade idea or create a new project, the following exception message will appear:

Error:java: Compilation failed: internal java compiler error 

Cause of error

This error is mainly caused by the JDK version. There are two reasons: the compiled version does not match, and the current project JDK version does not support.

View the JDK of the project

File -> Project Structure-> Project Settings -> Project or use the shortcut Ctrl+Alt+shift+S to open the JDK configuration of the project:

Check whether these two points are consistent with the target JDK.

View the JDK of the project

Click modules in the figure above to view the corresponding JDK version:

View java compiler version

When importing Java projects, the probability of this problem is high.

To solve this problem, reopening or modifying the contents of the POM file (Maven project) is likely to cause the JDK version to change back to 1.5. If it is a maven project, you can specify JDK related information in the POM file:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

[Solved] Heroku Error: Web process failed to bind to $PORT within 60 seconds of launch

Error description

If the set port number is less than 1000, an error will be reported, and there is no permission

2022-03-29T10:23:16.651636+00:00 heroku[web.1]: State changed from crashed to starting
2022-03-29T10:23:28.994173+00:00 heroku[web.1]: Starting process with command `python /code/server3.py`
2022-03-29T10:23:30.091143+00:00 app[web.1]: Traceback (most recent call last):
2022-03-29T10:23:30.091204+00:00 app[web.1]: File "/code/server3.py", line 247, in <module>
2022-03-29T10:23:30.091205+00:00 app[web.1]: serverSocket.bind(("127.0.0.1", serverPort))
2022-03-29T10:23:30.091208+00:00 app[web.1]: PermissionError: [Errno 13] Permission denied
2022-03-29T10:23:30.234919+00:00 heroku[web.1]: Process exited with status 1
2022-03-29T10:23:30.279569+00:00 heroku[web.1]: State changed from starting to crashed

If you set the port number to 8080, you will not be connected within 60 seconds

2022-03-29T10:53:34.400924+00:00 heroku[web.1]: State changed from crashed to starting
2022-03-29T10:53:49.432473+00:00 heroku[web.1]: Starting process with command `python /code/server3.py`
2022-03-29T10:53:33.432308+00:00 app[api]: Release v9 created by user ***@icloud.com
2022-03-29T10:53:33.432308+00:00 app[api]: Deployed web (350d1bd5740a) by user ***@icloud.com
2022-03-29T10:54:49.500818+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2022-03-29T10:54:49.587777+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-03-29T10:54:49.800462+00:00 heroku[web.1]: Process exited with status 137

If the port number in the environment variable is referenced dynamically, the acquisition fails

2022-03-29T11:12:03.984493+00:00 heroku[web.1]: State changed from crashed to starting
2022-03-29T11:12:19.984320+00:00 heroku[web.1]: Starting process with command `python /code/server3.py`
2022-03-29T11:12:21.706887+00:00 heroku[web.1]: Process exited with status 1
2022-03-29T11:12:21.536737+00:00 app[web.1]: Traceback (most recent call last):
2022-03-29T11:12:21.536756+00:00 app[web.1]: File "/code/server3.py", line 248, in <module>
2022-03-29T11:12:21.536757+00:00 app[web.1]: serverSocket.bind(("0.0.0.0", serverPort))
2022-03-29T11:12:21.536757+00:00 app[web.1]: TypeError: an integer is required (got type NoneType)
2022-03-29T11:12:21.769096+00:00 heroku[web.1]: State changed from starting to crashed

No matter the local address is not written,
ServerSocket Bind ((“”, serverport))
or 127.0.0.1
ServerSocket Bind ((“127.0.0.1”, serverport))
or write 0.0.0
ServerSocket Bind ((“0.0.0.0”, serverport))
doesn’t work

 

Solution (Python Project):

Dynamic binding port number is required

To write this in dockerfile, pass in $post

#Base image based on
FROM python:3.4

#code added to code folder
ADD . /pythonProject /code

# Set the code folder to be the working directory
WORKDIR /code

# Install support
#RUN pip install -r requirements.txt

CMD python /code/server3.py $PORT

Python file writing format,  obtain through parameters in server.py

serverPort = int(sys.argv[1])

The complete structure is as follows

if __name__ == '__main__':
    serverSocket = socket(AF_INET, SOCK_STREAM)
    serverPort = int(sys.argv[1])
    serverSocket.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
    serverSocket.bind(("", serverPort))

    serverSocket.listen(5)
    print('The server is running')
    # Main web server loop. It simply accepts TCP connections, and get the request processed in seperate threads.
    while True:
        # Set up a new connection from the client
        connectionSocket, addr = serverSocket.accept()
        # Clients timeout after 60 seconds of inactivity and must reconnect.
        connectionSocket.settimeout(600)
        # start new thread to handle incoming request
        _thread.start_new_thread(process, (connectionSocket,))

Solution (Nodejs Project):

// production
config.port = process.env.PORT

app.listen(config.port, () => {
  logger.info('Listening on port %d', config.port);
});

or

.listen(process.env.PORT || 5000)

or

production: {
    server: {
        host: '0.0.0.0',
        port: process.env.PORT
    }
}

Request processing failed; nested exception is java.lang.NullPointerException or UnsatisfiedDependencyE

1. Null pointer exception:

Request processing failed; nested exception is java.lang.NullPointerException

java.lang.NullPointerException
com.atguigu.mvc.controller.NodesController.getFilesAndSendId(NodesController.java:61)


See the exception address and check the control layer

Control level, line 61:

List<FilePath> files = fileService.getFiles();

current

@RequestMapping(value = "/getFilesAndSendId/{sensor_id}",method = RequestMethod.GET)

Parameter sensor_id is passed;

Solution to null pointer:
Original:

private FileService fileService;

Change to: add @Autowired annotation

 @Autowired
    private FileService fileService;

If there is any other error when you run the codes:

Servlet.init() of Servlet[DispatcherServlet] raises an exception.
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘nodesController’: Unsatisfied dependency expressed through field ‘fileService’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.atguigu.mvc.service.FileService’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}


Solution:
Check if the @Service annotation is added to the implementation class here

[Solved] Docker Start Error: System.InvalidOperationException Failed to set version to docker-desktop exit code

Project scenario:

Docker 3.2.2
win10 Home Edition

Problem Description:

The docker opens error: System.InvalidOperationException: Failed to set version to docker-desktop: exit code: -1
detailed error report:

System.InvalidOperationException:
Failed to set version to docker-desktop: exit code: -1
 stdout: ?S??v?[a?{|?W
N/ec??v?dO0
stderr: 
   在 Docker.ApiServices.WSL2.WslShortLivedCommandResult.LogAndThrowIfUnexpectedExitCode(String prefix, ILogger log, Int32 expectedExitCode) 位置 C:workspacesPR-15387srcgithub.comdockerpinatawinsrcDocker.ApiServicesWSL2WslCommand.cs:Line 146
   在 Docker.Engines.WSL2.WSL2Provisioning.<ProvisionAsync>d__8.MoveNext() 位置 C:workspacesPR-15387srcgithub.comdockerpinatawinsrcDocker.DesktopEnginesWSL2WSL2Provisioning.cs:Line 82
--- The end of the stack trace in the previous location where the exception was raised ---
   在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 Docker.Engines.WSL2.LinuxWSL2Engine.<DoStartAsync>d__26.MoveNext() 位置 C:workspacesPR-15387srcgithub.comdockerpinatawinsrcDocker.DesktopEnginesWSL2LinuxWSL2Engine.cs:Line 104
--- The end of the stack trace in the previous location where the exception was raised ---
   在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 Docker.ApiServices.StateMachines.TaskExtensions.<WrapAsyncInCancellationException>d__0.MoveNext() 位置 C:workspacesPR-15387srcgithub.comdockerpinatawinsrcDocker.ApiServicesStateMachinesTaskExtensions.cs:Line 29
--- The end of the stack trace in the previous location where the exception was raised ---
   在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   在 Docker.ApiServices.StateMachines.StartTransition.<DoRunAsync>d__5.MoveNext() 位置 C:workspacesPR-15387srcgithub.comdockerpinatawinsrcDocker.ApiServicesStateMachinesStartTransition.cs:Line 67
--- The end of the stack trace in the previous location where the exception was raised ---
   在 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   在 Docker.ApiServices.StateMachines.StartTransition.<DoRunAsync>d__5.MoveNext() 位置 C:workspacesPR-15387srcgithub.comdockerpinatawinsrcDocker.ApiServicesStateMachinesStartTransition.cs:Line 92

Screenshot:

 

Solution:

Execute under cmd/shell

netsh winsock reset

Then restart docker