Spring Boot: Jdbc javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify - mysql

I am currently learning more about implementing JDBC and using databases in a Spring Boot webapp, and I encountered the following Stack Trace written in the bottom of the post.
I have created a simple Employee model, and I am trying to execute some database code on the same class which my main() lies in. The model and the main class are the only two java files existing in this whole project. I am trying to implement the following run() code that overrides the one from the interface, CommandLineRunner, but I do not get the logs that should come after log.info("Part A:"):
log.info("Part A:")
employees.forEach(employee -> {log.info(employee.toString());
log.info("part a");});
--Things I noticed:
I noticed that the last line of the log before the stack trace starts comes from: "Thread-1" instead of "main". I think that means that a thread from somewhere other than the main encountered an error and closed connection before when it should close normally.
Also, I think that because HikariPool closed before "peer's close_notify", which I presume that it refers to the normal closure of HikariPool, I am not able to see the final bit of logging that I have kept trying to procure. The final bit of logging that I want to see is the logging of the employee that has become inserted into my database.
The final bit of logging that I want to see should be procured from this line of code:
employees.forEach(employee -> {log.info(employee.toString());
log.info("part a");});
--Things to note:
Because of this line in the log, I thought I would see the employee inserted into my database, but when I queried directly on MySQL Command Line Client, it returned an empty set:
2018-11-03 21:08:35.362 INFO 2408 --- [ main] c.j.jdbctest1.JdbcTest1Application : rows affected: 1
I don't understand why a row has been affected when nothing has been inserted into the database.
The stacktrace and logs: (The stacktrace pasted below actually repeats itself several more times but I cut it off for brevity.)
2018-11-03 21:08:32.997 INFO 2408 --- [ main] c.j.jdbctest1.JdbcTest1Application : Starting JdbcTest1Application on KitKat with PID 2408 (C:\Users\Nano\Downloads\jdbc-test1\jdbc-test1\target\classes started by Nano in C:\Users\Nano\Downloads\jdbc-test1\jdbc-test1)
2018-11-03 21:08:33.003 INFO 2408 --- [ main] c.j.jdbctest1.JdbcTest1Application : No active profile set, falling back to default profiles: default
2018-11-03 21:08:33.770 INFO 2408 --- [ main] c.j.jdbctest1.JdbcTest1Application : Started JdbcTest1Application in 1.024 seconds (JVM running for 1.778)
2018-11-03 21:08:33.770 INFO 2408 --- [ main] c.j.jdbctest1.JdbcTest1Application : Creating tables
2018-11-03 21:08:33.770 INFO 2408 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2018-11-03 21:08:34.082 INFO 2408 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2018-11-03 21:08:35.135 INFO 2408 --- [ main] c.j.jdbctest1.JdbcTest1Application : Inserting Baggins Hopkins
2018-11-03 21:08:35.362 INFO 2408 --- [ main] c.j.jdbctest1.JdbcTest1Application : rows affected: 1
2018-11-03 21:08:35.362 INFO 2408 --- [ main] c.j.jdbctest1.JdbcTest1Application : Querying for employee
2018-11-03 21:08:36.065 INFO 2408 --- [ main] c.j.jdbctest1.JdbcTest1Application : Part A:
2018-11-03 21:08:36.065 INFO 2408 --- [ Thread-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
Sat Nov 03 21:08:36 KST 2018 WARN: Caught while disconnecting...
EXCEPTION STACK TRACE:
** BEGIN NESTED EXCEPTION **
javax.net.ssl.SSLException
MESSAGE: closing inbound before receiving peer's close_notify
STACKTRACE:
javax.net.ssl.SSLException: closing inbound before receiving peer's close_notify
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:129)
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:117)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:264)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:255)
at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:645)
at java.base/sun.security.ssl.SSLSocketImpl.shutdownInput(SSLSocketImpl.java:624)
at com.mysql.cj.protocol.a.NativeProtocol.quit(NativeProtocol.java:1312)
at com.mysql.cj.NativeSession.quit(NativeSession.java:182)
at com.mysql.cj.jdbc.ConnectionImpl.realClose(ConnectionImpl.java:1750)
at com.mysql.cj.jdbc.ConnectionImpl.close(ConnectionImpl.java:720)
at com.zaxxer.hikari.pool.PoolBase.quietlyCloseConnection(PoolBase.java:135)
at com.zaxxer.hikari.pool.HikariPool.lambda$closeConnection$1(HikariPool.java:441)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
** END NESTED EXCEPTION **
The Java Code:
#SpringBootApplication
public class JdbcTest1Application implements CommandLineRunner {
private static final Logger log = LoggerFactory.getLogger(JdbcTest1Application.class);
#Autowired
JdbcTemplate jdbcTemplate;
public static void main(String[] args) {
SpringApplication.run(JdbcTest1Application.class, args);
}
#Override
public void run(String... args) throws Exception {
log.info("Creating tables");
jdbcTemplate.execute("DROP TABLE IF EXISTS employees");
jdbcTemplate.execute("CREATE TABLE employees (emp_id int, name varchar(100), role varchar(100), status varchar(100))");
log.info("Inserting Baggins Hopkins");
int rowsAffected = jdbcTemplate.update("INSERT INTO EMPLOYEE(EMP_ID, NAME, ROLE, STATUS)"
+ " VALUES(1,'Baggins Hopkins','thief','WORKING')");
log.info("rows affected: "+ Integer.toString(rowsAffected));
log.info("Querying for employee");
String sql = "SELECT emp_id,name,role,status FROM employees";
List<Employee> employees = jdbcTemplate.query(sql,(rs, rowNum)->
new Employee(rs.getInt("emp_id"), rs.getString("name"),
rs.getString("role"),Status.valueOf(rs.getString("status"))));
log.info("Part A:");
employees.forEach(employee -> {log.info(employee.toString());
log.info("part a");});
}
}
Also just in case this matters, I pasted this code from application.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/employee_database
spring.datasource.username=employee
spring.datasource.password=employee
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

