Roman Kharkovski Roman Kharkovski - 3 months ago 70
Java Question

Can't find valid JDBC driver when deploying Liberty app in Bluemix with ElephantSQL

I have a WebSphere Liberty webapp that I develop and run locally on my laptop with Derby DB using JPA to work with the database. I used to deploy it into Bluemix with SQLDB (retired by IBM in May 2016) and it all worked fine with automatic wiring of the service. Since SQLDB is no longer available, the only free SQL I was able to find on Bluemix is ElephantSQL, however the autowiring does not seem to work. Here is the error I get after the deployment:

Program error occured: CWWJP0013E: The server cannot locate the java:comp/env/jdbc/TriReplicatorDB data source for the TriReplicatorPersistenceUnit persistence unit because it has encountered the following exception: javax.naming.NamingException: CWNEN1001E: The object referenced by the java:comp/env/jdbc/TriReplicatorDB JNDI name could not be instantiated. If the reference name maps to a JNDI name in the deployment descriptor bindings for the application performing the JNDI lookup, make sure that the JNDI name mapping in the deployment descriptor binding is correct. If the JNDI name mapping is correct, make sure the target resource can be resolved with the specified name relative to the default initial context. [Root exception is CWNEN0030E: The server was unable to obtain an object instance for the java:comp/env/jdbc/TriReplicatorDB reference. The exception message was: CWNEN1006E: The server was unable to obtain an object for the jdbc/TriReplicatorDB binding with the javax.sql.DataSource type. The exception message was: java.sql.SQLNonTransientException: DSRA4000E: A valid JDBC driver implementation class was not found for the jdbcDriver jdbcDriver[myDerbyJDBCdriver] using the library [/home/vcap/app/wlp/usr/servers/triServer/lib/postgresql-jdbc-9.4.1209.jar]].

The way I upload the web app is by packaging the server and using
cf push
command. Here is the resulting server.xml file:

<server description="new server">
<!-- Enable features -->
<httpEndpoint httpPort="${port}" id="defaultHttpEndpoint" host="*"/>
<webContainer deferServletLoad="false" trustHostHeaderPort="true" extractHostHeaderPort="true"/>
<applicationMonitor updateTrigger="mbean"/>
<!-- This is the application itself -->
<webApplication contextRoot="/" id="Tri-Replicator" location="Tri-Replicator.war" name="Tri-Replicator">
<jdbcDriver id="myDerbyJDBCdriver">
<library name="DerbyLib">
<fileset dir="C:\projects_c\Tri-Replicator-16\db\db-derby-\lib" includes="derby.jar"/>
<fileset dir='${server.config.dir}/lib' includes='postgresql-jdbc-9.4.1209.jar'/>
<!-- Use local Derby DB for local testing on laptop, but when deployed into BlueMix this will automatically be rewired to use SQL DB instance -->
<dataSource id="DerbyConnection" jdbcDriverRef="myDerbyJDBCdriver" jndiName="jdbc/TriReplicatorDB">
<properties createDatabase="create" databaseName="${}" user="${}" password="${}" serverName="${}" portNumber="${}"/>
<include location='runtime-vars.xml'/>
<httpDispatcher enableWelcomePage='false'/>
<config updateTrigger='mbean'/>
<appstate appName='Tri-Replicator' markerPath='${home}/../.liberty.state'/>

As an alternative question - can anybody suggest other small free plan for SQL database in Bluemix? PostgreSQL and DB2 do not provide free plans.


The exception reported states the following:

A valid JDBC driver implementation class was not found 
for the jdbcDriver jdbcDriver[myDerbyJDBCdriver]

This exception is saying that it is unable to locate the Connection Pooling DataSource class within the postgresql-jdbc-9.4.1209.jar.

WLP is working as design and requires additional configuration in the server.xml since WLP is only able to locate the implementation classes for a certain number of known databases[1]. I reviewed the postgresql-jdbc-9.4.1209.jar driver and found the implementation class as the following:


You should update the server.xml file with the following: