The official JAR file for MySQL Connector/J (from https://dev.mysql.com/downloads/connector/j/) includes certain metadata (file '/META-INF/services/java.sql.Driver') that allows other components to recognize the Java class 'com.mysql.cj.jdbc.Driver' as a JDBC Service Provider - or, more specifically, a JDBC driver. This facilitates use of Connector/J from applications running within Tomcat, for example. The JAR file generated by the ebuild lacks this metadata, so 'com.mysql.cj.jdbc.Driver' is not auto-discovered as a JDBC driver, and has to be loaded explicitly to be used with JDBC. This can become a source of major confusion since a Connector/J JAR file from the Gentoo package doesn't "work" as expected (the same way as the official JAR file does - that is, with auto-discovery), potentially causing users to spend significant time on troubleshooting, trying to understand why, say, configurations taken from tutorials and HOW-TO's don't work for them. This happens because the ebuild for dev-java/jdbc-mysql-9.2.0 uses java-pkg-simple.eclass, which (as its description says) ignores build instructions from the sources - and the needed metadata comes exactly from Connector/J's build instructions (build.xml). So, to resolve this problem, the ebuild either needs to be switched to using upstream build instructions, or the '/META-INF/services/java.sql.Driver' file needs to be added/generated manually by the ebuild. Reproducible: Always Steps to Reproduce: 1. Create JdbcSource.java: import java.util.*; import com.zaxxer.hikari.*; public class JdbcSource { public static void main(String[] args) { try { Properties props = new Properties(); // Don't specify driverClassName: //props.setProperty("driverClassName", "com.mysql.cj.jdbc.Driver"); props.setProperty("jdbcUrl", "jdbc:mysql://localhost:3306/test"); props.setProperty("username", "test"); props.setProperty("password", "test"); HikariConfig config = new HikariConfig(props); HikariDataSource ds = new HikariDataSource(config); System.out.println("DataSource created."); } catch (Exception ex) { ex.printStackTrace(); } } } 2. wget https://repo1.maven.org/maven2/com/zaxxer/HikariCP/3.4.5/HikariCP-3.4.5.jar 3. emerge dev-java/slf4j-api dev-java/slf4j-simple =dev-java/jdbc-mysql-9.2.0 3. javac -classpath HikariCP-3.4.5.jar JdbcSource.java 4. java -classpath .:HikariCP-3.4.5.jar:$(java-config -p slf4j-api,slf4j-simple,jdbc-mysql) JdbcSource Actual Results: [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting... java.lang.RuntimeException: Failed to get driver instance for jdbcUrl=jdbc:mysql://localhost:3306/test Expected Results: [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting... [main] INFO com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed. DataSource created. Portage 3.0.67 (python 3.12.9-final-0, default/linux/amd64/23.0/split-usr/desktop, gcc-12, glibc-2.40-r8, 6.5.0-pf5-dracut051 x86_64) ================================================================= System uname: Linux-6.5.0-pf5-dracut051-x86_64-Intel-R-_Core-TM-_i7-8550U_CPU_@_1.80GHz-with-glibc2.40 KiB Mem: 32758200 total, 9062820 free KiB Swap: 41943036 total, 38076668 free Timestamp of repository gentoo: Sun, 23 Mar 2025 20:15:00 +0000 Head commit of repository gentoo: 2d61caeb04b13d359f6682cb53a2c6bc1854e5fd Head commit of repository nix-guix: efb6fb37203883f27e7e638fa8fb73c50a26677e Head commit of repository palemoon: 77300e599732b37683f878407ffa89817da35a69 Head commit of repository ssnb: 577be2ab7dacbf689167955e19a51591631f49c6 sh bash 5.2_p37 ld GNU ld (Gentoo 2.44 p1) 2.44.0 distcc 3.4 x86_64-pc-linux-gnu [enabled] ccache version 4.10.2 [enabled] app-misc/pax-utils: 1.3.8::gentoo app-shells/bash: 5.2_p37::gentoo dev-build/autoconf: 2.13-r8::gentoo, 2.72-r1::gentoo dev-build/automake: 1.16.5-r2::gentoo, 1.17-r1::gentoo dev-build/cmake: 3.31.5::gentoo dev-build/libtool: 2.5.4::gentoo dev-build/make: 4.4.1-r100::gentoo dev-build/meson: 1.7.0::gentoo dev-java/java-config: 2.3.4::gentoo dev-lang/perl: 5.40.0-r1::gentoo dev-lang/python: 2.7.18_p16-r2::gentoo, 3.10.16_p2::gentoo, 3.11.11_p2::gentoo, 3.12.9::gentoo, 3.13.2::gentoo dev-lang/rust-bin: 1.84.1-r2::gentoo dev-util/ccache: 4.10.2-r1::gentoo llvm-core/clang: 18.1.8-r6::gentoo, 19.1.7::gentoo llvm-core/lld: 19.1.7::gentoo llvm-core/llvm: 18.1.8-r6::gentoo, 19.1.7::gentoo sys-apps/baselayout: 2.17::gentoo sys-apps/openrc: 0.56::gentoo sys-apps/sandbox: 2.39::gentoo sys-devel/binutils: 2.44::gentoo sys-devel/binutils-config: 5.5.2::gentoo sys-devel/gcc: 12.4.1_p20241219::gentoo sys-devel/gcc-config: 2.12.1::gentoo sys-kernel/linux-headers: 6.12::gentoo (virtual/os-headers) sys-libs/glibc: 2.40-r8::gentoo Repositories: gentoo location: /usr/portage sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 volatile: True sync-rsync-extra-opts: sync-rsync-verify-max-age: 3 sync-rsync-verify-metamanifest: yes sync-rsync-verify-jobs: 1 java location: /var/lib/layman/java masters: gentoo priority: 50 volatile: True mv location: /var/lib/layman/mv masters: gentoo priority: 50 volatile: True nix-guix location: /var/lib/layman/nix-guix sync-type: git sync-uri: https://github.com/trofi/nix-guix-gentoo.git masters: gentoo priority: 50 volatile: True palemoon location: /var/lib/layman/palemoon sync-type: git sync-uri: https://github.com/gentoo-mirror/palemoon.git masters: gentoo priority: 50 volatile: True ssnb location: /var/lib/layman/ssnb sync-type: git sync-uri: https://cgit.gentoo.org/repo/user/ssnb.git/ masters: gentoo priority: 50 volatile: True steam-overlay location: /var/lib/layman/steam-overlay masters: gentoo priority: 50 volatile: True crossdev location: /usr/local/portage-crossdev masters: gentoo priority: 110 volatile: True local location: /usr/local/portage masters: gentoo priority: 200 volatile: True Installed sets: @system ACCEPT_KEYWORDS="amd64" ACCEPT_LICENSE="* -@EULA Broadcom dlj-1.1 AdobeFlash-10.3 FraunhoferFDK Vivaldi RAR" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-Os -finline-functions -frename-registers -pipe -march=nocona" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/easy-rsa /usr/share/gnupg/qualified.txt /usr/share/i18n/locales/en_US /usr/share/maven-bin-3.9/conf /var/bind /var/lib/i2pd/certificates" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.6/ext-active/ /etc/php/apache2-php8.2/ext-active/ /etc/php/cgi-php5.6/ext-active/ /etc/php/cgi-php8.2/ext-active/ /etc/php/cli-php5.6/ext-active/ /etc/php/cli-php8.2/ext-active/ /etc/php/fpm-php8.2/ext-active/ /etc/php/phpdbg-php8.2/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c" CXXFLAGS="-Os -finline-functions -frename-registers -pipe -march=nocona" DISTDIR="/usr/portage/distfiles" EMERGE_DEFAULT_OPTS="--autounmask n --autounmask-keep-masks y --verbose-conflicts" ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME" FCFLAGS="-O2 -pipe" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg-live ccache config-protect-if-modified distcc distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync merge-wait multilib-strict news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-O2 -pipe" GENTOO_MIRRORS="http://mirror.yandex.ru/gentoo-distfiles/ http://gentoo.mirror.web4u.cz/ http://mirrors.linuxant.fr/distfiles.gentoo.org/" LANG="en_US.utf8" LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs" LEX="flex" LINGUAS="en ru" MAKEOPTS="-j18 -l12" PKGDIR="/var/cache/binpkgs" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git" PORTAGE_TMPDIR="/var/tmp" SHELL="/bin/bash" USE="3dnow 3dnowext 7zip X a52 aac acl acpi aio alsa amd64 ao apache2 arts atm avahi avfs bash-completion bazaar binfilter bluetooth branding bzip2 cairo caps cdda cdr cet cgi chm console crypt cups curl custom-optimization cxx dbus dell device-mapper dhcp dillo dirac directfb disk-partition djvu dri dts dvd dvdr ebook elogind enca encode epub evo examples exif expat faac fat fbcon fbsplash fdk festival ffmpeg fftw flac fontconfig ftp fts3 fuse gajim gcj gdbm gdu gif git gmp gnome gnome-keyring gnutls gpg gphoto2 gpm gsf gstreamer gtk gucharmap gui gzip hardcoded-tables hddtemp htmlhandbook iconv icu idle imap ipv6 ithreads jack jadetex java java5 java6 javascript jfs jingle jpeg jpeg2k kde kf6compat lame laptop lcms libass libffi libnotify libsamplerate libtirpc lm_sensors log4j lz4 lzma lzo mad mate matroska mercurial mjpeg mmap mmxext mng mobi mod modemmanager modplug mp3 mp4 mpeg mplayer mtp multilib mysql mysqli ncurses netbeans nls nsplugin ntfs odbc ogg openal opengl openmp openssl oss pam pango pcre pdf perl png policykit postgres ppds pulseaudio python qml qt5 qt6 quicktime radius rar rdesktop rdp readline reiserfs samba schroedinger sdl seccomp session sftp slang smime smp sockets socks5 sound spell split-usr sql sqlite sqlite3 srv ssl ssse3 startup-notification subtitles subversion svg systray taglib tcl test-rust theora threads tiff tk trayicon truetype type1 udev udisks unicode upower usb userlocales v4l v4l2 vcd vdpau vhosts vnc vorbis vpx vulkan wavpack wayland wma wmf wxwidgets x264 xattr xcb xcomposite xetex xfce xfs xft xhtml xml xrender xscreensaver xulrunner xv xvid zip zlib zstd" ABI_X86="64 32" ADA_TARGET="gcc_14" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2 sse3 ssse3 sse4_1 sse4_2 avx aes" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" GUILE_SINGLE_TARGET="3-0" GUILE_TARGETS="3-0" INPUT_DEVICES="keyboard mouse evdev synaptics" KERNEL="linux" L10N="en ru" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PERL_FEATURES="ithreads" PHP_TARGETS="php5-3 php5-4 php5-6" POSTGRES_TARGETS="postgres16" PYTHON_SINGLE_TARGET="python3_10" PYTHON_TARGETS="python3_10 python3_12" RUBY_TARGETS="ruby31" VIDEO_CARDS="vga vesa nv nouveau radeon r600 amdgpu intel" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account" Unset: ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2efe9ada1058c471701439c560e6c23c250f71ab commit 2efe9ada1058c471701439c560e6c23c250f71ab Author: Volkmar W. Pogatzki <gentoo@pogatzki.net> AuthorDate: 2025-04-02 22:41:03 +0000 Commit: Florian Schmaus <flow@gentoo.org> CommitDate: 2025-04-04 12:06:25 +0000 dev-java/jdbc-mysql: add missing META-INF/services Closes: https://bugs.gentoo.org/953059 Signed-off-by: Volkmar W. Pogatzki <gentoo@pogatzki.net> Closes: https://github.com/gentoo/gentoo/pull/41441 Signed-off-by: Florian Schmaus <flow@gentoo.org> .../{jdbc-mysql-9.2.0.ebuild => jdbc-mysql-9.2.0-r1.ebuild} | 8 ++++++++ 1 file changed, 8 insertions(+)