Class not found exception with com.mysql.jdbc.Driver - mysql

This is my first post and I hoping I can reach out to the group.
I'm pulling my hair out with this problem.
I'm running a EC2 Ubuntu micro instance with LAMP.
I'm using Java with JDBC to access the mysql database.
The issue is that the Java code keeps throwing a "ClassNotFound" Exception when I execute:
Class.forName("com.mysql.jdbc.Driver");
I have installed the following:
sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install libmysql-java
My imports in the Java file are:
import java.text.CharacterIterator;
import java.text.StringCharacterIterator;
import java.util.regex.*;
import java.sql.*;
import java.util.Properties;
import java.net.*;
import java.sql.Connection;
import java.sql.DriverManager;
My $CLASSPATH shows:
.:/usr/share/java/mysql.jar:/usr/share/java/mysql-connector-java.jar:/usr/share/java/mysql.jar:/usr/share/java/mysql-connector-java.jar:/usr/share/java/mysql-5.1.10.jar:/usr/share/java/mysql-connector-java-5.1.10.jar
In /usr/share/java I have:
drwxr-xr-x 3 root root 4096 2012-05-25 02:01 .
drwxr-xr-x 316 root root 12288 2012-05-24 21:21 ..
-rwxrwxrwx 1 root root 448964 2009-11-23 22:38 gnome-java-bridge.jar
-rwxrwxrwx 1 root root 2621 2010-03-05 04:16 libintl.jar
lrwxrwxrwx 1 root root 31 2012-05-25 02:01 mysql-5.1.10.jar -> mysql-connector-java-5.1.10.jar
-rwxrwxrwx 1 root root 754057 2010-01-26 08:02 mysql-connector-java-5.1.10.jar
lrwxrwxrwx 1 root root 31 2012-05-25 02:01 mysql-connector-java.jar -> mysql-connector-java-5.1.10.jar
lrwxrwxrwx 1 root root 16 2012-05-25 02:01 mysql.jar -> mysql-5.1.10.jar
This is the code that always throws up the exception message to an output file:
try {
try {
Class.forName("com.mysql.jdbc.Driver");
outyyy.write("Class loaded \n");
}
catch (ClassNotFoundException e) {
outyyy.write("Class not found! \n");
outyyy.write(e.getMessage() + " \n");
}
this._connection = DriverManager.getConnection(url, this._user, this._pass);
this._isConnected = true;
}
catch (Exception e) {
this._isConnected = false;
}
I'm not sure if it's relevant but I can access and query the database just fine using PHP.
Any assistance is much appreciated.
Thanks, Andy

Set classpath
export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java.jar
Source: http://marksman.wordpress.com/2009/03/01/setting-up-mysqljdbc-driver-on-ubuntu/

Related

Unable to build podman compatiable containers using nix-build and dockerTools.buildImage

The following is invidious.nix, which builds a container that contains nix packages for Bash, Busybox and Invidious:
let
# nixos-22.05 / https://status.nixos.org/
pkgs = import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/d86a4619b7e80bddb6c01bc01a954f368c56d1df.tar.gz") {};
in rec {
docker = pkgs.dockerTools.buildImage {
name = "invidious";
contents = [ pkgs.busybox pkgs.bash pkgs.invidious ];
config = {
Cmd = [ "/bin/bash" ];
Env = [];
Volumes = {};
};
};
}
If I try to load the container with docker load < result, Docker can correctly load the container.
docker load < result
14508d34fd29: Loading layer [==================================================>] 156.6MB/156.6MB
Loaded image: invidious:2nrcdxgz46isccfgyzdcbirs0vvqhp55
However, if I attempt the same thing using podman, I get the following error:
podman load < result
Error: payload does not match any of the supported image formats:
* oci: initializing source oci:/var/tmp/podman3824611648:: open /var/tmp/podman3824611648/index.json: not a directory
* oci-archive: loading index: open /var/tmp/oci1927542201/index.json: no such file or directory
* docker-archive: loading tar component manifest.json: archive/tar: invalid tar header
* dir: open /var/tmp/podman3824611648/manifest.json: not a directory
If I inspect the result, it does appear to have the correct format for an OCI container:
tar tvfz result
dr-xr-xr-x root/root 0 1979-12-31 19:00 ./
-r--r--r-- root/root 391 1979-12-31 19:00 027302622543ef251be6d3f2d616f98c73399d8cd074b0d1497e5a7da5e6c882.json
dr-xr-xr-x root/root 0 1979-12-31 19:00 669db3729b40e36a9153569b747788611e547f0b50a9f7d77107a04c6ddd887e/
-r--r--r-- root/root 3 1979-12-31 19:00 669db3729b40e36a9153569b747788611e547f0b50a9f7d77107a04c6ddd887e/VERSION
-r--r--r-- root/root 353 1979-12-31 19:00 669db3729b40e36a9153569b747788611e547f0b50a9f7d77107a04c6ddd887e/json
-r--r--r-- root/root 156579840 1979-12-31 19:00 669db3729b40e36a9153569b747788611e547f0b50a9f7d77107a04c6ddd887e/layer.tar
-r--r--r-- root/root 280 1979-12-31 19:00 manifest.json
-r--r--r-- root/root 128 1979-12-31 19:00 repositories
How do I get nix-build to create compliant containers that podman can read?
nix-build version: 2.10.3
podman version: 4.2.0
It turns out, the version of podman I'm running can't read gzipped tar files. The following works:
zcat result | podman load

Mysql will not install due to mariadb install but mariadb is not installed