The SSL connection to the database is failing, try changing your datasource URL to:
spring.datasource.url=jdbc:mysql://localhost:3306/employee_database?useSSL=false

The warning looks like a MySQL driver bug with Java 11 and SSL enabled : https://bugs.mysql.com/bug.php?id=93590
Deactivating encryption because of a driver warning is a bad idea.
Your insertion problem looks more like a classic transaction issue though, I doubt it is related to the SSL warning.

This Worked for me
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
<version>8.0.20</version>
</dependency>

I also faced the same issue.
if you look the the stacktrace, it's cleary mentioned what to do -
Sat Mar 16 09:00:01 IST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'.
You need either to explicitly disable SSL by setting **useSSL=false**, or set **useSSL=true** and provide truststore for server certificate verification.
so after disabling the ssl by making changes in data source url solved the problem -
spring.datasource.url=jdbc:mysql://localhost:3306/security?useSSL=false

To solve this problem, it took me about three days.
(Edit: This is a workaround for testing and not actually a solution.)
At first, I started solving the problem from trying to configure my own SSL for mysql, and I spent quite a few hours on that. Too much time had passed until I realized configuring it had to do with Cmake and C++, which made me give up. It was very frustrating. However I did not give up and tried to disable SSL entirely through a method that hasn't been found. And I eventually did find the method. Here it is:
You have to use the legacy password for MySQL. The legacy password is the way MySQL authenticated things in version 5.7x.
Open up the MySQL installer again, and reconfigure the MySQL Server settings.
When you get there you will see this screen:
The screen that you should get to
You might get some errors when reaching the final stage of the reconfiguration:
I had problems at the final stage I had no idea how to fix so I uninstalled MySQL altogether. I use windows. I deleted the MySQL project root directory from Program Files to uninstall MySQL. I also deleted the databases saved in Program Data (a hidden folder in the C Drive) because I wanted to start afresh(WARNING: this will delete all your previously saved data!). Uninstalling MySQL from the control panel might not be enough to completely erase MySQL from your computer.
Delete all *.pem files in C:\ProgramData\MySQL\MySQL Server 8.0\Data. (or move it somewhere else, which is what I did)
You might not see ProgramData in the C Drive. That is because it is a hidden folder. In order to see hidden folders:
search for folder options in the control panel.
Go to view.
Under 'Advanced settings' and under 'Hidden files and folders' of that, click "Show hidden files, folders, and drives."
Go to C:\ProgramData\MySQL\MySQL Server 8.0 and open my.cnf (or my.ini). Add the following line after [mysqld]:
ssl=0
Then save. It should work now.
References:
https://community.atlassian.com/t5/Confluence-questions/MySQL-Public-Key-Retrieval-is-not-allowed/qaq-p/778956
https://scalegrid.io/blog/configuring-and-managing-ssl-on-your-mysql-server/

