0

我正在尝试在 karaf 中部署一个捆绑包。我想在其中创建一个连接到 h2 数据库的流程引擎。我在 pom.xml 中有依赖项:

<dependency>
    <groupId>com.h2database</groupId>
    <artifactId>h2</artifactId>
    <version>1.4.190</version>
</dependency>

ini()方法中,我尝试使用以下方法创建引擎进程:

ProcessEngine processEngine = ProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration()
    .setDatabaseSchemaUpdate(ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
    .setJdbcUrl("jdbc:h2:mem:my-own-db;DB_CLOSE_DELAY=1000")
    .setJobExecutorActivate(true)
    .buildProcessEngine();

尽管如此,当我部署捆绑包时,在 karaf 控制台中出现错误:

Caused by: org.apache.ibatis.datasource.DataSourceException: Error setting driver on UnpooledDataSource. Cause: java.lang.ClassNotFoundException: org.h2.Driver
    at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.initializeDriver(UnpooledDataSource.java:179)
    at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.getConnection(UnpooledDataSource.java:57)
    at org.apache.ibatis.datasource.pooled.PooledDataSource.popConnection(PooledDataSource.java:349)
    at org.apache.ibatis.datasource.pooled.PooledDataSource.getConnection(PooledDataSource.java:55)

…………

Caused by: java.lang.ClassNotFoundException: org.h2.Driver
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.apache.ibatis.datasource.unpooled.UnpooledDataSource.initializeDriver(UnpooledDataSource.java:173)
4

1 回答 1

0

你能打印构建的 MANIFEST 吗?bundle:headers 的结果我猜你的包尝试导入 h2 驱动程序,因为你没有将它设置为私有。

快速修复,在 karaf 中运行 bundle:install mvn:com.h2database/h2/1.4.199

于 2020-08-19T17:37:13.477 回答