I am building a JavaEE application with Spring and I am trying to connect it with the DerbyEmbeddedDriver. This application will be used on SAP HANA Cloud Platform trial, so I am using their version of Tomcat 8.
Tomcat 8 can be found at: https://tools.hana.ondemand.com/
SAP HCP: https://account.hanatrial.ondemand.com/
The error occurs when I start the Tomcat server. This is what I see:
Caused by: ERROR XJ041: Failed to create database 'memory:DemoDB', see the next exception for details. at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) at org.apache.derby.impl.jdbc.SQLExceptionFactory.wrapArgsForTransportAcrossDRDA(Unknown Source) ... 113 more Caused by: ERROR XBM02: Startup failed due to missing functionality for org.apache.derby.iapi.types.DataValueFactory. Please ensure your classpath includes the correct Derby software. at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) at org.apache.derby.iapi.error.StandardException.newException(Unknown Source) at org.apache.derby.iapi.services.monitor.Monitor.missingImplementation(Unknown Source) at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.startModule(Unknown Source) at org.apache.derby.impl.services.monitor.FileMonitor.startModule(Unknown Source) at org.apache.derby.iapi.services.monitor.Monitor.bootServiceModule(Unknown Source) at org.apache.derby.impl.db.BasicDatabase.boot(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.boot(Unknown Source) at org.apache.derby.impl.services.monitor.TopService.bootModule(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.bootService(Unknown Source) at org.apache.derby.impl.services.monitor.BaseMonitor.createPersistentService(Unknown Source) at org.apache.derby.impl.services.monitor.FileMonitor.createPersistentService(Unknown Source) at org.apache.derby.iapi.services.monitor.Monitor.createPersistentService(Unknown Source) ... 110 more
Which regards to the error, I am using Maven and this is my Derby dependency config:
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyclient</artifactId>
<version>10.13.1.1</version>
</dependency>
So I assume maven should add this to the Maven Dependencies lib, hence I don't need to add explicitly this on the Classpath, right?
And regarding the creation of the Data Source object. This Tomcat server has a config file under Servers//config_master/connection_data/connection.properties that contains:
#----------------------------------------
# Connection parameters for a local Derby database
# DB and tables are created automatically (if missing)
#----------------------------------------
javax.persistence.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
javax.persistence.jdbc.url=jdbc:derby:memory:DemoDB;create=true
javax.persistence.jdbc.user=demo
javax.persistence.jdbc.password=demo
eclipselink.target-database=Derby
#----------------------------------------
# Connection parameters MaxDB
#----------------------------------------
#javax.persistence.jdbc.driver=com.sap.dbtech.jdbc.DriverSapDB
#javax.persistence.jdbc.url=jdbc:sapdb://<host>/DEMO
#javax.persistence.jdbc.user=demo
#javax.persistence.jdbc.password=demo
#eclipselink.target-database=org.eclipse.persistence.platform.database.MaxDBPlatform
This is consumed by the Server and it will create a new Data Source and inject it on the context based on the name defined, so when I want to get it on the Application all I do is this:
@Configuration
public class DataSourceConfig {
@Bean
public DataSource dataSource() throws NamingException {
InitialContext ctx = new InitialContext();
DataSource dataSource = (DataSource) ctx.lookup("java:comp/env/memory/DemoDB");
return dataSource;
}
}
Can you point anything that I might be missing?
I found the issue... The problem was that the derby dependency was listed twice on the pom.xml as a test dependency...
This pom.xml file was reused from another project and skipped this when sanitizing it.