My similar problem in a tomcat trying to conect via ssl to Aurora mysql (AWS)
I solved the problem by updating the driver version from 'mysql-connector-java-5.1.40.jar' to 'mysql-connector-java-5.1.49.jar', and installing a root CA into ceacerts:
keytool -import -trustcacerts -file rds-ca-2019-root.pem -keystore /<your_java_home>/lib/security/cacerts
Hope be use to you

Try using the following URL. As they suggested use useSSL=false Also, Make sure to use <&amp> instead of just & when you have multiple properties defined in your URL.
jdbc:mysql://localhost:3306/TestDB?serverTimezone=PST&useSSL=false

I was also facing the same issue
But then i updated the mysql-connector-java version from 5.1.46 to 8.0.20 and by changing com.mysql.jdbc.Driver to com.mysql.cj.jdbc.Driver
it solved my issue

My similary prolem is in spark,
I solove the problem by down the java verion from
'openjdk version "1.8.0_275"' to 'openjdk version "1.8.0_265"',
hope be use to you

I had this issue and decided to use Carrier Pigeon Protocol's solution until I accidentally solved it by updating Tomcat from version 9.0.12 to 9.0.16.

I faced a similar issue when I upgraded the Java version in my server to 11 from 8.
The spring boot started supporting Java 11 from 2.1 and onwards. So make sure your project's dependencies are also updated accordingly. This is relevant for this answer as SpringBoot also influence MySQL connector, Hibernate core, and other dependencies.
The inability to connect to DB was resulting in some more NoClassDefFoundErrors. So make sure you solve this first before looking into other errors.
An example pom dependency for the SpringBoot starter
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.12.RELEASE</version>
<relativePath />
</parent>
Hope this helps someone.

Caused by: javax.persistence.PersistenceException: [PersistenceUnit: name-unit] Unable to build Hibernate SessionFactory
I had exactly the same problem, I also modified a false my useSSL like this useSSL=false and it works fine.
I think for those who use intelliJ ultimate the error the problem does not arise. But for those who use the community version "yes" also for those who are on netbeans like my case. This concerns the management of persistence.xml files and the EntityManagerHolder file

Rather than disabling SSL/TLS I appended the following to the database connection string: &enabledTLSProtocols=TLSv1.2

Related

Accessing data MySQL. Freezing on build

