Setup database structure before bundle under test is started with pax exam + karaf

2017-08-24 Thread karsten . blume
Hello everybody,
i am running pax exam 4 with a karaf 3 container.
The bundle under test is a camel 2.16.3 bundle.
The bundle uses a time triggered camel jpa component and pax-jdbc with (XA 
and pooling) to instantiate the datasource.
For the test i need some table and some test data in a schema.
If i run the test with an existing postgres database everything is fine. If 
i try to instantiate and setup the database first (H2 or Derby) the bundle 
under test does not 
find the database with the jndi name:
javax.naming.NameNotFoundException: 
osgi:service/javax.sql.DataSource/"(osgi.jndi.service.name=jdbc/scv_xa)"

How can i startup and setup the temporary db before the bundle under test 
is started?

Thanks and best regards
Karsten

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setup database structure before bundle under test is started with pax exam + karaf

2017-08-30 Thread karsten . blume
full Stack Trace for exception and log excerpt
datasources.osgi includes the pax-jdbc config files in live, for test the 
additional pax-jdbc bundles for derby and config files are added in the 
PaxExam configure() method
The only strange thing i see now is that the "Creating DataSource" log 
message is after the JNDI search by "org.apache.aries.jpa.container".
Might this be the cause? And how to change?

...
2017-08-30 11:26:42,770 | INFO  | 
FelixStartLevel| 
res.internal.FeaturesServiceImpl | Installing feature datasources.osgi 
17.32.2-SNAPSHOT | bcid:  
exchange:  msgid: 
2017-08-30 11:26:42,770 | INFO  | 
FelixStartLevel| 
res.internal.FeaturesServiceImpl | Installing feature camel-jdbc 2.16.3 | 
bcid:  exchange:  
msgid: 
2017-08-30 11:26:42,772 | INFO  | 
FelixStartLevel| 
res.internal.FeaturesServiceImpl | Installing feature pax-jdbc-config 0.9.0 
| bcid:  exchange:  
msgid: 
2017-08-30 11:26:42,772 | INFO  | 
FelixStartLevel| 
res.internal.FeaturesServiceImpl | Installing feature pax-jdbc-spec 0.9.0 | 
bcid:  exchange:  
msgid: 
2017-08-30 11:26:42,776 | INFO  | 
FelixStartLevel| 
res.internal.FeaturesServiceImpl | Installing feature pax-jdbc-postgresql 
0.9.0 | bcid:  exchange:  
msgid: 
2017-08-30 11:26:42,777 | INFO  | 
FelixStartLevel| 
res.internal.FeaturesServiceImpl | Installing feature pax-jdbc-pool-dbcp2 
0.9.0 | bcid:  exchange:  
msgid: 



2017-08-30 11:26:44,968 | INFO  | 
FelixStartLevel| 
res.internal.FeaturesServiceImpl | Installing feature pax-jdbc-derby 0.9.0 
| bcid:  exchange:  
msgid: 
2017-08-30 11:26:44,968 | INFO  | 
FelixStartLevel| 
res.internal.FeaturesServiceImpl | Installing feature pax-jdbc-spec 0.9.0 | 
bcid:  exchange:  
msgid: 

2017-08-30 11:27:04,677 | INFO  | Factory Update: 
factoryPid=[org.ops4j.datasource]) | nfig.impl.DataSourceRegistration | 
Detected config for DataSource jdbc/scv. Tracking DSF with filter 
(&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.name=derby-pool))
 
| bcid:  exchange:  
msgid: 
2017-08-30 11:27:05,343 | INFO  | Factory Update: 
factoryPid=[org.ops4j.datasource]) | nfig.impl.DataSourceRegistration | 
Detected config for DataSource jdbc/scv_xa. Tracking DSF with filter 
(&(objectClass=org.osgi.service.jdbc.DataSourceFactory)(osgi.jdbc.driver.name=derby-pool-xa))
 
| bcid:  exchange:  
msgid: 
...

