The command WGET not working and sending an error - java

I have created an image doing the following command :
wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.2.1.tgz
So I commented this command, and directly went in my image to do the command. However, the wget fails, with the following message :
wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.tgz
converted 'https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.tgz' (ANSI_X3.4-1968) -> 'https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.tgz' (UTF-8)
--2020-04-22 12:24:57-- https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.tgz
Resolving archive.apache.org (archive.apache.org)... 138.201.131.134, 2a01:4f8:172:2ec5::2
Connecting to archive.apache.org (archive.apache.org)|138.201.131.134|:443... connected.
ERROR: The certificate of 'archive.apache.org' is not trusted.
ERROR: The certificate of 'archive.apache.org' hasn't got a known issuer.
Am I missing something basic with WGET ?
Thank you in advance for your help.

First try to get proper certificate manager installed like below:
sudo apt-get install ca-certificates //. command dependent on linux distro , please correct according to distro use
If you don't care about certificate , then you can pass following param with wget:
--no-check-certificate
like below:
wget --no-check-certificate https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-5.tgz
Note:- It's insecure option and can lead to Security Vulnerability.

Adding --no-check-certificate to the wget command could do the trick, but I don't recommend you to do it.
What base Docker image are you using? Maybe the ca-certificates package is not installed or is outdated.

Related

java app built with gradle does not start on macOs Monterey

I'm having troubles with an application written in Java and built with gradle on Monterey.
I can build it and make a package to install it on macOS. After the installation I can see the right Icon in the Applications folder, but everytime I try to run it this dialog come out:
I think I tried everything to make it work on this OS.
On every other version of MacOS it works well.
I thought the problem could be regarding some permission, so I allowed permissions to every application like this:
but it still doesn't work.
Tried to run it via Terminal but I'm having this error:
The application cannot be opened for an unexpected reason, error=Error
Domain=NSOSStatusErrorDomain Code=-10810 "kLSUnknownErr: Unexpected internal error"
UserInfo={_LSFunction=_LSLaunchWithRunningboard, _LSLine=2732,
NSUnderlyingError=0x600000d3ecd0 {Error Domain=RBSRequestErrorDomain Code=5 "Launch
failed." UserInfo={NSLocalizedFailureReason=Launch failed.,
NSUnderlyingError=0x600000d3e520 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or
directory" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}}}
and I didn't find a solution for this.
I thought it could be a problem of signature of the application or something like that, but trying with these commands in a Teminal to find a solution of any type it still doesn't run.
codesign -v "MyApp.app"
codesign -s "MyCompany" MyApp.app
sudo xattr -r -d com.apple.quarantine MyApp.app
sudo chmod -R 755 MyApp.app
sudo codesign --force --deep --sign - MyApp.app
sudo xattr -d -r com.apple.quarantine /Applications/MyApp.app
Nothing happened and I'm at the starting situation of not working app on Monterey.
It's not a problem of Intel or M1 chip.
What could be the solution to this problem?
I searched all internet but didn't find a solution for this.
Thank you for the help.

Strange advise when loading external library with JNA [duplicate]

I am trying to run the first example in rootbeer library, which you can find from here.
The issue is, even though I followed all of their instructions, I am getting the following message when I am trying to run the Jar
root#ubuserver3:/home/ubuadmin/JavaJars/HelloWordGPU# java -jar HelloWorldGPU.jar
OpenJDK Client VM warning: You have loaded library /usr/lib/libcuda.so.319.37 which might have disabled stack guard. The VM will try to fix the stack guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'.
Exception in thread "main" java.lang.NullPointerException
at org.trifort.rootbeer.runtime.Rootbeer.run(Rootbeer.java:104)
at ScalarMult.test(ScalarMult.java:13)
at Main.main(Main.java:17)
I am not a Linux person, so I do not understand how to execute this command properly. I also don't understand what they mean by that message, because this is the first time I am on GPU programming. But I know messing with GPU with wrong commands would be a problem.
Type: execstack --version to check if you already have execstack installed.
If you get command not found type: sudo apt-get install execstack -y --force-yes
Type sudo execstack -c <file>
e.g sudo execstack -c /usr/lib/libcuda.so
1: Check execstack version using following command to find execstack installed or not
execstack --version
2: If execstack not installed then install using following command
sudo apt-get install execstack -y --force-yes
3: After successful installation execute following command
sudo execstack -c <filepath>
eg: sudo execstack -c /usr/lib/libjpcap.so
Make sure you are not running 32-bit Java. If you run java -d64, the 32-bit version will print an error.
make sure you are not running 32-bit jar on 64-bit jvm first
What does the file /usr/lib/libcuda.so.319.37 contain?
If the file is a 0-byte-file, there is something really wrong, so try to repair your system by reinstalling that library.
I had the same problem in smartgit, where a library in the local config folder was used, which was somehow corrupted and was a 0 byte file. So deleting the config folder and restarting the app worked for me. This could be a solution here too.

Java runtime error in Ubuntu - Where in a code to put javax.net.ssl.trustStore?

I used this Java code from here and when I try to download a file with Google Disk shared link with https I get an error:
javax.net.ssl.SSLException: java.lang.RuntimeException: Unexpected
error: java.security.InvalidAlgorithmParameterException: the
trustAnchors parameter must be non-empty
As I understand, I have to set in the code:
System.setProperty("javax.net.ssl.trustStore","/usr/lib/jvm/default-java/lib/security/cacerts");
Where in the code I have to put it and what if I run it on Windows PC later?
Ok, the solution for me on Ubuntu 18.04 was this commnet from #jsn on this SO question:
I ran sudo rm /etc/ssl/certs/java/cacerts and then sudo
update-ca-certificates -f and this fixed my issue in kubuntu 18.04.
Note that if you use Tomcat you should add trustStore properties to setenv.sh.
On Ubuntu/Debian:
-Djavax.net.ssl.trustStorePassword=changeit
-Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts
On CentOS/RH the path is different:
-Djavax.net.ssl.trustStore=/etc/pki/ca-trust/extracted/java/cacerts
Note that cacerts keystore is not generated by default on Ubuntu. You need to install ca-certificates-java
apt-get update
apt-get install ca-certificates-java
Note that above will install some Java (JDK 11 on Ubuntu 20). So to keep your previous version you might need change your java path in /etc/alternatives (the file /etc/alternatives/java is a link).

Mimic wget in Java --no-check-certificate --secure-protocol=TLSv1

I'm trying to download a file which is behind a website with authentication.
The service gave an example script which uses wget to download the file.
Now I'm trying to mimic that functionality in Java
set WGET_PARAM= --no-check-certificate --secure-protocol=TLSv1
set DOWNLOAD_PARAM=-nd -N -r --level=2 --include-directories=blob --accept=csv,txt,zip %PAGE%
REM * wget --save-cookies cookies.txt %WGET_PARAM% --keep-session-cookies --post-data %ACCOUNT% -O NUL https://www.example.com!login
wget --load-cookies cookies.txt %WGET_PARAM% %DOWNLOAD_PARAM%
REM * wget --load-cookies cookies.txt %WGET_PARAM% --post-data="x=1" -O https://www.example.com!logout
Any idea how I get around the --no-check-certificate --secure-protocol=TLSv1 ?
Thanks for any help.
Here is a library that does it and provides an example of how to use it.
https://github.com/axet/wget
I have done what #Andrew Henle has suggested. One issue I had was to get the session-cookie. The solution was to use
httpsConnection.setInstanceFollowRedirects(false);
also this helped:
To be able to see Set-Cookie values in HttpURLConnection.getHeaderFields, one should not set up a CookieManager.
https://bugs.openjdk.java.net/browse/JDK-8036017

Installing JDK on Linux

I’m trying to install JDK on Centos, but I’m getting an error:
[root#www opt]# rpm -ivh /opt/jdk-7u51-linux-x64.rpm
Preparing... ########################################### [100%]
1:jdk ########################################### [100%]
error: unpacking of archive failed on file /usr/java/jdk1.7.0_51/db/lib/derbyLocale_zh_CN.jar;533ab42a: cpio: read
Where can be problem?
Thanks
Can you please check the md5sum of the downloaded file against these values here: http://www.oracle.com/technetwork/java/javase/downloads/java-se-binaries-checksum-1956892.html ?
If the md5sum does not check, it must be a broken download.
A short answer: try downloading and installing again.
A longer answer:
Even though you are getting this, the jdk is getting installed. Sort of. This seems to be an error in the packaging but it is not fatal. Here is the output from my machine. In the example I cat'd the release file so you can see what CentOS I'm using and did an md5sum on the rpm I'm using. You'll notice that it doesn't match the md5sum from the Oracle site link (provided above by Kristof).
Next, I did an ls on the target directory for the jdk /usr/java/ so you can see that it is empty. Then ran the rpm install and did another ls to show that some files are there.
Of course, this defeats the purpose of using rpm, because the install information is not going to go into the rpm database. If I query the database it doesn't come up and it's missing the links that usually get installed pointing to 'latest' and 'default'
So I took a guess that maybe there is a mirror that might have a bad rpm and went to the Oracle site and downloaded the file again. I gave it a different name so that I can compare the two files. This time it was successful.
In the screen shot below you can see the two files. The newest download being the one I called jdk-7u51-linux-x86_64.rpm. You can see the md5sum shows the files are different, but on the new file, the md5 matches the Oracle site. I removed the directory that was created by the failed install and then ran the rpm -ivh command and it completed successfully. The ls on the /usr/java directory shows all the correct stuff and querying the rpm database shows it was installed. Hope this helps!
You can do it with simple script which you can find here
It's for Centos rpm, but you can edit script and change rpm to tar.gz for example
Also you can change version or env in variables bellow
BASE_URL="technetwork/java/javase/downloads"
BASE_URL_OUTPUT="$(curl -s -L0 http://www.oracle.com/${BASE_URL}/)"
JAVA_ENVIRONMENT="JDK"
JAVA_BASE_VERSION=8
DOWNLOAD_SITE="$(echo $BASE_URL_OUTPUT | grep -m 1 -io "${JAVA_ENVIRONMENT}${JAVA_BASE_VERSION}-downloads-[0-9]*.html" -- | tail -1)"
echo "DOWNLOAD_SITE="$DOWNLOAD_SITE
DOWNLOAD_LINK_OUTPUT="$(curl -s -L -j -H "Cookie: oraclelicense=accept-securebackup-cookie" http://www.oracle.com/${BASE_URL}/${DOWNLOAD_SITE} | grep -io "filepath.*${JAVA_ENVIRONMENT}-[${JAVA_BASE_VERSION}].*linux[-_]x64[._].*\(rpm\)" -- | cut -d '"' -f 3 | tail -1)"
echo "DOWNLOAD_LINK_OUTPUT="$DOWNLOAD_LINK_OUTPUT
curl -L -o java_rpm_packet.rpm -b "oraclelicense=a" $DOWNLOAD_LINK_OUTPUT
and install with
yum localinstall -y java_rpm_packet.rpm

Categories

Resources