I am currently following along with this document:
https://spring.io/guides/gs/accessing-data-mysql/
and when I build using Gradle, the process does not finish executing.
20-10-11 18:12:09.099 INFO 4584 --- [task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2020-10-11 18:12:09.245 INFO 4584 --- [main] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2020-10-11 18:12:09.253 INFO 4584 --- [main] c.e.a.AccessingDataMysqlApplication : Started AccessingDataMysqlApplication in 4.295 seconds (JVM running for 4.699)
<=========----> 75% EXECUTING [4m 32s]
I am new to Spring and starting a project from the ground up and do not know where to begin looking to solve this issue.
You are not just building the application - you are actually running it. And since it is a web application, listening to web requests on localhost:8080/demo, it runs until you exit it with ctrl+c.

Sonar Qube plugin problems with Flex

I'm having problems after an upgrade of my Sonar Qube :(
I installed the newest version (5.0) of Sonar Qube using an existing MySQL database. The previous Sonar Qube version was 3.7.4.
I'm using it to analyze a pure ActionScript project using the Flex plugin (Version 2.1).
The problems to me seem threefold:
Just starting the server and viewing previous analysis results I get gray
rects where code quality used to be indicated in shades of green etc.
After installing the Flex plugin using the Update Center this
remains.
Running the sonar-runner (version 2.4) I get two types of errors:
A whole lot of these:
23:35:01.572 DEBUG - Resource org.sonar.api.resources.Directory#46815882[key=path/to/folder] was found using deprecated key. Please update your plugin.
After which the analysis exits with this:
23:35:01.585 INFO - Sensor FlexSquidSensor done: 4508 ms
23:35:01.585 INFO - Sensor org.sonar.plugins.flex.cobertura.CoberturaSensor#1f96a21e...
23:35:01.585 INFO - No Cobertura report provided (see 'sonar.flex.cobertura.reportPath' property)
23:35:01.585 INFO - Sensor org.sonar.plugins.flex.cobertura.CoberturaSensor#1f96a21e done: 0 ms
23:35:01.585 INFO - Sensor SCM Sensor (wrapped)...
23:35:01.612 INFO - SCM provider for this project is: git
23:35:01.612 INFO - Retrieve SCM blame information...
23:35:01.615 INFO - 280 files to be analyzed
23:35:04.012 DEBUG - Updating semaphore batch-nl.manno:Earz
23:35:04.447 DEBUG - Release semaphore on project : org.sonar.api.resources.Project#4aa0b07b[id=60,key=nl.manno:Earz,qualifier=TRK], with key batch-nl.manno:Earz
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 14.293s
Final Memory: 15M/123M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalArgumentException: Expected one blame result per line but provider returned 3 blame lines while file src/nl/aloft/earz/core/modules/interval/Interval.as has 76 lines
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:88)
at org.sonar.batch.scm.DefaultBlameOutput.blameResult(DefaultBlameOutput.java:68)
at org.sonar.plugins.scm.git.JGitBlameCommand.blame(JGitBlameCommand.java:131)
at org.sonar.plugins.scm.git.JGitBlameCommand.access$000(JGitBlameCommand.java:44)
at org.sonar.plugins.scm.git.JGitBlameCommand$1.call(JGitBlameCommand.java:105)
at org.sonar.plugins.scm.git.JGitBlameCommand$1.call(JGitBlameCommand.java:102)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:695)
logout
Now I used to have more plugins installed than just Flex (including the mentioned Cobertura) but after installing those Sonar Qube fails to run at all without too much notification (needless to say the runner won't run either).
Can anyone shed some light on this?
Thanks in advance,
Manno
We already faced this issue with files having old Mac line ends (CR or \r). Git will not consider them as line ends so you end up having less lines in your blame than in your file.
You can "clean" your file using mac2unix utility.

Play TypeSafe Activator fails to start - IllegalArgumentException "Failed to download new template catalog properties"

Moving from play 2.2.x to latest activator last night. Downloaded minimal 1.2.10, extracted it in program file (x86)\typesafe... and put the directory into the system path variable. cloned my repository, and when i executed activator run it downloaded the required modules and my app is up and running. All great so far. run works!
Then I tried to create a new app, and activator fails, with the following trace:
Checking for a newer version of Activator (current version 1.2.10)...
... our current version 1.2.10 looks like the latest.
Found previous process id: 9632
FOUND REPO = activator-local # file:////C:/Program%20Files%20(x86)/Typesafe/activator-1.2.10-minimal/repository
Play server process ID is 9760
[info] play - Application started (Prod)
[info] play - Listening for HTTP on /127.0.0.1:8888
[info] a.e.s.Slf4jLogger - Slf4jLogger started
[WARN] [10/30/2014 10:47:13.972] [default-akka.actor.default-dispatcher-2] [ActorSystem(default)] Failed to download new template ca
talog properties: java.lang.IllegalArgumentException: requirement failed: Source file 'C:\Users\admin\.activator\1.2.10\templates\in
dex.db_6e0565f0c8826b17.tmp' is a directory.
[ERROR] [10/30/2014 10:47:13.972] [default-akka.actor.default-dispatcher-2] [akka://default/user/template-cache] Could not find a te
mplate catalog. (activator.templates.repository.RepositoryException: We don't have C:\Users\admin\.activator\1.2.10\templates\cache.
properties with an index hash in it, even though we should have downloaded one
activator.templates.repository.RepositoryException: We don't have C:\Users\admin\.activator\1.2.10\templates\cache.properties with a
n index hash in it, even though we should have downloaded one
at activator.cache.TemplateCacheActor.preStart(TemplateCacheActor.scala:184)
at akka.actor.Actor$class.aroundPreStart(Actor.scala:470)
at activator.cache.TemplateCacheActor.aroundPreStart(TemplateCacheActor.scala:25)
at akka.actor.ActorCell.create(ActorCell.scala:580)
at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:456)
at akka.actor.ActorCell.systemInvoke(ActorCell.scala:478)
at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:263)
at akka.dispatch.Mailbox.run(Mailbox.scala:219)
at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
I've taken a look at several similar issues on SO and elsewhere. I've deleted .activator directory and retried, I've tried this process from behind a proxy and not, as well as offline (surely offline should work!), but it consistently gives the above error. activator ui gives the same error. I'm stuck and any suggestions would be appreciated. (Edit. tried with full activator download, rather than minimal, and I get the same error.)
Look for reasons it might be impossible to create or access 'C:\Users\admin.activator\1.2.10\templates\in
dex.db_6e0565f0c8826b17.tmp' ... maybe a permissions issue?
The failed check is for "is a directory" but that also fails if it just doesn't exist or can't be accessed.

Play Framework 2.3 on OpenShift database token substitution not working

I am trying to deploy a Play Framework 2.3 application to OpenShift.
I am following this example: https://github.com/JamesSullivan/play2-openshift-quickstart
Building and deploying the application is working (by that I mean the push to the git repository is working and the build is completing successfully), but during startup I see this error in play.log:
AbstractConnectionHook -
Failed to obtain initial connection Sleeping for 0ms and trying again.
Attempts left: 0. Exception: null.
Message:No suitable driver found for jdbc:${OPENSHIFT_POSTGRESQL_DB_URL}
Oops, cannot start the server.
Configuration error: Configuration error[Cannot connect to database [default]]
at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:94)
at play.api.Configuration.reportError(Configuration.scala:743)
at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:247)
at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:238)
at scala.collection.immutable.List.map(List.scala:272)
at play.api.db.BoneCPPlugin.onStart(DB.scala:238)
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:91)
at scala.collection.immutable.List.foreach(List.scala:381)
at play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:91)
at play.api.Play$$anonfun$start$1.apply(Play.scala:91)
at play.api.Play$$anonfun$start$1.apply(Play.scala:91)
at play.utils.Threads$.withContextClassLoader(Threads.scala:21)
at play.api.Play$.start(Play.scala:90)
at play.core.StaticApplication.<init>(ApplicationProvider.scala:55)
at play.core.server.NettyServer$.createServer(NettyServer.scala:244)
at play.core.server.NettyServer$$anonfun$main$3.apply(NettyServer.scala:280)
at play.core.server.NettyServer$$anonfun$main$3.apply(NettyServer.scala:275)
at scala.Option.map(Option.scala:145)
at play.core.server.NettyServer$.main(NettyServer.scala:275)
at play.core.server.NettyServer.main(NettyServer.scala)
Caused by: java.sql.SQLException: No suitable driver found for jdbc:${OPENSHIFT_POSTGRESQL_DB_URL}
at java.sql.DriverManager.getConnection(DriverManager.java:596)
at java.sql.DriverManager.getConnection(DriverManager.java:215)
at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:363)
at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:416)
at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:120)
at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:240)
... 18 more
So it looks like the ${OPENSHIFT_POSTGRESQL_DB_URL} environment variable token-substitution is not working.
If I log in to my application, I see this via env (obviously I replaced the username, password, IP and port for the purposes of posting here):
OPENSHIFT_POSTGRESQL_DB_URL=postgresql://xxxx:yyyy#ip:port
I have also tried using the other environment variables, like OPENSHIFT_POSTGRESQL_DB_HOST but those too do not get substituted.
The relevant part of my openshift.conf looks like this:
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:${OPENSHIFT_POSTGRESQL_DB_URL}"
db.default.user=myappuser
db.default.password=myapppassword
From the linked quickstart project, the following command is used to start the Play server (again, I replaced server-ip for the purposes of this post):
/app-root/runtime/repo/target/universal/stage/bin/myapp
"-DapplyEvolutions.default=true"
-Dhttp.port=8080 -Dhttp.address=server-ip
-Dconfig.resource=openshift.conf
You can see the openshift.conf file being referenced.
I tried a lot of things, eventually I found something that worked:
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://"${OPENSHIFT_POSTGRESQL_DB_HOST}":"${OPENSHIFT_POSTGRESQL_DB_PORT}/mydb
db.default.user=(((db-user)))
db.default.password=(((dp-password)))
The upshot is, it seems, you need to watch out very carefully for correct usage of the quotation characters.
It looks "wrong" (at first glance) since the last quotation character closes the string prior to the OPENSHIFT_POSTGRESQL_DB_PORT variable.