Been trying for hours to get mysql installed but it failed due to a conflict.
This is a brand newly installed CentOS 8 x64 (latest) and it's fully updated. There are no custom packages installed this is a minimal install.
This is on a relatively powerful dedicated server with nothing else on it.
I first ran into the issue trying to install CentOS Web Panel. That is the only thing I've done on this server after install and update. The failure of centos web panel was simply the same conflict I'm running into with mysql. Mysql failed because it says mariadb is installed. But even when I removed mariadb still it gave the same issue.
Same issue happens when I try to install mysql directly which is what this question is about. I am able to install mariadb with no problem though and even remove it as well. But still after installing and removing mariadb mysql still refuses due to nonexistent conflict.
# rpm -q centos-release
centos-release-8.0-0.1905.0.9.el8..x86_64
# yum update -y
Last metadata expiration check: 0:14:30 ago on Sat 23 Nov 2019 02:12:39 PM EST.
Dependencies resolved.
Nothing to do.
Complete!
Here is what happens when I try to install
# yum install mysql -y
CentOS Web Panel repo for Linux 7 - .x86_64 10 kB/s | 2.9 kB 00:00
CentOS-8 - AppStream3.1 kB/s | 4.3 kB 00:01
CentOS-8 - Base 2.9 kB/s | 3.9 kB 00:01
CentOS-8 - Extras 4.3 kB/s | 1.5 kB 00:00
Extra Packages for Enterprise Linux 8 - .x86_64 15 kB/s | 19 kB 00:01
MariaDB 2.6 kB/s | 2.9 kB 00:01
Dependencies resolved.
================================================================================
Package ArchVersion Repository Size
================================================================================
Installing:
mysql .x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream 11 M
Installing dependencies:
mysql-common.x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream 143 k
MariaDB-common .x86_64 10.1.43-1.el7.centos mariadb 68 k
Transaction Summary
================================================================================
Install 3 Packages
Total download size: 11 M
Installed size: 68 M
Downloading Packages:
(1/3): mysql-common-8.0.17-3.module_el8.0.0+181 1.3 MB/s | 143 kB 00:00
(2/3): MariaDB-common-10.1.43-1.el7.centos.x86_ 233 kB/s | 68 kB 00:00
(3/3): mysql-8.0.17-3.module_el8.0.0+181+899d63 9.8 MB/s | 11 MB 00:01
--------------------------------------------------------------------------------
Total 7.6 MB/s | 11 MB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Transaction check error:
file /usr/share/mysql/charsets/Index.xml conflicts between attempted installs of mysql-common-8.0.17-3.module_el8.0.0+181+899d6349..x86_64 and MariaDB-common-10.1.43-1.el7.centos..x86_64
file /usr/share/mysql/charsets/armscii8.xml ... (same)
file /usr/share/mysql/charsets/ascii.xml ...
file /usr/share/mysql/charsets/cp1250.xml ...
file /usr/share/mysql/charsets/cp1251.xml ...
file /usr/share/mysql/charsets/cp1256.xml ...
file /usr/share/mysql/charsets/cp1257.xml ...
file /usr/share/mysql/charsets/cp850.xml ...
file /usr/share/mysql/charsets/cp852.xml ...
file /usr/share/mysql/charsets/cp866.xml ...
file /usr/share/mysql/charsets/dec8.xml ...
file /usr/share/mysql/charsets/geostd8.xml ...
file /usr/share/mysql/charsets/greek.xml ...
file /usr/share/mysql/charsets/hebrew.xml ...
file /usr/share/mysql/charsets/hp8.xml ...
file /usr/share/mysql/charsets/keybcs2.xml ...
file /usr/share/mysql/charsets/koi8r.xml ...
file /usr/share/mysql/charsets/koi8u.xml ...
file /usr/share/mysql/charsets/latin1.xml ...
file /usr/share/mysql/charsets/latin2.xml ...
file /usr/share/mysql/charsets/latin5.xml ...
file /usr/share/mysql/charsets/latin7.xml ...
file /usr/share/mysql/charsets/macce.xml ...
file /usr/share/mysql/charsets/macroman.xml ...
file /usr/share/mysql/charsets/swe7.xml ...
Error Summary
-------------
Problem is that mariadb is not installed. I uninstalled it. Even tried rebooting server to no avail. yum package list does not show either mysql or mariadb to be installed.
# yum remove -y mariadb
No match for argument: mariadb
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!
# rpm -e mariadb
error: package mariadb is not installed
# rpm -V mariadb
package mariadb is not installed
# yum remove mysql -y
No match for argument: mysql
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!
# yum remove mysql-common
No match for argument: mysql-common
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!
# package-cleanup --cleandupes
Last metadata expiration check: 0:07:50 ago on Sat 23 Nov 2019 02:12:39 PM EST.
Error: No duplicated packages found for removal.
# dnf clean packages
0 files removed
# yum list installed | grep mariadb
#
# yum list installed | grep mysql
#
as you see there's nothing there. Even rebooted. Tried installing again same error as above.
Here is my full package list:
~# yum list installed
Installed Packages
NetworkManager..x86_64
NetworkManager-libnm..x86_64
NetworkManager-team..x86_64
NetworkManager-tui..x86_64
PackageKit..x86_64
PackageKit-glib..x86_64
acl..x86_64
adcli..x86_64
apr..x86_64
apr-util..x86_64
at..x86_64
attr..x86_64
audit..x86_64
audit-libs..x86_64
authselect..x86_64
authselect-compat..x86_64
authselect-libs..x86_64
avahi-libs..x86_64
basesystem.noarch11-5.el8
bash..x86_64
bash-completion.noarch 1:2.7-5.el8
bc..x86_64
bind-export-libs..x86_64
bind-libs..x86_64
bind-libs-lite..x86_64
bind-license.noarch 32:9.11.4-17.P2.el8_0.1 #AppStream
bind-utils..x86_64
binutils..x86_64
biosdevname..x86_64
blktrace..x86_64
bpftool..x86_64
brotli..x86_64
bzip2..x86_64
bzip2-libs..x86_64
c-ares..x86_64
ca-certificates.noarch 2018.2.24-6.el8
cairo..x86_64
cairo-gobject..x86_64
centos-logos..x86_64
centos-release..x86_64
checkpolicy..x86_64
chkconfig..x86_64
chrony..x86_64
cockpit..x86_64
cockpit-bridge..x86_64
cockpit-packagekit.noarch184.1-1.el8
cockpit-system.noarch185.1-1.el8_0
cockpit-ws..x86_64
compat-openssl10..x86_64
coreutils..x86_64
coreutils-common..x86_64
cpio..x86_64
cracklib..x86_64
cracklib-dicts..x86_64
cronie..x86_64
cronie-anacron..x86_64
crontabs.noarc
crypto-policies.noarch
cryptsetup..x86_64
cryptsetup-libs..x86_64
cups-libs..x86_64
curl..x86_64
cwp-httpd..x86_64
cwp-suphp..x86_64
cyrus-sasl-gssapi..x86_64
cyrus-sasl-lib..x86_64
cyrus-sasl-plain..x86_64
dbus..x86_64
dbus-common.noarch 1:1.12.8-7.el8
dbus-daemon..x86_64
dbus-glib..x86_64
dbus-libs..x86_64
dbus-tools..x86_64
dejavu-fonts-common.noarch 2.35-6.el8
dejavu-sans-fonts.noarch 2.35-6.el8
desktop-file-utils..x86_64
device-mapper..x86_64
device-mapper-event..x86_64
device-mapper-event-libs..x86_64
device-mapper-libs..x86_64
device-mapper-persistent-data..x86_64
dhcp-client..x86_64
dhcp-common.noarch 12:4.3.6-30.el8
dhcp-libs..x86_64
diffutils..x86_64
dmidecode..x86_64
dnf.noarch
dnf-data.noarch
dnf-plugin-spacewalk.noarch
dnf-plugins-core.noarch
dnf-utils.noarch
dos2unix..x86_64
dosfstools..x86_64
dracut..x86_64
dracut-config-rescue..x86_64
dracut-network..x86_64
dracut-squash..x86_64
dwz..x86_64
e2fsprogs..x86_64
e2fsprogs-libs..x86_64
ed..x86_64
efi-srpm-macros.noarch 3-2.el8
elfutils-default-yama-scope.noarch 0.174-6.el8
elfutils-libelf..x86_64
elfutils-libs..x86_64
emacs-filesystem.noarch 1:26.1-5.el8
epel-release.noarch 8-7.el8 #epel
ethtool..x86_64
expat..x86_64
file..x86_64
file-libs..x86_64
filesystem..x86_64
findutils..x86_64
fipscheck..x86_64
fipscheck-lib..x86_64
firewalld.noarch
firewalld-filesystem.noarch
fontconfig..x86_64
fontpackages-filesystem.noarch
fprintd..x86_64
fprintd-pam..x86_64
freetype..x86_64
fuse-libs..x86_64
gawk..x86_64
gdbm..x86_64
gdbm-libs..x86_64
gdk-pixbuf2..x86_64
geolite2-city.noarch 20180605-1.el8
geolite2-country.noarch 20180605-1.el8
gettext..x86_64
gettext-libs..x86_64
ghc-srpm-macros.noarch 1.4.2-7.el8
glib-networking..x86_64
glib2..x86_64
glibc..x86_64
glibc-common..x86_64
glibc-langpack-en..x86_64
gmp..x86_64
gnupg2..x86_64
gnupg2-smime..x86_64
gnutls..x86_64
go-srpm-macros.noarch2-16.el8
gobject-introspection..x86_64
gpgme..x86_64
gpm-libs..x86_64
grep..x86_64
groff-base..x86_64
grub2-common.noarch
grub2-pc..x86_64
grub2-pc-modules.noarch
grub2-tools..x86_64
grub2-tools-efi..x86_64
grub2-tools-extra..x86_64
grub2-tools-minimal..x86_64
grubby..x86_64
gsettings-desktop-schemas..x86_64
gzip..x86_64
hardlink..x86_64
hdparm..x86_64
hostname..x86_64
hwdata.noarch0.314-8.0.el8
ima-evm-utils..x86_64
info..x86_64
initscripts..x86_64
insights-client.noarch 3.0.5-4.el8
ipcalc..x86_64
iproute..x86_64
iprutils..x86_64
ipset..x86_64
ipset-libs..x86_64
iptables..x86_64
iptables-ebtables..x86_64
iptables-libs..x86_64
iptstate..x86_64
iputils..x86_64
irqbalance..x86_64
iwl100-firmware.noarch
iwl1000-firmware.noarch
iwl105-firmware.noarch
iwl135-firmware.noarch
iwl2000-firmware.noarch 18.168.6.1-92.el8.1 #anaconda
iwl2030-firmware.noarch 18.168.6.1-92.el8.1 #anaconda
iwl3160-firmware.noarch 1:25.30.13.0-92.el8.1#anaconda
iwl3945-firmware.noarch 15.32.2.9-92.el8.1 #anaconda
iwl4965-firmware.noarch 228.61.2.24-92.el8.1 #anaconda
iwl5000-firmware.noarch 8.83.5.1_1-92.el8.1 #anaconda
iwl5150-firmware.noarch 8.24.2.2-92.el8.1
iwl6000-firmware.noarch 9.221.4.1-92.el8.1 #anaconda
iwl6000g2a-firmware.noarch 18.168.6.1-92.el8.1 #anaconda
iwl6050-firmware.noarch 41.28.5.1-92.el8.1 #anaconda
iwl7260-firmware.noarch 1:25.30.13.0-92.el8.1#anaconda
jansson..x86_64
json-c..x86_64
json-glib..x86_64
kbd..x86_64
kbd-legacy.noarch2.0.4-8.el8
kbd-misc.noarch 2.0.4-8.el8
kernel..x86_64
kernel..x86_64
kernel-core..x86_64
kernel-core..x86_64
kernel-modules..x86_64
kernel-modules..x86_64
kernel-tools..x86_64
kernel-tools-libs..x86_64
kexec-tools..x86_64
keyutils-libs..x86_64
kmod..x86_64
kmod-kvdo..x86_64
kmod-libs..x86_64
kpartx..x86_64
kpatch.noarch0.6.1-1.el8
krb5-libs..x86_64
langpacks-en.noarch 1.0-12.el8
ledmon..x86_64
less..x86_64
libX11..x86_64
libX11-common.noarch 1.6.7-1.el8
libXau..x86_64
libXext..x86_64
libXrender..x86_64
libacl..x86_64
libaio..x86_64
libappstream-glib..x86_64
libarchive..x86_64
libassuan..x86_64
libattr..x86_64
libbasicobjects..x86_64
libblkid..x86_64
libcap..x86_64
libcap-ng..x86_64
libcollection..x86_64
libcom_err..x86_64
libcomps..x86_64
libconfig..x86_64
libcroco..x86_64
libcurl..x86_64
libdaemon..x86_64
libdb..x86_64
libdb-utils..x86_64
libdhash..x86_64
libdnf..x86_64
libedit..x86_64
libestr..x86_64
libevent..x86_64
libfastjson..x86_64
libfdisk..x86_64
libffi..x86_64
libfprint..x86_64
libgcc..x86_64
libgcrypt..x86_64
libgomp..x86_64
libgpg-error..x86_64
libgudev..x86_64
libidn2..x86_64
libini_config..x86_64
libipa_hbac..x86_64
libkcapi..x86_64
libkcapi-hmaccalc..x86_64
libksba..x86_64
libldb..x86_64
libmaxminddb..x86_64
libmetalink..x86_64
libmnl..x86_64
libmodman..x86_64
libmodulemd1..x86_64
libmount..x86_64
libndp..x86_64
libnetfilter_conntrack..x86_64
libnfnetlink..x86_64
libnfsidmap..x86_64
libnftnl..x86_64
libnghttp2..x86_64
libnl3..x86_64
libnl3-cli..x86_64
libnsl2..x86_64
libpath_utils..x86_64
libpcap..x86_64
libpipeline..x86_64
libpkgconf..x86_64
libpng..x86_64
libpq..x86_64
libproxy..x86_64
libpsl..x86_64
libpwquality..x86_64
libref_array..x86_64
librelp..x86_64
librepo..x86_64
libreport-filesystem..x86_64
libseccomp..x86_64
libsecret..x86_64
libselinux..x86_64
libselinux-utils..x86_64
libsemanage..x86_64
libsepol..x86_64
libsigsegv..x86_64
libsmartcols..x86_64
libsmbclient..x86_64
libsolv..x86_64
libsoup..x86_64
libss..x86_64
libssh..x86_64
libsss_autofs..x86_64
libsss_certmap..x86_64
libsss_idmap..x86_64
libsss_nss_idmap..x86_64
libsss_sudo..x86_64
libstdc++..x86_64
libstemmer..x86_64
libstoragemgmt..x86_64
libsysfs..x86_64
libtalloc..x86_64
libtasn1..x86_64
libtdb..x86_64
libteam..x86_64
libtevent..x86_64
libtirpc..x86_64
libunistring..x86_64
libusbx..x86_64
libuser..x86_64
libutempter..x86_64
libuuid..x86_64
libverto..x86_64
libwbclient..x86_64
libxcb..x86_64
libxcrypt..x86_64
libxkbcommon..x86_64
libxml2..x86_64
libyaml..x86_64
linux-firmware.noarch20190111-92.gitd9fb2ee6.el8 #anaconda
logrotate..x86_64
lshw..x86_64
lsof..x86_64
lsscsi..x86_64
lua-libs..x86_64
lvm2..x86_64
lvm2-libs..x86_64
lz4-libs..x86_64
lzo..x86_64
mailcap.noarch 2.1.48-3.el8
make..x86_64
man-db..x86_64
man-pages..x86_64
mcelog..x86_64
mdadm..x86_64
microcode_ctl..x86_64
mlocate..x86_64
mozjs52..x86_64
mpfr..x86_64
mtr..x86_64
nano..x86_64
ncurses..x86_64
ncurses-base.noarch 6.1-7.20180224.el8 #anaconda
ncurses-libs..x86_64
net-tools..x86_64
nettle..x86_64
newt..x86_64
nftables..x86_64
nmap-ncat..x86_64
npth..x86_64
nspr..x86_64
nss..x86_64
nss-softokn..x86_64
nss-softokn-freebl..x86_64
nss-sysinit..x86_64
nss-util..x86_64
numactl-libs..x86_64
ocaml-srpm-macros.noarch 5-4.el8
openblas-srpm-macros.noarch 2-2.el8
openldap..x86_64
openssh..x86_64
openssh-clients..x86_64
openssh-server..x86_64
openssl..x86_64
openssl-libs..x86_64
openssl-pkcs11..x86_64
os-prober..x86_64
p11-kit..x86_64
p11-kit-trust..x86_64
p7zip..x86_64
p7zip-plugins..x86_64
pam..x86_64
parted..x86_64
passwd..x86_64
pciutils..x86_64
pciutils-libs..x86_64
pcre..x86_64
pcre2..x86_64
perl..x86_64
perl-Algorithm-Diff.noarch 1.1903-9.el8
perl-Archive-Tar.noarch 2.30-1.el8
perl-Archive-Zip.noarch 1.60-3.el8
perl-Attribute-Handlers.noarch 0.99-416.el8
perl-B-Debug.noarch 1.26-2.el8
perl-CPAN.noarch 2.18-397.el8
perl-CPAN-Meta.noarch2.150010-396.el8
perl-CPAN-Meta-Requirements.noarch 2.140-396.el8
perl-CPAN-Meta-YAML.noarch 0.018-397.el8
perl-Carp.noarch 1.42-396.el8
perl-Compress-Bzip2..x86_64
perl-Compress-Raw-Bzip2..x86_64
perl-Compress-Raw-Zlib..x86_64
perl-Config-Perl-V.noarch0.30-1.el8
perl-DB_File..x86_64
perl-Data-Dumper..x86_64
perl-Data-OptList.noarch 0.110-6.el8
perl-Data-Section.noarch 0.200007-3.el8
perl-Devel-PPPort..x86_64
perl-Devel-Peek..x86_64
perl-Devel-SelfStubber.noarch1.06-416.el8
perl-Devel-Size..x86_64
perl-Digest.noarch 1.17-395.el8
perl-Digest-MD5..x86_64
perl-Digest-SHA..x86_64
perl-Encode..x86_64
perl-Encode-Locale.noarch1.05-9.el8
perl-Encode-devel..x86_64
perl-Env.noarch 1.04-395.el8
perl-Errno..x86_64
perl-Exporter.noarch 5.72-396.el8
perl-ExtUtils-CBuilder.noarch1:0.280230-2.el8
perl-ExtUtils-Command.noarch 1:7.34-1.el8
perl-ExtUtils-Embed.noarch 1.34-416.el8
perl-ExtUtils-Install.noarch 2.14-4.el8
perl-ExtUtils-MM-Utils.noarch1:7.34-1.el8
perl-ExtUtils-MakeMaker.noarch 1:7.34-1.el8
perl-ExtUtils-Manifest.noarch1.70-395.el8
perl-ExtUtils-Miniperl.noarch1.06-416.el8
perl-ExtUtils-ParseXS.noarch 1:3.35-2.el8
perl-File-Fetch.noarch 0.56-2.el8
perl-File-HomeDir.noarch 1.002-4.el8
perl-File-Path.noarch2.15-2.el8
perl-File-Temp.noarch0.230.600-1.el8
perl-File-Which.noarch 1.22-2.el8
perl-Filter..x86_64
perl-Filter-Simple.noarch0.94-2.el8
perl-Getopt-Long.noarch 1:2.50-4.el8
perl-HTTP-Tiny.noarch0.074-1.el8
perl-IO..x86_64
perl-IO-Compress.noarch 2.081-1.el8
perl-IO-Socket-IP.noarch 0.39-5.el8
perl-IO-Socket-SSL.noarch2.060-2.el8
perl-IO-Zlib.noarch 1:1.10-416.el8
perl-IPC-Cmd.noarch 2:1.02-1.el8
perl-IPC-SysV..x86_64
perl-IPC-System-Simple.noarch1.25-17.el8
perl-JSON-PP.noarch 1:2.97.001-3.el8
perl-Locale-Codes.noarch 3.57-1.el8
perl-Locale-Maketext.noarch 1.28-396.el8
perl-Locale-Maketext-Simple.noarch 1:0.21-416.el8
perl-MIME-Base64..x86_64
perl-MRO-Compat.noarch 0.13-4.el8
perl-Math-BigInt.noarch 1:1.9998.11-5.el8
perl-Math-BigInt-FastCalc..x86_64
perl-Math-BigRat.noarch 0.2614-1.el8
perl-Math-Complex.noarch 1.59-416.el8
perl-Memoize.noarch 1.03-416.el8
perl-Module-Build.noarch 2:0.42.24-5.el8
perl-Module-CoreList.noarch 1:5.20181130-1.el8
perl-Module-CoreList-tools.noarch1:5.20181130-1.el8
perl-Module-Load.noarch 1:0.32-395.el8
perl-Module-Load-Conditional.noarch 0.68-395.el8
perl-Module-Loaded.noarch1:0.08-416.el8
perl-Module-Metadata.noarch 1.000033-395.el8
perl-Mozilla-CA.noarch 20160104-7.el8
perl-Net-Ping.noarch 2.55-416.el8
perl-Net-SSLeay..x86_64
perl-Package-Generator.noarch1.106-11.el8
perl-Params-Check.noarch 1:0.38-395.el8
perl-Params-Util..x86_64
perl-PathTools..x86_64
perl-Perl-OSType.noarch 1.010-396.el8
perl-PerlIO-via-QuotedPrint.noarch 0.08-395.el8
perl-Pod-Checker.noarch 4:1.73-395.el8
perl-Pod-Escapes.noarch 1:1.07-395.el8
perl-Pod-Html.noarch 1.22.02-416.el8
perl-Pod-Parser.noarch 1.63-396.el8
perl-Pod-Perldoc.noarch 3.28-396.el8
perl-Pod-Simple.noarch 1:3.35-395.el8
perl-Pod-Usage.noarch4:1.69-395.el8
perl-Scalar-List-Utils..x86_64
perl-SelfLoader.noarch 1.23-416.el8
perl-Socket..x86_64
perl-Software-License.noarch 0.103013-2.el8
perl-Storable..x86_64
perl-Sub-Exporter.noarch 0.987-15.el8
perl-Sub-Install.noarch 0.928-14.el8
perl-Sys-Syslog..x86_64
perl-Term-ANSIColor.noarch 4.06-396.el8
perl-Term-Cap.noarch 1.17-395.el8
perl-TermReadKey..x86_64
perl-Test.noarch 1.30-416.el8
perl-Test-Harness.noarch 1:3.42-1.el8
perl-Test-Simple.noarch 1:1.302135-1.el8
perl-Text-Balanced.noarch2.03-395.el8
perl-Text-Diff.noarch1.45-2.el8
perl-Text-Glob.noarch0.11-4.el8
perl-Text-ParseWords.noarch 3.30-395.el8
perl-Text-Tabs+Wrap.noarch 2013.0523-395.el8
perl-Text-Template.noarch1.51-1.el8
perl-Thread-Queue.noarch 3.13-1.el8
perl-Time-HiRes..x86_64
perl-Time-Local.noarch 1:1.280-1.el8
perl-Time-Piece..x86_64
perl-URI.noarch 1.73-3.el8
perl-Unicode-Collate..x86_64
perl-Unicode-Normalize..x86_64
perl-autodie.noarch 2.29-396.el8
perl-bignum.noarch 0.49-2.el8
perl-constant.noarch 1.33-396.el8
perl-devel..x86_64
perl-encoding..x86_64
perl-experimental.noarch 0.019-2.el8
perl-inc-latest.noarch 2:0.500-9.el8
perl-interpreter..x86_64
perl-libnet.noarch 3.11-3.el8
perl-libnetcfg.noarch4:5.26.3-416.el8
perl-libs..x86_64
perl-local-lib.noarch2.000024-2.el8
perl-macros..x86_64
perl-open.noarch 1.11-416.el8
perl-parent.noarch 1:0.237-1.el8
perl-perlfaq.noarch 5.20180605-1.el8
perl-podlators.noarch4.11-1.el8
perl-srpm-macros.noarch 1-25.el8
perl-threads..x86_64
perl-threads-shared..x86_64
perl-utils.noarch5.26.3-416.el8
perl-version..x86_64
pigz..x86_64
pinentry..x86_64
pinfo..x86_64
pixman..x86_64
pkgconf..x86_64
pkgconf-m4.noarch1.4.2-1.el8
pkgconf-pkg-config..x86_64
platform-python..x86_64
platform-python-pip.noarch 9.0.3-13.el8
platform-python-setuptools.noarch39.2.0-4.el8
plymouth..x86_64
plymouth-core-libs..x86_64
plymouth-scripts..x86_64
policycoreutils..x86_64
policycoreutils-python-utils.noarch 2.8-16.1.el8
polkit..x86_64
polkit-libs..x86_64
polkit-pkla-compat..x86_64
popt..x86_64
prefixdevname..x86_64
procps-ng..x86_64
psacct..x86_64
publicsuffix-list-dafsa.noarch 20180723-1.el8
python-srpm-macros.noarch3-37.el8
python3-asn1crypto.noarch0.24.0-3.el8
python3-audit..x86_64
python3-bind.noarch 32:9.11.4-17.P2.el8_0.1 #AppStream
python3-cairo..x86_64
python3-cffi..x86_64
python3-chardet.noarch 3.0.4-7.el8
python3-configobj.noarch 5.0.6-11.el8
python3-cryptography..x86_64
python3-dateutil.noarch 1:2.6.1-6.el8
python3-dbus..x86_64
python3-decorator.noarch 4.2.1-2.el8
python3-dmidecode..x86_64
python3-dnf.noarch 4.0.9.2-5.el8
python3-dnf-plugin-spacewalk.noarch 2.8.5-11.module_el8.0.0+180+337688dc
python3-dnf-plugins-core.noarch 4.0.2.2-3.el8
python3-firewall.noarch 0.6.3-7.el8
python3-gobject..x86_64
python3-gobject-base..x86_64
python3-gpg..x86_64
python3-hawkey..x86_64
python3-hwdata.noarch2.3.6-3.el8
python3-idna.noarch 2.5-5.el8
python3-iniparse.noarch 0.4-31.el8
python3-libcomps..x86_64
python3-libdnf..x86_64
python3-librepo..x86_64
python3-libs..x86_64
python3-libselinux..x86_64
python3-libsemanage..x86_64
python3-libstoragemgmt.noarch1.6.2-9.el8
python3-libstoragemgmt-clibs..x86_64
python3-libxml2..x86_64
python3-linux-procfs.noarch 0.6-6.el8
python3-magic.noarch 5.33-8.el8
python3-netifaces..x86_64
python3-newt..x86_64
python3-perf..x86_64
python3-ply.noarch 3.9-7.el8
python3-policycoreutils.noarch 2.8-16.1.el8
python3-pyOpenSSL.noarch 18.0.0-1.el8
python3-pycparser.noarch 2.14-14.el8
python3-pyparsing.noarch 2.1.10-7.el8
python3-pysocks.noarch 1.6.8-3.el8
python3-pyudev.noarch0.21.0-7.el8
python3-pyyaml..x86_64
python3-requests.noarch 2.20.0-1.el8
python3-rhn-client-tools..x86_64
python3-rhnlib.noarch2.8.6-8.module_el8.0.0+180+337688dc
python3-rpm..x86_64
python3-rpm-macros.noarch3-37.el8
python3-schedutils..x86_64
python3-setools..x86_64
python3-six.noarch 1.11.0-8.el8
python3-slip.noarch 0.6.4-11.el8
python3-slip-dbus.noarch 0.6.4-11.el8
python3-sssdconfig.noarch2.0.0-43.el8_0.3
python3-syspurpose..x86_64
python3-systemd..x86_64
python3-unbound..x86_64
python3-urllib3.noarch 1.23-5.el8
qt5-srpm-macros.noarch 5.11.1-2.el8
quota..x86_64
quota-nls.noarch 1:4.04-10.el8
readline..x86_64
realmd..x86_64
redhat-rpm-config.noarch 116-1.el8.0.1
rhn-client-tools..x86_64
rng-tools..x86_64
rootfiles.noarch 8.1-22.el8
rpm..x86_64
rpm-build-libs..x86_64
rpm-libs..x86_64
rpm-plugin-selinux..x86_64
rpm-plugin-systemd-inhibit..x86_64
rsync..x86_64
rsyslog..x86_64
rsyslog-gnutls..x86_64
rsyslog-gssapi..x86_64
rsyslog-relp..x86_64
rust-srpm-macros.noarch 5-2.el8
samba-client-libs..x86_64
samba-common.noarch 4.9.1-8.el8
samba-common-libs..x86_64
screen..x86_64
sed..x86_64
selinux-policy.noarch3.14.1-61.el8_0.2
selinux-policy-targeted.noarch 3.14.1-61.el8_0.2
setroubleshoot-plugins.noarch3.3.10-1.el8
setroubleshoot-server..x86_64
setup.noarch 2.12.2-2.el8
sg3_utils..x86_64
sg3_utils-libs..x86_64
shadow-utils..x86_64
shared-mime-info..x86_64
slang..x86_64
smartmontools..x86_64
snappy..x86_64
sos.noarch 3.6-10.el8_0.3
sqlite..x86_64
sqlite-libs..x86_64
squashfs-tools..x86_64
sscg..x86_64
sssd..x86_64
sssd-ad..x86_64
sssd-client..x86_64
sssd-common..x86_64
sssd-common-pac..x86_64
sssd-ipa..x86_64
sssd-kcm..x86_64
sssd-krb5..x86_64
sssd-krb5-common..x86_64
sssd-ldap..x86_64
sssd-nfs-idmap..x86_64
sssd-proxy..x86_64
strace..x86_64
sudo..x86_64
symlinks..x86_64
systemd..x86_64
systemd-libs..x86_64
systemd-pam..x86_64
systemd-udev..x86_64
systemtap-sdt-devel..x86_64
tar..x86_64
tcpdump..x86_64
teamd..x86_64
time..x86_64
timedatex..x86_64
tree..x86_64
trousers..x86_64
trousers-lib..x86_64
tuned.noarch 2.10.0-15.el8
tzdata.noarch2019a-1.el8
unbound-libs..x86_64
unzip..x86_64
usbutils..x86_64
util-linux..x86_64
util-linux-user..x86_64
vdo..x86_64
vim-common..x86_64
vim-enhanced..x86_64
vim-filesystem.noarch2:8.0.1763-10.el8
vim-minimal..x86_64
virt-what..x86_64
wget..x86_64
which..x86_64
words.noarch 3.0-28.el8
xdg-utils.noarch 1.1.2-5.el8
xfsdump..x86_64
xfsprogs..x86_64
xkeyboard-config.noarch 2.24-3.el8
xz..x86_64
xz-libs..x86_64
yum.noarch 4.0.9.2-5.el8
zip..x86_64
zlib..x86_64
Additionally mariadb-libs is NOT installed.
# yum remove mariadb-libs -y
No match for argument: mariadb-libs
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!
So removing maria-libs is not the solution unlike another question which proposes that.
Also tried to remove any extraneous files/folders.
rm -f /var/log/mariadb
rm -f /var/log/mariadb/mariadb.log.rpmsave
rm -rf /var/lib/mysql
rm -rf /usr/lib64/mysql
rm -rf /usr/share/mysql
No luck. Same error like it exists even though it does not exist and it is not installed.
Last attempt: trying to install with mariadb reinstalled also fails
Lastly, I tried one more thing, which is to, after doing all this, then trying to install mariadb and then try installing mysql,
~# yum install mariadb -y
Last metadata expiration check: 0:02:02 ago on Sat 23 Nov 2019 02:51:37 PM EST.
Dependencies resolved.
...
Installed:
mariadb-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64
mariadb-common-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64
mariadb-connector-c-3.0.7-1.el8.x86_64
MariaDB-common-10.1.43-1.el7.centos.x86_64
Complete!
And mariadb installs fine, but mysql still doesn't install. It gives a different error, but this is because mariadb is installed in this case. If I remove mariadb again, it gives the original error again like above.
# yum install mysql -y
Last metadata expiration check: 0:02:18 ago on Sat 23 Nov 2019 02:51:37 PM EST.
Error:
Problem: problem with installed package mariadb-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64
- package mariadb-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64 conflicts with mysql provided by mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64
- package mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 conflicts with mariadb provided by mariadb-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64
- conflicting requests
- package MariaDB-client-10.1.40-1.el7.centos.x86_64 is excluded
- package MariaDB-client-10.1.41-1.el7.centos.x86_64 is excluded
- package MariaDB-client-10.1.43-1.el7.centos.x86_64 is excluded
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
#
I also tried the --nobest flag but that does nothing, and I tried the --skip-broken flag but then it installs nothing either since it thinks it's broken.
I also tried installing mysql-server but no luck on that either.
# yum install mysql-server
Last metadata expiration check: 0:04:49 ago on Sat 23 Nov 2019 02:51:37 PM EST.
Error:
Problem: problem with installed package mariadb-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64
- package mariadb-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64 conflicts with mysql provided by mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64
- package mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 conflicts with mariadb provided by mariadb-3:10.3.11-2.module_el8.0.0+35+6f2527ed.x86_64
- package mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64 requires mysql(x86-64), but none of the providers can be installed
- conflicting requests
- package mysql-8.0.13-1.module_el8.0.0+41+ca30bab6.x86_64 is excluded
- package MariaDB-client-10.1.40-1.el7.centos.x86_64 is excluded
- package MariaDB-client-10.1.41-1.el7.centos.x86_64 is excluded
- package MariaDB-client-10.1.43-1.el7.centos.x86_64 is excluded
#
Please help me solve this issue, thank you.
Try install mysql-server instead using: yum install mysql-server
I suspect you are suffering from the issue caused by MariaDB bug for InnoDB fails to start when fts table has FK relation as reported here: MDEV-20987
For quick relief from this problem, the only way to fix this issue is by downgrading the installation. Use following command to downgrade.
yum downgrade MariaDB-server MariaDB-common MariaDB-shared MariaDB-client MariaDB-compat MariaDB-devel
NOTE: Officially MariaDB has fixed the issue in the following unpublished versions:
10.1.43 [ 23703 ]
10.2.29 [ 23911 ]
10.3.20 [ 23909 ]
10.4.10 [ 23907 ]

