0

On creating a new database with ij of derby db I got an SQL Error, but no entry within derby.log. No mean to correct the error, hence I set up an new default installation of debian 10 within a virtual machine. With apt-get I added jdk 11. I downloaded the latest bin version of derby db from apache and I expanded. I set JAVA_HOME and DERBY_HOME as well as the PATH variable and I tried to create a db within this clean environment. No chance it doesn't work. Beside I have the same derby version with jdk 11 running on OpenSuse Leap 15.1, works as expected and the same is true for the previous version of derby db with jdk 8 on debian 9! Must be a specific problem! Working steps:

juerg@debian:~/opt/db-derby-10.15.1.3-bin/databases$  ../bin/startNetworkServer &
[1] 1423
juerg@debian:~/opt/db-derby-10.15.1.3-bin/databases$ Wed Jan 29 11:57:34 CET 2020 : Security manager installed using the Basic server security policy.
Wed Jan 29 11:57:35 CET 2020 : Apache Derby Network Server - 10.15.1.3 - (1853019) started and ready to accept connections on port 1527

juerg@debian:~/opt/db-derby-10.15.1.3-bin/databases$ ij
ij version 10.15
ij> connect 'jdbc:derby://localhost:1527/sample;create=true';
ERROR XJ041: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sample', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001
ij> exit;
juerg@debian:~/opt/db-derby-10.15.1.3-bin/databases$ ll
insgesamt 4
-rw------- 1 juerg juerg 187 Jan 29 12:00 derby.log
juerg@debian:~/opt/db-derby-10.15.1.3-bin/databases$ cat derby.log
----------------------------------------------------------------
Wed Jan 29 12:00:17 CET 2020: Shutting down Derby engine

info tells me:
juerg@debian:~/opt/db-derby-10.15.1.3-bin/databases$ sysinfo
------------------ Java Information ------------------
Java Version:    11.0.6
Java Vendor:     Debian
Java home:       /usr/lib/jvm/java-11-openjdk-amd64
Java classpath:  /home/juerg/opt/db-derby-10.15.1.3-bin/lib/derbyshared.jar:/home/juerg/opt/db-derby-10.15.1.3-bin/lib/derby.jar:/home/juerg/opt/db-derby-10.15.1.3-bin/lib/derbynet.jar:/home/juerg/opt/db-derby-10.15.1.3-bin/lib/derbytools.jar:/home/juerg/opt/db-derby-10.15.1.3-bin/lib/derbyoptionaltools.jar:/home/juerg/opt/db-derby-10.15.1.3-bin/lib/derbyclient.jar
OS name:         Linux
OS architecture: amd64
OS version:      4.19.0-6-amd64
Java user name:  juerg
Java user home:  /home/juerg
Java user dir:   /home/juerg/opt/db-derby-10.15.1.3-bin/databases
java.specification.name: Java Platform API Specification
java.specification.version: 11
java.runtime.version: 11.0.6+10-post-Debian-1deb10u1
--------- Derby Information --------
[/home/juerg/opt/db-derby-10.15.1.3-bin/lib/derby.jar] 10.15.1.3 - (1853019)
[/home/juerg/opt/db-derby-10.15.1.3-bin/lib/derbytools.jar] 10.15.1.3 - (1853019)
[/home/juerg/opt/db-derby-10.15.1.3-bin/lib/derbynet.jar] 10.15.1.3 - (1853019)
[/home/juerg/opt/db-derby-10.15.1.3-bin/lib/derbyclient.jar] 10.15.1.3 - (1853019)
[/home/juerg/opt/db-derby-10.15.1.3-bin/lib/derbyshared.jar] 10.15.1.3 - (1853019)
[/home/juerg/opt/db-derby-10.15.1.3-bin/lib/derbyoptionaltools.jar] 10.15.1.3 - (1853019)