Oozie - Got exception running sqoop: Could not load db driver class: com.mysql.jdbc.Driver

I am trying to perform an sqoop export on HDP sandbox 2.1 via Oozie. When I run the Oozie job I get the following java runtime exception.
'>>> Invoking Sqoop command line now >>>
7598 [main] WARN org.apache.sqoop.tool.SqoopTool - $SQOOP_CONF_DIR
has not been set in the environment. Cannot check for additional
configuration.
7714 [main] INFO org.apache.sqoop.Sqoop - Running Sqoop version:
1.4.4.2.1.1.0-385
7760 [main] WARN org.apache.sqoop.SqoopOptions - Character argument
'\t' has multiple characters; only the first will be used.
7791 [main] WARN org.apache.sqoop.ConnFactory - $SQOOP_CONF_DIR has
not been set in the environment. Cannot check for additional
configuration.
7904 [main] INFO org.apache.sqoop.manager.MySQLManager - Preparing
to use a MySQL streaming resultset.
7905 [main] INFO org.apache.sqoop.tool.CodeGenTool - Beginning code
generation
7946 [main] ERROR org.apache.sqoop.Sqoop - Got exception running
Sqoop: java.lang.RuntimeException: Could not load db driver class:
com.mysql.jdbc.Driver Intercepting System.exit(1)
I have copied jdbc driver file "mysql-connector-java.jar" to Oozie's shared library folder which I believe is "/usr/lib/oozie/share/lib/sqoop/". I have restarted my sandbox and tried to perform the export with Oozie again and I still get the same error.
The export works perfectly fine when I try performing it only via sqoop, so I presume Oozie needs its own set of drivers.
My question is, which Oozie directory am I suppose to copy my jdbc drivers to?
If you guys think I'm doing something wrong or you need further information, please let me know.
Thank you for your time.
Normally for Oozie the sharelib directory is /user/oozie/share/lib/ on HDFS where "oozie" would be the name of the user which is used to start the Oozie Server. I don't know what that is in case of HDP sandbox 2.1 , but you can use ps command to figure that out.
And for jars needed for sqoop action, I think you should copy the jar to /user/oozie/share/lib/sqoop/ folder.