[ https://issues.apache.org/jira/browse/KARAF-4124?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15011518#comment-15011518 ]
Markus Rathgeb commented on KARAF-4124: --------------------------------------- I want to switch easy between different database drivers. So I need to change: * the dialect for hibernate * the data source configuration * the respective used feature But the following mechanism is much better because all is configured in one file / feature: * feature for MariaDB {noformat} <?xml version="1.0" encoding="UTF-8"?> <features name="${project.artifactId}-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.3.0"> <feature name='${project.artifactId}' description='${project.name}' version='${project.version}'> <details>${project.description}</details> <feature>pax-jdbc-mariadb</feature> <config name="org.apache.aries.jpa.testdb"> hibernate.dialect=org.hibernate.dialect.MySQL5Dialect hibernate.hbm2ddl.auto=create-drop </config> <config name="org.ops4j.datasource-testdb"> osgi.jdbc.driver.name=mariadb user=foo password=bar url=jdbc:mariadb://127.0.0.1:3306/test dataSourceName=testdb </config> </feature> </features> {noformat} * feature for H2 in memory {noformat} <?xml version="1.0" encoding="UTF-8"?> <features name="${project.artifactId}-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.3.0"> <feature name='${project.artifactId}' description='${project.name}' version='${project.version}'> <details>${project.description}</details> <feature>pax-jdbc-h2</feature> <config name="org.apache.aries.jpa.testdb"> hibernate.dialect=org.hibernate.dialect.H2Dialect hibernate.hbm2ddl.auto=create-drop </config> <config name="org.ops4j.datasource-testdb"> osgi.jdbc.driver.name=H2-pool-xa url=jdbc:h2:mem:test dataSourceName=testdb </config> </feature> </features> {noformat} One note: configfile is working as expected, but this means 3 files (2x config, 1x feature). > feature config installer adds property to config > ------------------------------------------------ > > Key: KARAF-4124 > URL: https://issues.apache.org/jira/browse/KARAF-4124 > Project: Karaf > Issue Type: Bug > Components: karaf-feature > Affects Versions: 4.0.3 > Reporter: Markus Rathgeb > > The <config/> element in a feature XML allows a feature to create and/or > populate a configuration (identified by a configuration PID). > The "FeatureConfigInstaller" adds a custom property to the configuration. > key = "org.apache.karaf.features.configKey" > value = result of function call "createConfigurationKey(pid[0], pid[1])" > There are bundles that cannot handle additional properties in the > configuration. > For example: > * using Aries JPA + Hiberante + h2 > * the configuration is installed by a feature and a realted config entry > * this will result in a non working setup > {noformat} > Caused by: org.h2.jdbc.JdbcSQLException: Unsupported connection setting > "ORG.APACHE.KARAF.FEATURES.CONFIGKEY" [90113-172] > at > org.h2.message.DbException.getJdbcSQLException(DbException.java:329) > at org.h2.message.DbException.get(DbException.java:169) > at org.h2.message.DbException.get(DbException.java:146) > at > org.h2.engine.ConnectionInfo.readSettingsFromURL(ConnectionInfo.java:266) > at org.h2.engine.ConnectionInfo.<init>(ConnectionInfo.java:77) > at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:90) > at org.h2.Driver.connect(Driver.java:73) > at > org.h2.jdbcx.JdbcDataSource.getJdbcConnection(JdbcDataSource.java:187) > at > org.h2.jdbcx.JdbcDataSource.getXAConnection(JdbcDataSource.java:323) > at > org.apache.commons.dbcp2.managed.DataSourceXAConnectionFactory.createConnection(DataSourceXAConnectionFactory.java:112) > at > org.apache.commons.dbcp2.managed.PoolableManagedConnectionFactory.makeObject(PoolableManagedConnectionFactory.java:66) > at > org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868) > at > org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435) > at > org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363) > at > org.apache.commons.dbcp2.managed.ManagedConnection.updateTransactionStatus(ManagedConnection.java:127) > ... 132 more > {noformat} > There is a conditional branch in the "findExistingConfiguration" function to > filter (find) the configuration using that property instead of the > service.pid (this is another conditional branch). > Is there any reason for using that property? > I changed the "FeatureConfigInstaller" to not append that property and the > above example is working now. -- This message was sent by Atlassian JIRA (v6.3.4#6332)