JDBC: SunCertPathBuilderException: unable to find valid certification path to requested target [duplicate]

I have a class that will download a file from a https server. When I run it, it returns a lot of errors. It seems that I have a problem with my certificate. Is it possible to ignore the client-server authentication? If so, how?
package com.da;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.CharBuffer;
import java.util.concurrent.Future;
import org.apache.http.HttpResponse;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.impl.nio.client.DefaultHttpAsyncClient;
import org.apache.http.nio.IOControl;
import org.apache.http.nio.client.HttpAsyncClient;
import org.apache.http.nio.client.methods.AsyncCharConsumer;
import org.apache.http.nio.client.methods.HttpAsyncGet;
import org.apache.http.nio.client.methods.HttpAsyncPost;
public class RSDDownloadFile {
static FileOutputStream fos;
public void DownloadFile(String URI, String Request) throws Exception
{
java.net.URI uri = URIUtils.createURI("https", "176.66.3.69:6443", -1, "download.aspx",
"Lang=EN&AuthToken=package", null);
System.out.println("URI Query: " + uri.toString());
HttpAsyncClient httpclient = new DefaultHttpAsyncClient();
httpclient.start();
try {
Future<Boolean> future = httpclient.execute(
new HttpAsyncGet(uri),
new ResponseCallback(), null);
Boolean result = future.get();
if (result != null && result.booleanValue()) {
System.out.println("\nRequest successfully executed");
} else {
System.out.println("Request failed");
}
}
catch(Exception e){
System.out.println("[DownloadFile] Exception: " + e.getMessage());
}
finally {
System.out.println("Shutting down");
httpclient.shutdown();
}
System.out.println("Done");
}
static class ResponseCallback extends AsyncCharConsumer<Boolean> {
#Override
protected void onResponseReceived(final HttpResponse response) {
System.out.println("Response: " + response.getStatusLine());
System.out.println("Header: " + response.toString());
try {
//if(response.getStatusLine().getStatusCode()==200)
fos = new FileOutputStream( "Response.html" );
}catch(Exception e){
System.out.println("[onResponseReceived] Exception: " + e.getMessage());
}
}
#Override
protected void onCharReceived(final CharBuffer buf, final IOControl ioctrl) throws IOException {
try
{
while (buf.hasRemaining())
{
//System.out.print(buf.get());
fos.write(buf.get());
}
}catch(Exception e)
{
System.out.println("[onCharReceived] Exception: " + e.getMessage());
}
}
#Override
protected void onCleanup() {
try
{
if(fos!=null)
fos.close();
}catch(Exception e){
System.out.println("[onCleanup] Exception: " + e.getMessage());
}
System.out.println("onCleanup()");
}
#Override
protected Boolean buildResult() {
return Boolean.TRUE;
}
}
}
Errors:
URI Query: https://176.66.3.69:6443/download.aspx?Lang=EN&AuthToken=package
Aug 2, 2011 3:47:57 PM org.apache.http.impl.nio.client.NHttpClientProtocolHandler exception
SEVERE: I/O error: General SSLEngine problem
javax.net.ssl.SSLHandshakeException: General SSLEngine problem
at com.sun.net.ssl.internal.ssl.Handshaker.checkThrown(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.checkTaskThrown(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.writeAppRecord(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.wrap(Unknown Source)
at javax.net.ssl.SSLEngine.wrap(Unknown Source)
at org.apache.http.impl.nio.reactor.SSLIOSession.doHandshake(SSLIOSession.java:154)
at org.apache.http.impl.nio.reactor.SSLIOSession.isAppInputReady(SSLIOSession.java:276)
at org.apache.http.impl.nio.client.InternalClientEventDispatch.inputReady(InternalClientEventDispatch.java:79)
at org.apache.http.impl.nio.reactor.BaseIOReactor.readable(BaseIOReactor.java:161)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:335)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:275)
at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:542)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLEngineImpl.fatal(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
at com.sun.net.ssl.internal.ssl.Handshaker$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.net.ssl.internal.ssl.Handshaker$DelegatedTask.run(Unknown Source)
at org.apache.http.impl.nio.reactor.SSLIOSession.doHandshake(SSLIOSession.java:180)
... 9 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(Unknown Source)
at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
at sun.security.validator.Validator.validate(Unknown Source)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(Unknown Source)
... 16 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(Unknown Source)
at java.security.cert.CertPathBuilder.build(Unknown Source)
... 21 more
onCleanup()
[DownloadFile] Exception: javax.net.ssl.SSLHandshakeException: General SSLEngine problem
Shutting down
Done
The problem appears when your server has self signed certificate. To workaround it you can add this certificate to the list of trusted certificates of your JVM.
In this article author describes how to fetch the certificate from your browser and add it to cacerts file of your JVM. You can either edit JAVA_HOME/jre/lib/security/cacerts file or run you application with -Djavax.net.ssl.trustStore parameter. Verify which JDK/JRE you are using too as this is often a source of confusion.
See also: How are SSL certificate server names resolved/Can I add alternative names using keytool? If you run into java.security.cert.CertificateException: No name matching localhost found exception.
Here's what reliably works for me on macOS. Make sure to replace example.com and 443 with the actual hostname and port you're trying to connect to, and give a custom alias. The first command downloads the provided certificate from the remote server and saves it locally in x509 format. The second command loads the saved certificate into Java's SSL trust store.
openssl x509 -in <(openssl s_client -connect example.com:443 -prexit 2>/dev/null) -out ~/example.crt
sudo keytool -importcert -file ~/example.crt -alias example -keystore $(/usr/libexec/java_home)/jre/lib/security/cacerts -storepass changeit
I had the same issue with a valid signed wildcard certificate from symantec.
First try running your java application with -Djavax.net.debug=SSL to see what is really going on.
I ended up importing the intermediate certificate which was causing the cert chain to break.
I downloaded the missing intermediate cert from symantec (you can see the download link to the missing cert in the ssl handshake log: http://svrintl-g3-aia.verisign.com/SVRIntlG3.cer in my case).
And I imported the cert in the java keystore. After importing the intermediate certificate my wildcard ssl cert finally started working:
keytool -import -keystore ../jre/lib/security/cacerts -trustcacerts -alias "VeriSign Class 3 International Server CA - G3" -file /pathto/SVRIntlG3.cer
Export the SSL certificate using Firefox. You can export it by hitting the URL in the browser and then select the option to export the certificate. Let's assume the cert file name is your.ssl.server.name.crt
Go to your JRE_HOME/bin or JDK/JRE/bin
Type the command
keytool -keystore ..\lib\security\cacerts -import -alias your.ssl.server.name -file .\relative-path-to-cert-file\your.ssl.server.name.crt
Restart your Java process
#Gabe Martin-Dempesy's answer is helped to me. And I wrote a small script related to it. The usage is very simple.
Install a certificate from host:
> sudo ./java-cert-importer.sh example.com
Remove the certificate that installed already.
> sudo ./java-cert-importer.sh example.com --delete
java-cert-importer.sh
#!/usr/bin/env bash
# Exit on error
set -e
# Ensure script is running as root
if [ "$EUID" -ne 0 ]
then echo "WARN: Please run as root (sudo)"
exit 1
fi
# Check required commands
command -v openssl >/dev/null 2>&1 || { echo "Required command 'openssl' not installed. Aborting." >&2; exit 1; }
command -v keytool >/dev/null 2>&1 || { echo "Required command 'keytool' not installed. Aborting." >&2; exit 1; }
# Get command line args
host=$1; port=${2:-443}; deleteCmd=${3:-${2}}
# Check host argument
if [ ! ${host} ]; then
cat << EOF
Please enter required parameter(s)
usage: ./java-cert-importer.sh <host> [ <port> | default=443 ] [ -d | --delete ]
EOF
exit 1
fi;
if [ "$JAVA_HOME" ]; then
javahome=${JAVA_HOME}
elif [[ "$OSTYPE" == "linux-gnu" ]]; then # Linux
javahome=$(readlink -f $(which java) | sed "s:bin/java::")
elif [[ "$OSTYPE" == "darwin"* ]]; then # Mac OS X
javahome="$(/usr/libexec/java_home)/jre"
fi
if [ ! "$javahome" ]; then
echo "WARN: Java home cannot be found."
exit 1
elif [ ! -d "$javahome" ]; then
echo "WARN: Detected Java home does not exists: $javahome"
exit 1
fi
echo "Detected Java Home: $javahome"
# Set cacerts file path
cacertspath=${javahome}/lib/security/cacerts
cacertsbackup="${cacertspath}.$$.backup"
if ( [ "$deleteCmd" == "-d" ] || [ "$deleteCmd" == "--delete" ] ); then
sudo keytool -delete -alias ${host} -keystore ${cacertspath} -storepass changeit
echo "Certificate is deleted for ${host}"
exit 0
fi
# Get host info from user
#read -p "Enter server host (E.g. example.com) : " host
#read -p "Enter server port (Default 443) : " port
# create temp file
tmpfile="/tmp/${host}.$$.crt"
# Create java cacerts backup file
cp ${cacertspath} ${cacertsbackup}
echo "Java CaCerts Backup: ${cacertsbackup}"
# Get certificate from speficied host
openssl x509 -in <(openssl s_client -connect ${host}:${port} -prexit 2>/dev/null) -out ${tmpfile}
# Import certificate into java cacerts file
sudo keytool -importcert -file ${tmpfile} -alias ${host} -keystore ${cacertspath} -storepass changeit
# Remove temp certificate file
rm ${tmpfile}
# Check certificate alias name (same with host) that imported successfully
result=$(keytool -list -v -keystore ${cacertspath} -storepass changeit | grep "Alias name: ${host}")
# Show results to user
if [ "$result" ]; then
echo "Success: Certificate is imported to java cacerts for ${host}";
else
echo "Error: Something went wrong";
fi;
Quoting from No more 'unable to find valid certification path to requested target'
when trying to open an SSL connection to a host using JSSE. What this usually means is that the server is using a test certificate (possibly generated using keytool) rather than a certificate from a well known commercial Certification Authority such as Verisign or GoDaddy. Web browsers display warning dialogs in this case, but since JSSE cannot assume an interactive user is present it just throws an exception by default.
Certificate validation is a very important part of SSL security, but I am not writing this entry to explain the details. If you are interested, you can start by reading the Wikipedia blurb. I am writing this entry to show a simple way to talk to that host with the test certificate, if you really want to.
Basically, you want to add the server's certificate to the KeyStore with your trusted certificates
Try the code provided there. It might help.
This solved my issue,
We need to import the cert onto the local java. If not we could get the below exception.
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1949)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:302)
SSLPOKE is a tool where you can test the https connectivity from your local machine.
Command to test the connectivity:
"%JAVA_HOME%/bin/java" SSLPoke <hostname> 443
sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:387)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
at sun.security.validator.Validator.validate(Validator.java:260)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1496)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1026)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:961)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747)
at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:138)
at SSLPoke.main(SSLPoke.java:31)
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to
requested target
at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
... 15 more
keytool -import -alias <anyname> -keystore "%JAVA_HOME%/jre/lib/security/cacerts" -file <cert path>
this would first prompt to "Enter keystore password:" changeit is the default password. and finally a prompt "Trust this certificate? [no]:", provide "yes" to add the cert to keystore.
Verfication:
C:\tools>"%JAVA_HOME%/bin/java" SSLPoke <hostname> 443
Successfully connected
Simple Steps that I followed.
problem: I was trying to connect to an endpoint(https://%s.blob.core.windows.net) using a simple java class(main method).
So I was getting this certification issue as mentioned above, in the question.
Solution:
Get the certificate using a browser(chrome). To do this paste your endpoint URL in the browser and enter. Now you will see a lock icon, click on that -->certificate--> details --> copy to files--> download it.
open the cmd(i am using windows) as admin and then navigate to the directory where you have downloaded the .cer file.
3.(Optional)If you are using multiple JDK in the same machine then change your JDK version the same as you are using in your application.
Now use the below command
keytool -import -alias mycertificate -keystore "C:\Program
Files\Java\jdk-11.0.5\lib\security\cacerts" -file myurlcrt.cer
Give the default password: changeit
Trust this certificate: yes
And you are done.
Thanks!
I was able to get it working with code only, i.e. no need to use keytool:
import com.netflix.config.DynamicBooleanProperty;
import com.netflix.config.DynamicIntProperty;
import com.netflix.config.DynamicPropertyFactory;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.ssl.SSLContexts;
import org.apache.http.conn.ssl.TrustStrategy;
import org.apache.http.conn.ssl.X509HostnameVerifier;
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
import org.apache.http.impl.nio.client.HttpAsyncClients;
import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
import org.apache.http.impl.nio.reactor.IOReactorConfig;
import org.apache.http.nio.conn.NoopIOSessionStrategy;
import org.apache.http.nio.conn.SchemeIOSessionStrategy;
import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import java.io.IOException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
public class Test
{
private static final DynamicIntProperty MAX_TOTAL_CONNECTIONS = DynamicPropertyFactory.getInstance().getIntProperty("X.total.connections", 40);
private static final DynamicIntProperty ROUTE_CONNECTIONS = DynamicPropertyFactory.getInstance().getIntProperty("X.total.connections", 40);
private static final DynamicIntProperty CONNECT_TIMEOUT = DynamicPropertyFactory.getInstance().getIntProperty("X.connect.timeout", 60000);
private static final DynamicIntProperty SOCKET_TIMEOUT = DynamicPropertyFactory.getInstance().getIntProperty("X.socket.timeout", -1);
private static final DynamicIntProperty CONNECTION_REQUEST_TIMEOUT = DynamicPropertyFactory.getInstance().getIntProperty("X.connectionrequest.timeout", 60000);
private static final DynamicBooleanProperty STALE_CONNECTION_CHECK = DynamicPropertyFactory.getInstance().getBooleanProperty("X.checkconnection", true);
public static void main(String[] args) throws Exception
{
SSLContext sslcontext = SSLContexts.custom()
.useTLS()
.loadTrustMaterial(null, new TrustStrategy()
{
#Override
public boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException
{
return true;
}
})
.build();
SSLIOSessionStrategy sslSessionStrategy = new SSLIOSessionStrategy(sslcontext, new AllowAll());
Registry<SchemeIOSessionStrategy> sessionStrategyRegistry = RegistryBuilder.<SchemeIOSessionStrategy>create()
.register("http", NoopIOSessionStrategy.INSTANCE)
.register("https", sslSessionStrategy)
.build();
DefaultConnectingIOReactor ioReactor = new DefaultConnectingIOReactor(IOReactorConfig.DEFAULT);
PoolingNHttpClientConnectionManager connectionManager = new PoolingNHttpClientConnectionManager(ioReactor, sessionStrategyRegistry);
connectionManager.setMaxTotal(MAX_TOTAL_CONNECTIONS.get());
connectionManager.setDefaultMaxPerRoute(ROUTE_CONNECTIONS.get());
RequestConfig requestConfig = RequestConfig.custom()
.setSocketTimeout(SOCKET_TIMEOUT.get())
.setConnectTimeout(CONNECT_TIMEOUT.get())
.setConnectionRequestTimeout(CONNECTION_REQUEST_TIMEOUT.get())
.setStaleConnectionCheckEnabled(STALE_CONNECTION_CHECK.get())
.build();
CloseableHttpAsyncClient httpClient = HttpAsyncClients.custom()
.setSSLStrategy(sslSessionStrategy)
.setConnectionManager(connectionManager)
.setDefaultRequestConfig(requestConfig)
.build();
httpClient.start();
// use httpClient...
}
private static class AllowAll implements X509HostnameVerifier
{
#Override
public void verify(String s, SSLSocket sslSocket) throws IOException
{}
#Override
public void verify(String s, X509Certificate x509Certificate) throws SSLException {}
#Override
public void verify(String s, String[] strings, String[] strings2) throws SSLException
{}
#Override
public boolean verify(String s, SSLSession sslSession)
{
return true;
}
}
}
The source of this error on my Apache 2.4 instance (using a Comodo wildcard certificate) was an incomplete path to the SHA-1 signed root certificate. There were multiple chains in the issued certificate, and the chain leading to a SHA-1 root certificate was missing an intermediate certificate. Modern browsers know how to handle this, but Java 7 doesn't handle it by default (although there are some convoluted ways to accomplish this in code). The result is error messages that look identical to the case of self-signed certificates:
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:196)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
... 22 more
In this case, the "unable to find valid certification path to requested target" message is being produced due to the missing intermediate certificate. You can check which certificate is missing using SSL Labs test against the server. Once you find the appropriate certificate, download it and (if the server is under your control) add it to the certificate bundle. Alternatively, you can import the missing certificate locally. Accommodating this issue on the server is a more general solution to the problem.
For Windows only, follow these steps:
In Chrome go to settings.
In Settings click show advance settings.
Under HTTPS/SSL Click on Manage Certificates.
Export Your Certificate.
In Windows searchs (Pressing windows key on keyboard) type java.
Select (Configure Java) Option Which will open Java Control Panel
Select Security tab in Java Control Panel
Select Manage Certificates
Click Import
Under (User) tab selected and certificate type as (Trusted Certificates)
Click import button and browse to downloaded certificate and import it.
There is a lot of way to solve this...
One way is set the TrustStore certificates in a keystore file and put it in the path of the application, and set these system properties in the main method:
public static void main(String[] args) {
System.setProperty("javax.net.ssl.trustStore", "trust-store.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "TrustStore");
...
}
Other way is place the keystore as resource file inside the project jar file and load it:
public static SSLContext createSSLContext(String resourcePath, String pass) throws NoSuchAlgorithmException, KeyStoreException, IOException, CertificateException, UnrecoverableKeyException, KeyManagementException {
// initialise the keystore
final char[] password = pass.toCharArray();
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(ThisClass.class.getResourceAsStream(resourcePath
), password);
// Setup the key manager factory.
KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(ks, password);
// Setup the trust manager factory.
TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
tmf.init(ks);
SSLContext sslc = SSLContext.getInstance("TLS");
sslc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
return sslc;
}
public static void main(String[] args) {
SSLContext.setDefault(
createSSLContext("/trust-store.jks", "TrustStore"));
...
}
In windows you can try this solution too: https://stackoverflow.com/a/59056537/980442
I created the keystore file from a Certificate authority CA .crt file in this way:
keytool -import -alias ca -keystore trust-store.jks -storepass TrustStore -trustcacerts -file ca.crt
FYI: https://docs.oracle.com/javadb/10.8.3.0/adminguide/cadminsslclient.html
For those who like Debian and prepackaged Java:
sudo mkdir /usr/share/ca-certificates/test/ # don't mess with other certs
sudo cp ~/tmp/test.loc.crt /usr/share/ca-certificates/test/
sudo dpkg-reconfigure --force ca-certificates # check your cert in curses GUI!
sudo update-ca-certificates --fresh --verbose
Don't forget to check /etc/default/cacerts for:
# enable/disable updates of the keystore /etc/ssl/certs/java/cacerts
cacerts_updates=yes
To remove cert:
sudo rm /usr/share/ca-certificates/test/test.loc.crt
sudo rm /etc/ssl/certs/java/cacerts
sudo update-ca-certificates --fresh --verbose
UPDATE: That a reboot helped was coincidental (I hoped so, hooray!). The real cause of the problem was this: When Gradle is directed to use a specific keystore, that keystore must also contain all the official root certificates. Otherwise it cannot access libraries from regular repositories. What I had to do was this:
Import the self-signed certificate:
keytool -import -trustcacerts -alias myselfsignedcert -file /Users/me/Desktop/selfsignedcert.crt -keystore ./privateKeystore.jks
Add the official root certificates:
keytool -importkeystore -srckeystore <java-home>/lib/security/cacerts -destkeystore ./privateKeystore.jks
Maybe the Gradle daemon also got in the way. Might be worth killing all running daemons found with ./gradlew --status if things start looking bleak.
ORIGINAL POSTING:
Nobody will believe this, I know. Still, if all else fails, give it a try:
After a reboot of my Mac the problem was gone. Grrr.
Background:
./gradlew jar kept giving me "unable to find valid certification path to requested target"
I am stuck with a self-signed certificate, saved from browser, imported in privateKeystore.jks. Then instructed Gradle to work with privateKeystore.jks:
org.gradle.jvmargs=-Djavax.net.debug=SSL -Djavax.net.ssl.trustStore="/Users/me/IntelliJ/myproject/privateKeystore.jks" -Djavax.net.ssl.trustStorePassword=changeit
As mentioned, this only worked after a reboot.
Had the issue like this image.
Tried a few solutions.
But found that even if it's same project, when it's on other one's working place, it's totally fine. No extra settings needed. So we guessed it's an enviroment issue. We tried changing JDK version, IDE but didn't work. it took about 4 hours for investigation, until we tried the top-rated answer. I didn't find the error mentioned in that answer but I found via my browser about HTTP URL (lock) that there was a certification of Charles. Then I realized my charles was on all the time. As long as I turned that off, it's working all fine.
So I left my experience that could be helpful for your case.
This can also be caused by using GoDaddy certs with Java 7 that are signed using SHA2.
Chrome and all other browsers are starting to deprecate SSL certs that are signed using SHA1, as it's not as secure.
More info on the issue can be found here, as well as how to resolve it on your server if you need to now.
AVG version 18.1.3044 (with Windows 10) interfer with my local Spring application.
Solution: enter in AVG section called "Web and email" and disable the "email protection".
AVG block the certificate if the site isn't secure.
I had the same problem with the certificates error and it was because of SNI: the http client that I used didn't have SNI implemented. So a version update did the job
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.6</version>
</dependency>
Download the certificate from Nexus3 Browser (click on the lock-pad for View Site Information in case of Edge broser)
Click on Connection is secure
Click on the certificate details
Click on Copy To file (it opens up export certificate wizard)
Choose Base-64 encoding
Browse and select a download location and file-name (let’s say mycert)
Open cmd
Goto the download location and execute the below command
keytool -import -alias mycert -keystore "<<your-JAVA_HOME-directory>>\jre\lib\security\cacerts" -file mycert.cer
Restart the machine
Execute maven build again.
And if you are here in 2022 and are on mac follow this
1. Download the certificate.
echo -n | openssl s_client -connect <ServerName>:<PORT> -servername <ServerName> \
| openssl x509 > /tmp/<ServerName>.cert
2. Find your JDK path by executing the command.
/usr/libexec/java_home
3. Now import the cert into the cert-store of jdk.
sudo keytool -import -alias mycertificate -keystore "<JDK_HOME>/lib/security/cacerts" -file /tmp/<ServerName>.cert
You have two options, import the self-signed cert into java's keystore for each jvm the software will run on or try the non-validating ssl factory:
jdbc:postgresql://myserver.com:5432/mydatabasename?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory
Make sure that the https://176.66.3.69:6443/ have a valid certificate.
you can check it via browser firstly if it works in browser it will work in java.
that is working for me
If getting this error in maven, or maven with TestNG :
download the certificate from the target website and install certificate on your machine (using keytool as suggested above, or on windows)
add the following content to the maven arguments (command line and/or IDE):
-Djavax.net.ssl.trustStore=C:\Users\me.keystore -Djavax.net.ssl.trustStorePassword=X
Where X is the password you used at the keytool step.
note : C:\Users\me.keystore should also be set to match your machine.
For instance :
mvn -ea -Dtestng.dtd.http=true -Djavax.net.ssl.trustStore=C:\Users\me\.keystore -Djavax.net.ssl.trustStorePassword=X -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true -Dcucumber.features=src/test/resources -Dcucumber.glue=com.myapp -Dcucumber.filter.tags="#MY_TEST"
In my case I'm running MacOs High Sierra with Java 1.6. The cacert file is in a different location than referenced above in Gabe Martin-Dempesy's answer. The cacert file was also already linked to another location (/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/lib/security/cacerts).
Using FireFox, I exported the certificate from the web site in question to a local file called "exportedCertFile.crt". From there, I used keytool to move the certificate into the cacert file. This fixed the problem.
bash-3.2# cd /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/security/
bash-3.2# keytool -importcert -file ~/exportedCertFile.crt -alias example -keystore cacerts -storepass changeit
first Download the ssl certificate then you can go to your java bin path execute the below command in the console.
C:\java\JDK1.8.0_66-X64\bin>keytool -printcert -file C:\Users\lova\openapi.cer -keystore openapistore
In my case I had both keystore and truststore having the same certificate so removing truststore helped. Sometimes the chain of certificates can be an issue if you've multiple copies of certificates.
As original question was - how to ignore the cert error, here is solution for those using SpringBoot and RestTemplate
#Service
public class SomeService {
private final RestTemplate restTemplate;
private final ObjectMapper objectMapper;
private static HttpComponentsClientHttpRequestFactory createRequestFactory() {
try {
SSLContextBuilder sslContext = new SSLContextBuilder();
sslContext.loadTrustMaterial(null, new TrustAllStrategy());
CloseableHttpClient client = HttpClients.custom().setSSLContext(sslContext.build()).setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
requestFactory.setHttpClient(client);
return requestFactory;
} catch (KeyManagementException | KeyStoreException | NoSuchAlgorithmException var3) {
throw new IllegalStateException("Couldn't create HTTP Request factory ignore SSL cert validity: ", var3);
}
}
#Autowired
public SomeService(RestTemplate restTemplate, ObjectMapper objectMapper) {
this.objectMapper = objectMapper;
this.dimetorURL = dimetorURL;
restTemplate.setRequestFactory(createRequestFactory());
}
public ResponseEntity<ResponseObject> sendRequest(RequestObject requestObject) {
//...
return restTemplate.exchange(url, HttpMethod.GET, ResponseObject.class);
//...
}
}
This is what worked for me on macOS. Replace server-name and server-port with your own.
Run these two commands on your terminal.
Download certificate from the remote server
openssl x509 -in <(openssl s_client -connect server-name:server-port -prexit 2>/dev/null) -out ~/server-name.crt
Import cert to Java keystore
sudo keytool -importcert -file ~/server-name.crt -alias server-name -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit
Restart your application and the certs errors should go away!
This works on any OS you just need JDK installed :
Download the certificate from the remote server :
keytool -printcert -rfc -sslserver <your remote server hostname> > /tmp/remorte-cert.crt
Import the certificate to your JDK keystore :
keytool -importcert -file /tmp/remorte-cert.crt -alias <an alias for your remote server> -storepass changeit -keystore "${JAVA_HOME}/lib/security/cacerts" -noprompt

Error while connecting to mysql database, haskell

I'm absolutely newbie to haskell, but I need to write a simple application to work with DB. I'm reading realworldhaskell book, chapter about using databases: http://book.realworldhaskell.org/read/using-databases.html.
I've installed HDBC and HDBC-mysql and trying to run:
ghci> :module Database.HDBC Database.HDBC.MySQL
but receive error
attempting to use module ‘Database.HDBC.MySQL’ (./Database/HDBC/MySQL.hs) which is not loaded.
Does someone have some idea how to fix it and by what is is caused? Thanks!
I could solve the problem installing mysql on MacOS,
brew install mysql
mysql.server start ## mysqld
Followed by
cabal install HDBC
cabal install HDBC-mysql
Then could I create MySQL connection,
import Control.Monad
import Database.HDBC
import Database.HDBC.MySQL
main = do conn <- connectMySQL MySQLConnectInfo {
mysqlHost = "localhost",
mysqlUser = "root",
mysqlPassword = "",
mysqlDatabase = "chat_server",
mysqlPort = 3306,
mysqlUnixSocket = "/tmp/mysql.sock",
mysqlGroup = Just "test"
}
rows <- quickQuery' conn "SELECT 1 + 1" []
forM_ rows $ \row -> putStrLn $ show row
Note: you might need to update mysqlUnixSocket based on where is it located which can be found with following command:
sudo find / -type s

How to connect to MySQL using OpenJDK in Linux Mint

I am having issues trying to get a database connection using the code below:
import java.lang.*;
import java.sql.*;
public class Demo {
public static void main(String[] args){
try{
Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test?" + "user=test&password=123456");
}catch(SQLException ex){
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}catch(Exception ex){
System.out.println("Exception: " + ex.getMessage());
}
}
}
The error message that is outputted is:
SQLException: No suitable driver found for jdbc:mysql://127.0.0.1:3306/test?user=test&password=123456
SQLState: 08001
VendorError: 0
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at Demo.main(Demo.java:9)
My java version is below:
java -> /usr/lib/jvm/java-6-openjdk-i386/bin/java
javac -> /usr/lib/jvm/java-6-openjdk-i386/bin/javac
javac.1.gz -> /usr/lib/jvm/java-6-openjdk-i386/man/man1/javac.1.gz
javadoc -> /usr/lib/jvm/java-6-openjdk-i386/bin/javadoc
javadoc.1.gz -> /usr/lib/jvm/java-6-openjdk-i386/man/man1/javadoc.1.gz
javah -> /usr/lib/jvm/java-6-openjdk-i386/bin/javah
javah.1.gz -> /usr/lib/jvm/java-6-openjdk-i386/man/man1/javah.1.gz
javap -> /usr/lib/jvm/java-6-openjdk-i386/bin/javap
javap.1.gz -> /usr/lib/jvm/java-6-openjdk-i386/man/man1/javap.1.gz
javaws -> /usr/lib/jvm/java-6-openjdk-i386/jre/bin/javaws
javaws.1.gz -> /usr/lib/jvm/java-6-openjdk-i386/jre/man/man1/javaws.1.gz
I've, literally, no idea how to troubleshoot this error message. The database exists. The username and password exists. I've currently not added any tables to the database but I don't think that can be the issue, since I'm only making a connection after all...
Driver is installed under /usr/share/java
-rw-r--r-- 1 root root 822524 10月 20 2011 mysql-connector-java-5.1.16.jar
-rw-r--r-- 1 root root 827942 9月 9 22:40 mysql-connector-java-5.1.21-bin.jar
lrwxrwxrwx 1 root root 35 9月 9 22:40 mysql-connector-java.jar -> mysql-connector-java-5.1.21-bin.jar
lrwxrwxrwx 1 root root 24 10月 20 2011 mysql.jar -> mysql-connector-java.jar
Does anybody know how to fix it..
Thanks for your help!
:)
Make sure you have mysql connector driver (i.e. jar file) in your project library. This error message appears when there is no appropriate driver.
You can download the MySQL connector driver from this site.
I was having the same problem and the curiouss answer helped me to figure out an new solution.
Note: I was using Maven.
So I decided to try this dependency: http://mvnrepository.com/artifact/mysql/mysql-connector-java
After I added into the pom.xml and run mvn compile exec:javait worked.