and the environment variables are:
juerg@debian:~/opt/db-derby-10.15.1.3-bin/databases$ env
SHELL=/bin/bash
SESSION_MANAGER=local/debian:@/tmp/.ICE-unix/759,unix/debian:/tmp/.ICE-unix/759
QT_ACCESSIBILITY=1
COLORTERM=truecolor
XDG_MENU_PREFIX=gnome-
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
DERBY_HOME=/home/juerg/opt/db-derby-10.15.1.3-bin
LANGUAGE=de_CH:de
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
DESKTOP_SESSION=gnome
GTK_MODULES=gail:atk-bridge
XDG_SEAT=seat0
PWD=/home/juerg/opt/db-derby-10.15.1.3-bin/databases
XDG_SESSION_DESKTOP=gnome
LOGNAME=juerg
XDG_SESSION_TYPE=wayland
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
GDM_LANG=de_CH.UTF-8
HOME=/home/juerg
USERNAME=juerg
LANG=de_CH.UTF-8
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
XDG_CURRENT_DESKTOP=GNOME
VTE_VERSION=5402
WAYLAND_DISPLAY=wayland-0
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/e18a57ab_ab8d_4eb5_99d6_814c0efa12ea
GJS_DEBUG_OUTPUT=stderr
XDG_SESSION_CLASS=user
TERM=xterm-256color
USER=juerg
GNOME_TERMINAL_SERVICE=:1.51
DISPLAY=:0
SHLVL=1
XDG_VTNR=2
XDG_SESSION_ID=2
XDG_RUNTIME_DIR=/run/user/1000
PATH=/usr/lib/jvm/java-11-openjdk-amd64/bin:/usr/lib/jvm/java-11-openjdk-amd64/lib:/home/juerg/opt/db-derby-10.15.1.3-bin/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin
GDMSESSION=gnome
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
OLDPWD=/home/juerg/opt/db-derby-10.15.1.3-bin
_=/usr/bin/env```
who can see the bug?

Part of derby.log:
Fri Feb 07 17:51:29 CET 2020 : Apache Derby Network Server - 10.15.1.3 - (1853019) started and ready to accept connections on port 1527
----------------------------------------------------------------
Fri Feb 07 17:52:16 CET 2020:
Booting Derby version The Apache Software Foundation - Apache Derby - 10.15.1.3 - (1853019): instance a816c00e-0170-2090-408b-ffff8c52a9b6 
on database directory /home/juerg/opt/db-derby-10.15.1.3-bin/bin/demo with class loader jdk.internal.loader.ClassLoaders$AppClassLoader@55054057 
Loaded from file:/home/juerg/opt/db-derby-10.15.1.3-bin/lib/derby.jar
java.vendor=Debian
user.dir=/home/juerg/opt/db-derby-10.15.1.3-bin/bin
os.name=Linux
os.arch=amd64
os.version=4.19.0-6-amd64
derby.system.home=/home/juerg/opt/db-derby-10.15.1.3-bin/bin
Database Class Loader started - derby.database.classpath=''
----------------------------------------------------------------
Fri Feb 07 17:52:18 CET 2020:
Shutting down instance a816c00e-0170-2090-408b-ffff8c52a9b6 on database directory /home/juerg/opt/db-derby-10.15.1.3-bin/bin/demo with class loader jdk.internal.loader.ClassLoaders$AppClassLoader@55054057 
Fri Feb 07 17:52:18 CET 2020 Thread[DRDAConnThread_2,5,main] Cleanup action starting
ERROR XBM01: Startup failed due to an exception. See next exception for details. 
    at org.apache.derby.shared.common.error.StandardException.newException(StandardException.java:300)
    at org.apache.derby.iapi.services.monitor.Monitor.exceptionStartingModule(Monitor.java:743)
    at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(BaseMonitor.java:1857)
    at org.apache.derby.impl.services.monitor.BaseMonitor.createPersistentService(BaseMonitor.java:1022)
    at org.apache.derby.impl.services.monitor.FileMonitor.createPersistentService(FileMonitor.java:48)
    at org.apache.derby.iapi.services.monitor.Monitor.createPersistentService(Monitor.java:650)
    at org.apache.derby.impl.jdbc.EmbedConnection$5.run(EmbedConnection.java:4067)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at org.apache.derby.impl.jdbc.EmbedConnection.createPersistentService(EmbedConnection.java:4061)
    at org.apache.derby.impl.jdbc.EmbedConnection.createDatabase(EmbedConnection.java:2654)
    at org.apache.derby.impl.jdbc.EmbedConnection.<init>(EmbedConnection.java:435)
    at org.apache.derby.iapi.jdbc.InternalDriver$1.run(InternalDriver.java:660)
    at org.apache.derby.iapi.jdbc.InternalDriver$1.run(InternalDriver.java:656)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at org.apache.derby.iapi.jdbc.InternalDriver.getNewEmbedConnection(InternalDriver.java:654)
    at org.apache.derby.iapi.jdbc.InternalDriver.connect(InternalDriver.java:300)
    at org.apache.derby.iapi.jdbc.InternalDriver.connect(InternalDriver.java:967)
    at org.apache.derby.jdbc.EmbeddedDriver.connect(EmbeddedDriver.java:125)
    at org.apache.derby.impl.drda.Database.makeConnection(Database.java:253)
    at org.apache.derby.impl.drda.DRDAConnThread.getConnFromDatabaseName(DRDAConnThread.java:1476)
    at org.apache.derby.impl.drda.DRDAConnThread.verifyUserIdPassword(DRDAConnThread.java:1426)
    at org.apache.derby.impl.drda.DRDAConnThread.parseSECCHK(DRDAConnThread.java:3380)
    at org.apache.derby.impl.drda.DRDAConnThread.parseDRDAConnection(DRDAConnThread.java:1210)
    at org.apache.derby.impl.drda.DRDAConnThread.processCommands(DRDAConnThread.java:1010)
    at org.apache.derby.impl.drda.DRDAConnThread.run(DRDAConnThread.java:300)
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getenv.SOURCE_DATE_EPOCH")
    at java.base/java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
    at java.base/java.security.AccessController.checkPermission(AccessController.java:897)
    at java.base/java.lang.SecurityManager.checkPermission(SecurityManager.java:322)
    at java.base/java.lang.System.getenv(System.java:996)
    at java.base/java.util.Properties.getFormattedTimestamp(Properties.java:1587)
    at java.base/java.util.Properties.store0(Properties.java:929)
    at java.base/java.util.Properties.store(Properties.java:918)
    at org.apache.derby.impl.services.monitor.StorageFactoryService$5.run(StorageFactoryService.java:369)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at org.apache.derby.impl.services.monitor.StorageFactoryService.saveServiceProperties(StorageFactoryService.java:347)
    at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(BaseMonitor.java:1840)
    ... 22 more
--------------------------------------
//
// This system policy file grants a set of default permissions to all domains
// and can be configured to grant additional permissions to modules and other
// code sources. The code source URL scheme for modules linked into a
// run-time image is "jrt".
//
// For example, to grant permission to read the "foo" property to the module
// "com.greetings", the grant entry is:
//
// grant codeBase "jrt:/com.greetings" {
//     permission java.util.PropertyPermission "foo", "read";
// };
//


// default permissions granted to all domains
grant {
    // allows anyone to listen on dynamic ports
    permission java.net.SocketPermission "localhost:0", "listen";

    // "standard" properies that can be read by anyone
    permission java.util.PropertyPermission "java.version", "read";
    permission java.util.PropertyPermission "java.vendor", "read";
    permission java.util.PropertyPermission "java.vendor.url", "read";
    permission java.util.PropertyPermission "java.class.version", "read";
    permission java.util.PropertyPermission "os.name", "read";
    permission java.util.PropertyPermission "os.version", "read";
    permission java.util.PropertyPermission "os.arch", "read";
    permission java.util.PropertyPermission "file.separator", "read";
    permission java.util.PropertyPermission "path.separator", "read";
    permission java.util.PropertyPermission "line.separator", "read";
    permission java.util.PropertyPermission "java.specification.version", "read";
    permission java.util.PropertyPermission "java.specification.vendor", "read";
    permission java.util.PropertyPermission "java.specification.name", "read";
    permission java.util.PropertyPermission "java.vm.specification.version", "read";
    permission java.util.PropertyPermission "java.vm.specification.vendor", "read";
    permission java.util.PropertyPermission "java.vm.specification.name", "read";
    permission java.util.PropertyPermission "java.vm.version", "read";
    permission java.util.PropertyPermission "java.vm.vendor", "read";
    permission java.util.PropertyPermission "java.vm.name", "read";
    permission java.lang.RuntimePermission "getenv.SOURCE_DATE_EPOCHE", "read";
};
grant codeBase "file:/home/juerg.m2/repository/org/apache/derby/derby/10.15.1.3/derby-10.15.1.3.jar" {
    permission java.security.AllPermission;
};
grant codeBase "file:/home/juerg.m2/repository/org/apache/derby/derby/10.15.1.3/derbyshared-10.15.1.3.jar" {
    permission java.security.AllPermission;
};
grant codeBase "file:/home/juerg.m2/repository/org/apache/derby/derby/10.15.1.3/derbyclient-10.15.1.3.jar" {
    permission java.security.AllPermission;
};
grant codeBase "file:/home/juerg.m2/repository/org/apache/derby/derby/10.15.1.3/derbynet-10.15.1.3.jar" {
    permission java.security.AllPermission;
};
grant codeBase "file:/home/juerg.m2/repository/org/apache/derby/derby/10.15.1.3/derbytools-10.15.1.3.jar" {
    permission java.security.AllPermission;
};


juerg
  • 381
  • 4
  • 18
  • What does your derby.log for your Network Server say? – Bryan Pendleton Jan 29 '20 at 14:22
  • 1
    Look at line below cat derby.log! Strictly nothing, i.e. Shutting down Derby engine! I forgot to say on Debian 10 it's jdk 11.0.6! Maybe important, as on debian 9 I have jdk 11.0.4 installed and it works! – juerg Jan 30 '20 at 06:36
  • 1
    meanwhile I smuggled the database from strech to buster and then connected to the database. Works as it should! However repeating to create a new database fails without exception! There must be a bug! Where? derby-10.15.1.3 not working properly with jdk 11.0.6 of debian! I repeated the test on windows: jdk 11.0.6 and same version of derby. Creating a db works! – juerg Jan 30 '20 at 08:02
  • Try running with ij.exceptionTrace and see if you get any more clues: https://db.apache.org/derby/docs/10.15/tools/rtoolsijproprefexceptiontrace.html – Bryan Pendleton Jan 30 '20 at 22:20
  • 1
    done! I got a trace with the principal line:Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getenv.SOURCE_DATE_EPOCH")! see above, env doesn't contain any "SOURCE_DATE_EPOCHE"! I didn't read, that this must be added in any form! Further I added "permission java.security.AllPermission;" to the file: /etc/java-11-openjdk/security/java.policy, but this didn't change any thing in behavior! user.dir=/home/juerg/opt/db-derby-10.15.1.3-bin/databases derby.system.home is OK Database Class Loader started - derby.database.classpath='' – juerg Feb 01 '20 at 16:44
  • Seems like you''re making progress, but still haven't figured it out? Can you include the complete output of the stack trace in your question? – Bryan Pendleton Feb 02 '20 at 06:49
  • shortly! I'll try also to create in memory only! But before I have some other tasks to accomplish. – juerg Feb 03 '20 at 08:17
  • The issue must be related to https://bz.apache.org/bugzilla/show_bug.cgi?id=62617, as working with embedded mode every tested variant works fine. I tried also to modify /etc/java-11-openjdk/security/java.policy with: grant codeBase "file:/home/juerg.m2/repository/org/apache/derby/derby/10.15.1.3/derby-10.15.1.3.jar" { permission java.security.AllPermission; }; - for all jars used, without any effect. Maybe my syntax used is wrong! – juerg Feb 10 '20 at 15:04
  • Perhaps this: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=914278 is relevant? The syntax of Java security policy files is very challenging, so maybe you can include your full security policy file? – Bryan Pendleton Feb 10 '20 at 21:44
  • 1
    My stomach feeling tells me the repair of bug 914278 could be the origin of my issue! And I added the content of the java.policy file. W.r.t. the latter, I must confess, my changes are rather based on guessing than knowing. Helas! – juerg Feb 12 '20 at 14:05

2 Answers2

1

ij> connect 'jdbc:derby://localhost:1527/sample;create=true';

juerg@debian:~/opt/db-derby-10.15.1.3-bin/databases$ ij
ij version 10.15
ij> connect 'jdbc:derby:sample;create=true';

https://db.apache.org/derby/docs/10.0/manuals/getstart/gspr16.html

  • 1
    Create Derby database Connect in this way by using the Connect command and the embedded driver: java org.apache.derby.tools.ij ij> connect 'jdbc:derby:sample'; If the URL entered contains Network Client information, the Connect command loads the Network Client driver: java org.apache.derby.tools.ij ij version 10.15 ij> connect 'jdbc:derby://localhost:1527/sample'; ij> https://db.apache.org/derby/docs/10.15/tools/index.html – Viktor Wellboy Feb 09 '21 at 10:24
0

Replacing getenv.SOURCE_DATE_EPOCHE with getenv.SOURCE_DATE_EPOCHin the policy file should fix the AccessControlException.

Emmanuel Bourg
  • 9,601
  • 3
  • 48
  • 76