Thanks for the update. I will investigate tomorrow. I will keep you posted.
Regards
JB
Le mar. 18 f?vr. 2020 ? 17:01, Erwin Hogeweg <erwin.hoge...@me.com> a ?crit :
Lukas,I believe I have some success by copying configuration from my env. to the prehook test.2020-02-18T10:35:05,924 | INFO | features-3-thread-1 | PreHookTest | 50 - prehook - 1.0.0.SNAPSHOT | Starting PreHookTest ...2020-02-18T10:35:05,928 | WARN | activator-1-thread-1 | SshUtils | 38 - org.apache.karaf.shell.ssh - 4.2.8 | Configured cipher 'aes256-ctr' not available2020-02-18T10:35:05,931 | INFO | features-3-thread-1 | ServiceTrackerHelper | 16 - org.ops4j.pax.jdbc.config - 1.4.4 | Obtained service dependency: (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc. driver.name=sqlite)) 2020-02-18T10:35:05,931 | WARN | activator-1-thread-1 | SshUtils | 38 - org.apache.karaf.shell.ssh - 4.2.8 | Configured cipher 'aes192-ctr' not available2020-02-18T10:35:05,932 | INFO | features-3-thread-1 | DataSourceRegistration | 16 - org.ops4j.pax.jdbc.config - 1.4.4 | Found DataSourceFactory. Creating DataSource prehook-test2020-02-18T10:35:05,953 | INFO | features-3-thread-1 | DataSourceRegistration | 16 - org.ops4j.pax.jdbc.config - 1.4.4 | Executing pre hook for DataSource prehook-test2020-02-18T10:35:05,953 | INFO | features-3-thread-1 | PreHookTest | 50 - prehook - 1.0.0.SNAPSHOT | Called PreHookTest.prepare() ?I reduced the maven-bundle-plugin to:<groupId>org.apache.felix</groupId><artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions><configuration><!-- Do not generate that OBR file in the local maven cache --><obrRepository>NONE</obrRepository><instructions><_nouses>true</_nouses><Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> </instructions></configuration>And I changed the component annotations to:@Component(// scope = ServiceScope.SINGLETON,immediate = true,// service = PreHook.class,property = "name=prehook-test-hook")public class PreHookTest implements PreHook {?I may have thrown away too much, but at least this is a good starting point.ErwinOn Feb 17, 2020, at 13:55, Erwin Hogeweg <erwin.hoge...@me.com> wrote:Lukas,I am currently on the road but I will try this ASAP.Kind Regards,ErwinEl feb. 17, 2020, a la(s) 08:55, Roedl Lukas <lukas.ro...@ait.ac.at> escribi?:?Hi,We?ve similar problems with a Pax JDBC Pre Hook getting called.I?ve prepared a minimal example on https://github.com/roedll/pax-jdbc-pre-hook-test using SQLite to make it a bit more concrete.Apache Karaf 4.2.8 in combination with Pax JDBC 1.4.4 is used.The DataSource is specified in the file ?org.ops4j.datasource-prehook-test.cfg? (see [1]) and without a PreHook defined the DataSource is published as expected: dataSourceName = prehook-testfelix.fileinstall.filename = file:/X:/pax-jdbc-pre-hook-test/framework/target/assembly/etc/org. ops4j.datasource-prehook-test.cfg objectClass = [javax.sql.DataSource]osgi.jdbc.driver.name = sqliteosgi.jndi.service.name = prehook-testpax.jdbc.managed = trueservice.bundleid = 16service.factoryPid = org.ops4j.datasourceservice.id = 88service.pid = org.ops4j.datasource.5a7b2e4b-4781-4b60-b707-74a48e210bda service.scope = singletonurl = "">With the PreHook specified (like ?ops4j.preHook=prehook-test-hook?)the last log entry is ?Waiting for service dependency: (&(objectClass=org.ops4j.pax.jdbc. hook.PreHook)(name=prehook-test- hook))? event if the PreHook itself is started and active: Pax JDBC - Test - PreHook (21) provides:---------------------------------------- component.id = 0component.name = at.roedll.pax.jdbc.pre.hook.test.PreHookTest name = prehook-test-hookobjectClass = [org.ops4j.pax.jdbc.hook.PreHook]service.bundleid = 21service.id = 75service.scope = bundleCan someone which doesn?t have problems with this, please take a short look, if there are some differences between the working configurations and this example?Best,LukasVon: Erwin Hogeweg <erwin.hoge...@me.com>
Gesendet: Donnerstag, 23. Januar 2020 22:40
An: user@karaf.apache.org
Betreff: Re: Karaf 4.2.8-SNAPSHOT - pax-jdbc 1.4.4 - prehook not workingHi Alex,Below a similar sequence from my log.From your log it seems that the Derby DataSourceFactory is not resolved. I remember that at some point I changed the driver.name entry in the config to a driver.class entry. That is for a mySQL database though but but maybe?Another silly question: Is your datasource functional if you leave out the preHook?Obtained service dependency: (objectClass=org.ops4j.pax.jdbc.config.ConfigLoader) Waiting for service dependency: (objectClass=org.ops4j.pax.jdbc.config.ConfigLoader) Waiting for service dependency: (&(pool=*)(!(pax.jdbc.managed=true))(|(objectClass=javax.sql.DataSource) (objectClass=javax.sql.XADataSource))) Waiting for service dependency: (&(objectClass=org.ops4j.pax.jdbc.pool.common.PooledDataSourceFactory) (pool=dbcp2)(xa=false)) Waiting for service dependency: (&(objectClass=org.ops4j.pax.jdbc.pool.common.PooledDataSourceFactory) (pool=dbcp2)(xa=false)) Obtained service dependency: (&(objectClass=org.ops4j.pax.jdbc.pool.common.PooledDataSourceFactory) (pool=dbcp2)(xa=false)) Obtained service dependency: (&(objectClass=org.ops4j.pax.jdbc.hook.PreHook)(name=seegate)) Obtained service dependency: (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc. driver.class=com.mysql.jdbc.Driver)) Cheers,ErwinOn Jan 23, 2020, at 13:22, Alex Soto <alex.s...@envieta.com> wrote:Yes, the migration service is being registered:Obtained service dependency: (objectClass=org.ops4j.pax.jdbc.config.ConfigLoader) Waiting for service dependency: (objectClass=org.ops4j.pax.jdbc.config.ConfigLoader) Waiting for service dependency: (&(pool=*)(!(pax.jdbc.managed=true))(|(objectClass=javax.sql.DataSource) (objectClass=javax.sql.XADataSource))) Obtained service dependency: (&(objectClass=org.ops4j.pax.jdbc.hook.PreHook)(name=querierDB)) Waiting for service dependency: (&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc. driver.name=derby)) Andservice:list org.ops4j.pax.jdbc.hook.PreHook [org.ops4j.pax.jdbc.hook.PreHook]---------------------------------component.id = 29component.name = org.enquery.encryptedquery.querier.data.maint.Migration name = querierDBservice.bundleid = 35service.id = 276service.scope = bundleProvided by :EncryptedQuery :: Querier :: Data (35)Used by:OPS4J Pax JDBC Config (210)Best regards,
Alex sotoOn Jan 22, 2020, at 1:06 PM, Erwin Hogeweg <erwin.hoge...@me.com> wrote:Just this week I upgraded from karaf-1.2.6 and pax-jdbc-1.3.1 to karaf-1.2.8-SNAPSHOT and pax-jdbc-1.4.4 and I didn?t run into any issues.Stupid question, but can you confirm that the Migrator class is instantiated and that the component is active?com.*.Migrator in bundle 129 (db.init:1.0.0.SNAPSHOT_20200122-1230) enabled, 1 instance.
Id: 18, State:ACTIVE
Initially I missed some Package-Imports on the migrator bundle which left the component in the SATISFIED (I believe) state. After scrolling through the logs I discovered a CNFE which pointed me in the right direction.ErwinOn Jan 22, 2020, at 12:53, Alex Soto <alex.s...@envieta.com> wrote:I tested with Karaf 4.2.7 and various versions of Pax-JDBC.The hook is not being called stating with Pax-JDBC 1.3.4.Something must have changed in Pax-JDBC 1.3.4 as everything else remains the same in my tests.Best regards,
Alex sotoOn Jan 22, 2020, at 12:39 PM, Erwin Hogeweg <erwin.hoge...@me.com> wrote:Ignore the different datasource names. I messed up the ?replace all? :-)On Jan 22, 2020, at 12:36, Erwin Hogeweg <erwin.hoge...@me.com> wrote:It seems to work for me with Karaf-4.2.8-SNAPSHOT and pax-jdbc-1.4.4.12 ? Active ? 80 ? 1.4.4 ? OPS4J Pax JDBC Generic Driver Extender
13 ? Active ? 80 ? 1.4.4 ? OPS4J Pax JDBC Config
14 ? Active ? 80 ? 1.4.4 ? OPS4J Pax JDBC Pooling Support Base[features-2-thread-1] INFO org.ops4j.pax.jdbc.config.impl.DataSourceRegistration - Found DataSourceFactory. Creating DataSource jdbc/mydatasource
[features-2-thread-1] INFO org.ops4j.pax.jdbc.config.impl.DataSourceRegistration - Executing pre hook for DataSource jdbc/mydatasource
INFO 1/22/20 12:32 PM: liquibase: Successfully acquired change log lock
INFO 1/22/20 12:32 PM: liquibase: Reading from seegate.DATABASECHANGELOG
INFO 1/22/20 12:32 PM: liquibase: Successfully released change log lock
[features-2-thread-1] INFO org.ops4j.pax.jdbc.config.impl.DataSourceRegistration - Pre hook finished. Publishing DataSource jdbc/mydatasource
[features-2-thread-1] INFO org.apache.aries.jpa.container.impl.DataSourceTracker - Found DataSource for seegate.pu osgi:service/javax.sql. DataSource/(osgi.jndi.service.name= jdbc/mydatasource)
FWIW - I did change the exception handling in Migrator to better see when/if the migration fails:@Overridepublic void prepare(DataSource ds) throwsSQLException {try (Connection connection =ds.getConnection()) { prepare(connection);} catch (LiquibaseException e) {LOG.error(e.getClass().getName() + ": " + e.getMessage()); // throw new RuntimeException(e);}}Cheers,ErwinOn Jan 22, 2020, at 11:11, Alex Soto <alex.s...@envieta.com> wrote:Same is happening to me, it works with Pax-JDBC 1.3.0, but not with Pax-JDBC 1.4.0, which is the one included in Karaf 4.2.7.Best regards,
Alex sotoOn Jan 20, 2020, at 9:10 AM, stefang <stefan.gue...@me.com> wrote:Hi,
we are not able to run Christian's Example:
https://github.com/cschneider/Karaf-Tutorial/blob/master/liquibase/service/ src/main/java/net/lr/tutorial/db/ service/Migrator.java
Must be something todo with pax-jdbc 1.4.4 (wich comes with 4.2.8)
Karaf 4.2.6 (pax-jdbc 1.3.5)works fine.
Stefan
--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html