There are two aspects to this bug:
When sample application setup scripts that use the Derby database are run, the Derby database gets created under the current directory or under <install_root>/bin.
The sample build Ant script creates a password.txt file that stores the admin password file under current directory, which will not be writable in non-root and sparse zones scenarios.
Derby database location – Use the --dbhome option with the start-database command to create the database at the value specified for --dbhome. For example, the following is the asadmin command syntax for start-database.
start-database [--dbhost 0.0.0.0] [--dbport 1527] [--dbhome db_directory] [--echo=false] [--verbose=false]
Location of the password.txt file – By design, the samples directory is expected to be writable since all the build commands include the creation of a password.txt file in that directory. Be sure to install a working copy of the samples in a writable location.