2017-08-30 11:27:27,421 | INFO  | 
FelixStartLevel| 
openjpa.Runtime  | Starting OpenJPA 2.2.2 | 
bcid:  exchange:  
msgid: 
2017-08-30 11:27:27,482 | ERROR | 
FelixStartLevel| 
org.apache.aries.jpa.container   | The DataSource 
osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/scv_xa) 
required by bundle UNDERTEST/17.32.2.SNAPSHOT could not be found. | 
bcid:  exchange:  
msgid: 
javax.naming.NameNotFoundException: 
osgi:service/javax.sql.DataSource/"(osgi.jndi.service.name=jdbc/scv_xa)"
at 
org.apache.aries.jndi.url.ServiceRegistryContext.lookup(ServiceRegistryContext.java:113)
at 
org.apache.aries.jndi.url.ServiceRegistryContext.lookup(ServiceRegistryContext.java:138)
at 
org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at 
org.apache.aries.jpa.container.unit.impl.JndiDataSource.getDs(JndiDataSource.java:66)
at 
org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource.getConnection(DelayedLookupDataSource.java:36)
at 
org.apache.openjpa.lib.jdbc.DelegatingDataSource.getConnection(DelegatingDataSource.java:110)
at 
org.apache.openjpa.lib.jdbc.DecoratingDataSource.getConnection(DecoratingDataSource.java:87)
at 
org.apache.openjpa.jdbc.sql.DBDictionaryFactory.newDBDictionary(DBDictionaryFactory.java:91)
at 
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:603)
at 
org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(Mappin

Re: Setup database structure before bundle under test is started with pax exam + karaf

2017-08-30 Thread karsten . blume
How is your test triggered? By timer? 

The test is started automatically by PaxExam.

>
> Can you create a simpler test-case you can publish on github that shows 
> your problem?
>

Not really, because there are several additional dependencies (db 
unrelated) involved.

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setup database structure before bundle under test is started with pax exam + karaf

2017-08-31 Thread karsten . blume
I have added to the blueprint description of my bundle under test:



with no result.
Getting still the unfriendly Exception and after that the 
INFO  | FelixStartLevel   
 | nfig.impl.DataSourceRegistration | Creating 
DataSource jdbc/scv 

message.

what do you mean by :
-- "
Beside that you should check if camel can even use those fetched service as 
a datasource instead of JNDI because that might create issues if the 
service changes while blueprint keeps track of those changes."?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setup database structure before bundle under test is started with pax exam + karaf

2017-08-31 Thread karsten . blume
here is some more information:
i have started the karaf service created by pax exam manually, getting on 
the command line:

service:list DataSource shows:

[javax.sql.DataSource]
--
 databaseName = scvdev
 dataSourceName = jdbc/scv_xa
 felix.fileinstall.filename = 
file:/D:/HYPER-V/data/git/AMX/hoi.itest.karaf/target/pax/fe9a14e5-ac9a-47a3-acb8-bec13851ab36/etc/org.ops4j.datasource-scv_xa.cfg
 osgi.jdbc.driver.name = derby-pool-xa
 osgi.jndi.service.name = jdbc/scv_xa
 password = xxx
 service.factoryPid = org.ops4j.datasource
 service.id = 409
 service.pid = org.ops4j.datasource.5d401396-0dc7-445e-8dad-0c1077a2a28f
 url = jdbc:derby:target/scvdev;create=true;user=xxx;password=xxx
 user = xxx
Provided by :
 OPS4J Pax JDBC Config (39)

also 
jdbc:datasources shows:
jdbc/scv_xa, 409   | Apache Derby | 10.11.1.1 - (1616546) | 
jdbc:derby:target/scvdev


| OK
and jdbc:tables shows all the Derby system tables.

So this seems to be a timing problem between those bundles.
Wondering does nobody use the pax-jdbc bundle and pax exam?

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Setup database structure before bundle under test is started with pax exam + karaf

2017-09-12 Thread karsten . blume
Hello Christian,
the PreHook is in pax-jdbc 1.2.0 but i cannot run this in Karaf 3.0.7, the 
namespace of the features.xml is unknown.
2017-09-12 10:17:06,820 | WARN  | 
FelixStartLevel| 
res.internal.FeaturesServiceImpl | Unable to add features repository 
mvn:org.ops4j.pax.jdbc/pax-jdbc-features/1.2.0/xml/features at startup | 
bcid:
exchange:  msgid:
java.lang.IllegalArgumentException: Unrecognized root element: 
{http://karaf.apache.org/xmlns/features/v1.4.0}features
at 
org.apache.karaf.features.internal.FeatureValidationUtil.validate(FeatureValidationUtil.java:83)
at 
org.apache.karaf.features.internal.FeaturesServiceImpl.validateRepository(FeaturesServiceImpl.java:174)
at 
org.apache.karaf.features.internal.FeaturesServiceImpl.internalAddRepository(FeaturesServiceImpl.java:245)

-- 
-- 
--
OPS4J - http://www.ops4j.org - ops4j@googlegroups.com

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ops4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.