Derby嵌入式驱动程序错误XBM02请确保您的类路径包含正确的Derby软件

时间:2016-11-29 13:30:39

标签: java spring tomcat sap derby

我正在使用Spring构建JavaEE应用程序,我正在尝试将其与DerbyEmbeddedDriver连接。此应用程序将用于SAP Hana Cloud Platform试用版,因此我使用的是他们的Tomcat 8版本。

可以在https://tools.hana.ondemand.com/

找到Tomcat 8

SAP HCP:https://account.hanatrial.ondemand.com/

启动Tomcat服务器时发生错误。这就是我所看到的:

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

关于错误,我正在使用Maven,这是我的Derby依赖配置:

<dependency>
    <groupId>org.apache.derby</groupId>
    <artifactId>derbyclient</artifactId>
    <version>10.13.1.1</version>
</dependency>

所以我假设maven应该将它添加到Maven Dependencies lib中,因此我不需要在Classpath上明确添加它,对吧?

关于数据源对象的创建。此Tomcat服务器在Servers // config_master / connection_data / connection.properties下有一个配置文件,其中包含:

#----------------------------------------
# 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

这是由服务器使用的,它将创建一个新的数据源,并根据定义的名称将其注入上下文,所以当我想在应用程序上获取它时,我所做的就是:

@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;
    }
}

你能指出我可能遗失的任何东西吗?

1 个答案:

答案 0 :(得分:1)

我发现了问题......问题是derby依赖项在pom.xml上列出了两次作为测试依赖项......

此pom.xml文件已从另一个项目中重用,并在清理时跳过此文件。