You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Borut Bolčina <bo...@gmail.com> on 2012/04/16 14:23:07 UTC

Deploying data sources

Hello,

my first post here, so bare with me please - newbie on board.

I am trying to deploy my first camel route to Karaf and this route must be
configurable (html address) and must persist some data with jpa component.
This route is happily persisting in my test (outside osgi container).

Now I am reading
https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-mysql.xml
where
it says I should copy the file to Karaf's deploy folder.

And the question: What is the practice of deploying data sources? Should I
create a features project which includes a blueprint for my route's data
source?

Let's say my route needs connection to mysql database, so the feature
project would include features.xml

<?xml version="1.0" encoding="UTF-8"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0
http://karaf.apache.org/xmlns/features/v1.0.0">

<feature name="weather" version="${pom.version}">
<bundle>mvn:mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.stax-api-1.0/1.9.0</bundle>
 <bundle>mvn:mvn:mysql/mysql-connector-java/5.1.18</bundle>
<bundle>mvn:my.company/route-weather-current/${pom.version}</bundle>
 *<bundle>my datasource blueprint</bundle>*
<configfile
finalname="/etc/weather.cfg">mvn:my.company/features-weather/${pom.version}/cfg</configfile>
 </feature>
</features>

I guess then the only command to install my Camel route to Karaf would then
be feature:install and all the dependencies including datasource and
configuration would be installed before. And how to package the "my
datasource blueprint"?

Or is there some other practice?

Thanks,
borut

Re: Deploying data sources

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Borut,

a datasource is exposed as an OSGi service, and referenced with JNDI 
name using Aries.

You have an exemple here:
http://svn.apache.org/repos/asf/aries/trunk/samples/ariestrader/modules/ariestrader-derby-ds/src/main/resources/OSGI-INF/blueprint/blueprint.xml

The most elegant approach is to package this blueprint descriptor in a 
bundle, this bundle is part of a feature.

Regards
JB

On 04/16/2012 02:23 PM, Borut Bolčina wrote:
> Hello,
>
> my first post here, so bare with me please - newbie on board.
>
> I am trying to deploy my first camel route to Karaf and this route must
> be configurable (html address) and must persist some data with jpa
> component. This route is happily persisting in my test (outside osgi
> container).
>
> Now I am reading
> https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-mysql.xml where
> it says I should copy the file to Karaf's deploy folder.
>
> And the question: What is the practice of deploying data sources? Should
> I create a features project which includes a blueprint for my route's
> data source?
>
> Let's say my route needs connection to mysql database, so the feature
> project would include features.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0
> http://karaf.apache.org/xmlns/features/v1.0.0">
>
> <feature name="weather" version="${pom.version}">
> <bundle>mvn:mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.stax-api-1.0/1.9.0</bundle>
> <bundle>mvn:mvn:mysql/mysql-connector-java/5.1.18</bundle>
> <bundle>mvn:my.company/route-weather-current/${pom.version}</bundle>
> *<bundle>my datasource blueprint</bundle>*
> <configfile
> finalname="/etc/weather.cfg">mvn:my.company/features-weather/${pom.version}/cfg</configfile>
> </feature>
> </features>
>
> I guess then the only command to install my Camel route to Karaf would
> then be feature:install and all the dependencies including datasource
> and configuration would be installed before. And how to package the "my
> datasource blueprint"?
>
> Or is there some other practice?
>
> Thanks,
> borut

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Deploying data sources

Posted by "ajs6f@virginia.edu" <aj...@virginia.edu>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I've had good success with just this style of deployment, and it's very nice to be able simply to add a OSGi Metatype annotation document and have your configuration properties appear in the Felix Web Console with labels and descriptions and default values.

- ---
A. Soroka
Software & Systems Engineering :: Online Library Environment
the University of Virginia Library

On Apr 16, 2012, at 8:51 AM, Jean-Baptiste Onofré wrote:

> Username/password/URL could be in <cm:properties/> and so handle in the "application" config oriented file in etc.
> 
> Regards
> JB
> 
> On 04/16/2012 02:47 PM, Christian Schneider wrote:
>> I would simply deploy the blueprint xml by hand. Just treat it like a
>> config file you would have to add.
>> This is of course not everyone´s favorite style.
>> 
>> The problem with adding the blueprint to the feature is that it would
>> have to be in the maven repo. As the username and password are in this
>> file this is not recommended.
>> 
>> So another way to achieve what I did is separate the things that should
>> be configured per server or stage from the things that keep the same like
>> driver class name. You could use the config admin service in the
>> blueprint file to move the username / password to a separate config file.
>> This would make the whole thing a bit more complex though but you could
>> then safely put the blueprint file into a feature.
>> 
>> Christian
>> 
>> 
>> 2012/4/16 Borut Bolčina <borut.bolcina@gmail.com
>> <ma...@gmail.com>>
>> 
>>    Hello,
>> 
>>    my first post here, so bare with me please - newbie on board.
>> 
>>    I am trying to deploy my first camel route to Karaf and this route
>>    must be configurable (html address) and must persist some data with
>>    jpa component. This route is happily persisting in my test (outside
>>    osgi container).
>> 
>>    Now I am reading
>>    https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-mysql.xml where
>>    it says I should copy the file to Karaf's deploy folder.
>> 
>>    And the question: What is the practice of deploying data sources?
>>    Should I create a features project which includes a blueprint for my
>>    route's data source?
>> 
>>    Let's say my route needs connection to mysql database, so the
>>    feature project would include features.xml
>> 
>>    <?xml version="1.0" encoding="UTF-8"?>
>>    <features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0"
>>    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>    xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0
>>    http://karaf.apache.org/xmlns/features/v1.0.0">
>> 
>>    <feature name="weather" version="${pom.version}">
>>    <bundle>mvn:mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.stax-api-1.0/1.9.0</bundle>
>>    <bundle>mvn:mvn:mysql/mysql-connector-java/5.1.18</bundle>
>>    <bundle>mvn:my.company/route-weather-current/${pom.version}</bundle>
>>    *<bundle>my datasource blueprint</bundle>*
>>    <configfile
>>    finalname="/etc/weather.cfg">mvn:my.company/features-weather/${pom.version}/cfg</configfile>
>>    </feature>
>>    </features>
>> 
>>    I guess then the only command to install my Camel route to Karaf
>>    would then be feature:install and all the dependencies including
>>    datasource and configuration would be installed before. And how to
>>    package the "my datasource blueprint"?
>> 
>>    Or is there some other practice?
>> 
>>    Thanks,
>>    borut
>> 
>> 
> 
> -- 
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org

iQEcBAEBAgAGBQJPjBicAAoJEATpPYSyaoIkAnAIAIiVH4OsOLPbhMKxUxUhSBbP
2//XLJm3hODlaDtf99S6JraqRT51nU95WwSVyufui1KSK2gnOWw+HU638F1dKliQ
WnqcLOaT0iUpxTsnt/eQSKDtbEd3iVqFC2uDTZtqitD1IM19stqHjsaNbpRAfWEZ
Ni5TAKV0NRWfOM82d+3RF6Fxyp86imT1sWB8qlyYDKMmJPeavjFpnCycJ9Alkt1d
XFlhBHDBBM9/3Xkdt1Kh37UB+6uLeZaR8hcJRw1lJKEvrceciRUy+vzRQAnZlUCn
mjWyOjw2GrjjUVg8DiD23+1wH1Mp9gB5ckOF44ghVwX8JYGqgn4/8so3G7cauXg=
=Lhx2
-----END PGP SIGNATURE-----

Re: Deploying data sources

Posted by Borut Bolčina <bo...@gmail.com>.
Well I don't know if it works, 'couse this was never run :-)

The route looks like:

public class WeatherCurrentRouteBuilder extends RouteBuilder {

 private String sourceUrl;

public void setSourceUrl(String sourceUrl) {
 this.sourceUrl = sourceUrl;
}

public void refresh() {
 System.out.println("Configuration updated (sourceUrl=" + this.sourceUrl +
")");
}

public void configure() {

DataFormat jaxbDataFormat = new
JaxbDataFormat("si.najdi.model.entities.weather");

from("quartz://weather/currentWeatherSlovenia?cron=0+*/1+*+?+*+*")
.log("Getting weather from: " + sourceUrl)
 .to(sourceUrl)
.split()
.tokenizeXML("metData")
 .unmarshal(jaxbDataFormat)
.to("jpa:com.mycompany.model.entities.weather.WeatherCurrent?persistenceUnit=weather");
 }
}

so does the route need a reference to datasource?

This also brings me to using persistence layer in my bundles. Declaring
something like:

  <bean id="personService"
class="net.lr.tutorial.karaf.db.examplejpa.impl.PersonServiceImpl">
<jpa:context property="entityManager" unitname="person" />
 <tx:transaction method="*" value="Required"/>
  </bean>

<service ref="personService"
interface="net.lr.tutorial.karaf.db.examplejpa.PersonService" />

which follows the DAO pattern in a way is only needed if my bundle's code
would be using some persistence operations other then those contained in
camel jpa component for example, isn't it?

Cheers,
borut

Dne 16. april 2012 15:21 je Jean-Baptiste Onofré <jb...@nanthrax.net>napisal/-a:

> The way that you did work too ;)
>
> I would prefer a better separation (the Camel route should use a service
> reference to the datasource).
>
> Regards
> JB
>
>
> On 04/16/2012 03:17 PM, Borut Bolčina wrote:
>
>> OK, to make a first step which doesn't involve creating a separate
>> bundle for datasource, but instead adding a datasource configuration
>> directly to my Camel route bundle's blueprint.xml:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <blueprint xmlns="http://www.osgi.org/**xmlns/blueprint/v1.0.0<http://www.osgi.org/xmlns/blueprint/v1.0.0>
>> "
>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>> "
>> xmlns:cm="http://aries.apache.**org/blueprint/xmlns/blueprint-**cm/v1.1.0<http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0>
>> "
>> xsi:schemaLocation="
>> ... ">
>> <cm:property-placeholder persistent-id="WeatherCurrent"
>> update-strategy="reload">
>> <cm:default-properties>
>> <cm:property name="sourceUrl"
>> value="http://meteo.arso.gov.**si/uploads/probase/www/observ/**
>> surface/text/sl/observation_**si_latest.xml<http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml>
>> "
>> />
>> <cm:property name="weatherDbConnectionUrl"
>> value="jdbc:mysql://my.**company.com:3306/weather?**useUnicode=yes&amp;**
>> characterEncoding=UTF-8<http://my.company.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>  <http://my.company.com:3306/**weather?useUnicode=yes&amp;**
>> characterEncoding=UTF-8<http://my.company.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>> >"
>>
>> />
>> <cm:property name="weatherDbUser" value="testUser" />
>> <cm:property name="weatherDbPassword" value="testPass" />
>> </cm:default-properties>
>> </cm:property-placeholder>
>> <bean id="dataSource" class="com.mysql.jdbc.jdbc2.**
>> optional.MysqlDataSource">
>> <property name="url" value="${**weatherDbConnectionUrl}"/>
>> <property name="user" value="${weatherDbUser}"/>
>> <property name="password" value="${weatherDbPassword}"/>
>> </bean>
>> <service interface="javax.sql.**DataSource" ref="dataSource">
>> <service-properties>
>> <entry key="osgi.jndi.service.name <http://osgi.jndi.service.name**>"
>>
>> value="jdbc/mysqlds"/>
>> </service-properties>
>> </service>
>>
>> <bean id="**weatherCurrentRouteBuilder"
>> class="com.mycompany.route.**weather.**WeatherCurrentRouteBuilder"
>> init-method="refresh">
>> <property name="sourceUrl" value="${sourceUrl}"></**property>
>> </bean>
>>
>> <camelContext id="weather-forecast"
>> xmlns="http://camel.apache.**org/schema/blueprint<http://camel.apache.org/schema/blueprint>
>> ">
>> <routeBuilder ref="**weatherCurrentRouteBuilder" />
>> </camelContext>
>>
>> </blueprint>
>>
>>
>> and the configuration file weather.cfg
>>
>> sourceUrl=http://meteo.arso.**gov.si/uploads/probase/www/**
>> observ/surface/text/sl/**observation_si_latest.xml<http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml>
>> weatherDbConnectionUrl=jdbc:**mysql://my.comapny.com:3306/**
>> weather?useUnicode=yes&amp;**characterEncoding=UTF-8<http://my.comapny.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>  <http://my.comapny.com:3306/**weather?useUnicode=yes&amp;**
>> characterEncoding=UTF-8<http://my.comapny.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>> >
>>
>> weatherDbUser=testUser
>> weatherDbPassword=testPass
>>
>> and the persistence.xml
>>
>> <persistence xmlns="http://java.sun.com/**xml/ns/persistence<http://java.sun.com/xml/ns/persistence>
>> "
>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>> "
>> version="1.0">
>>
>> <persistence-unit name="weather" transaction-type="JTA">
>> <provider>org.hibernate.ejb.**HibernatePersistence</**provider>
>> <jta-data-source>osgi:service/**javax.sql.DataSource/(osgi.**
>> jndi.service.name <http://osgi.jndi.service.name>
>> <http://osgi.jndi.service.name**>=jdbc/mysqlds)</jta-data-**source>
>>
>> <class>my.company.model.**entities.weather.**WeatherCurrent</class>
>> <exclude-unlisted-classes>**true</exclude-unlisted-**classes>
>> <properties>
>> <property name="hibernate.show_sql" value="true"/>
>> <property name="hibernate.format_sql" value="true"/>
>> </properties>
>> </persistence-unit>
>> </persistence>
>>
>> and features bundle which installs configuration and drivers besides my
>> camel route:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <features xmlns="http://karaf.apache.**org/xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> "
>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>> "
>> xsi:schemaLocation="http://**karaf.apache.org/xmlns/**features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> http://karaf.apache.org/xmlns/**features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> ">
>>
>> <feature name="weather" version="${pom.version}">
>> <bundle>mvn:mvn:org.apache.**servicemix.specs/org.apache.**
>> servicemix.specs.stax-api-1.0/**1.9.0</bundle>
>> <bundle>mvn:mvn:mysql/mysql-**connector-java/5.1.18</bundle>
>> <bundle>mvn:my.company/route-**weather-current/${pom.version}**</bundle>
>> <configfile
>> finalname="/etc/weather.cfg">**mvn:my.company/features-**
>> weather/${pom.version}/cfg</**configfile>
>> </feature>
>>
>> </features>
>>
>>
>> Am I heading the right way or am I on the Titanic's route?
>>
>> Cheers,
>> borut
>>
>>
>> Dne 16. april 2012 14:51 je Jean-Baptiste Onofré <jb@nanthrax.net
>> <ma...@nanthrax.net>> napisal/-a:
>>
>>
>>    Username/password/URL could be in <cm:properties/> and so handle in
>>    the "application" config oriented file in etc.
>>
>>    Regards
>>    JB
>>
>>
>>    On 04/16/2012 02:47 PM, Christian Schneider wrote:
>>
>>        I would simply deploy the blueprint xml by hand. Just treat it
>>        like a
>>        config file you would have to add.
>>        This is of course not everyone´s favorite style.
>>
>>        The problem with adding the blueprint to the feature is that it
>>        would
>>        have to be in the maven repo. As the username and password are
>>        in this
>>        file this is not recommended.
>>
>>        So another way to achieve what I did is separate the things that
>>        should
>>        be configured per server or stage from the things that keep the
>>        same like
>>        driver class name. You could use the config admin service in the
>>        blueprint file to move the username / password to a separate
>>        config file.
>>        This would make the whole thing a bit more complex though but
>>        you could
>>        then safely put the blueprint file into a feature.
>>
>>        Christian
>>
>>
>>        2012/4/16 Borut Bolčina <borut.bolcina@gmail.com
>>        <mailto:borut.bolcina@gmail.**com <bo...@gmail.com>>
>>        <mailto:borut.bolcina@gmail.__**com <mailto:borut.bolcina@gmail.**
>> com <bo...@gmail.com>>>>
>>
>>
>>
>>            Hello,
>>
>>            my first post here, so bare with me please - newbie on board.
>>
>>            I am trying to deploy my first camel route to Karaf and this
>>        route
>>            must be configurable (html address) and must persist some
>>        data with
>>            jpa component. This route is happily persisting in my test
>>        (outside
>>            osgi container).
>>
>>            Now I am reading
>>        https://github.com/cschneider/**__Karaf-Tutorial/blob/master/**
>> db/__datasource/datasource-**mysql.__xml<https://github.com/cschneider/__Karaf-Tutorial/blob/master/db/__datasource/datasource-mysql.__xml>
>>
>>        <https://github.com/**cschneider/Karaf-Tutorial/**
>> blob/master/db/datasource/**datasource-mysql.xml<https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-mysql.xml>
>> >
>>        where
>>            it says I should copy the file to Karaf's deploy folder.
>>
>>            And the question: What is the practice of deploying data
>>        sources?
>>            Should I create a features project which includes a
>>        blueprint for my
>>            route's data source?
>>
>>            Let's say my route needs connection to mysql database, so the
>>            feature project would include features.xml
>>
>>        <?xml version="1.0" encoding="UTF-8"?>
>>        <features xmlns="http://karaf.apache.__**org/xmlns/features/v1.0.0
>>        <http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> >"
>>            xmlns:xsi="http://www.w3.org/_**_2001/XMLSchema-instance<http://www.w3.org/__2001/XMLSchema-instance>
>>        <http://www.w3.org/2001/**XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>> >"
>>
>>          xsi:schemaLocation="http://__k**araf.apache.org/xmlns/__**
>> features/v1.0.0 <http://karaf.apache.org/xmlns/__features/v1.0.0> <
>> http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> >
>>        http://karaf.apache.org/xmlns/**__features/v1.0.0<http://karaf.apache.org/xmlns/__features/v1.0.0>
>>
>>        <http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> >">
>>
>>        <feature name="weather" version="${pom.version}">
>>        <bundle>mvn:mvn:org.apache.__**servicemix.specs/org.apache.__**
>> servicemix.specs.stax-api-1.0/**__1.9.0</bundle>
>>        <bundle>mvn:mvn:mysql/mysql-__**connector-java/5.1.18</bundle>
>>        <bundle>mvn:my.company/route-_**_weather-current/${pom.**
>> version}__</bundle>
>>
>>            *<bundle>my datasource blueprint</bundle>*
>>
>>        <configfile
>>
>>          finalname="/etc/weather.cfg">_**_mvn:my.company/features-__**
>> weather/${pom.version}/cfg</__**configfile>
>>
>>        </feature>
>>        </features>
>>
>>            I guess then the only command to install my Camel route to
>> Karaf
>>            would then be feature:install and all the dependencies
>> including
>>            datasource and configuration would be installed before. And
>>        how to
>>            package the "my datasource blueprint"?
>>
>>            Or is there some other practice?
>>
>>            Thanks,
>>            borut
>>
>>
>>
>>    --
>>    Jean-Baptiste Onofré
>>    jbonofre@apache.org <ma...@apache.org>
>>
>>    http://blog.nanthrax.net
>>    Talend - http://www.talend.com
>>
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Re: Deploying data sources

Posted by Bengt Rodehav <be...@rodehav.com>.
Did you try to disable the validation? You might have a validation provider
present in the classpath when you run outside of OSGi. In OSGi, the
validation provider must be "OSGi-enabled" in order to be found by OpenJPA.

/Bengt

2012/4/26 Borut Bolcina <bo...@gmail.com>

> Aha, yes it does work as I have several unit tests, one of them is
> persisting the data just fine with the same route, aka jpa component which
> is configured with persistence.xml with the same credentials and url
> connection string.
>
> Borut
>
> Sent from my iPad
>
> On 26. apr. 2012, at 15:50, Christian Schneider <ch...@die-schneider.net>
> wrote:
>
> That is not what I meant. Try to connect to the datasource using jdbc in
> the same way as in the osgi connect but in a simple little java class with
> a main method.
> So you can test that jdbc, the connection string and your credentials
> really work.
>
> Christian
>
> Am 26.04.2012 13:16, schrieb Borut Bolčina:
>
> Yes I can connect to the database and the data is there. Double checked.
>
>  someUser@dev.mycompany.com:~$ mysql -u userA -p
> Enter password:
> Welcome to the MySQL monitor.  Commands end with ; or \g.
> Your MySQL connection id is 251676
>  Server version: 5.1.41-3ubuntu12.10-log (Ubuntu)
>
>  userA@localhost:(none)> use weather;
>  Reading table information for completion of table and column names
> You can turn off this feature to get a quicker startup with -A
>
>  Database changed
> userA@localhost:weather> show tables;
> +--------------------------+
> | Tables_in_weather        |
> +--------------------------+
> | weather_my_table_which_holds_some_data          |
> | weather_xxx         |
> | weather_xxxx |
> | weather_xxxxx         |
> | weather_xxxxxx         |
>  +--------------------------+
> 5 rows in set (0.00 sec)
>
>  userA@localhost:weather> select * from
> weather_my_table_which_holds_some_data ;
>
> +--------+-------------+-----------------+------------+-------------+-------------------------------------------------+-----------------------------------+---------------------+----------------------+
> | rec_no | skislope_id | skislope        | conditions | temperature | link
>                                            | phonenum
>    | published           | successfully_updated |
>
> +--------+-------------+-----------------+------------+-------------+-------------------------------------------------+-----------------------------------+---------------------+----------------------+
> |   1025 | sneg_1      | ccc     | NULL       |           6 |
> http://www.xxx.si/default.asp?sid=1  | xxx telefon: 031/041  182501   |
> 2011-08-10 07:54:00 | 2011-08-10 14:19:46  |
>
>
>  Maybe permissions are in question.
>
>  -borut
>
>  Dne 26. april 2012 12:58 je Christian Schneider <ch...@die-schneider.net>napisal/-a:
>
>>  The service lists look good but that the db command does not work shows
>> that there is a problem. The problem seems to be already in the datasource
>> though.
>>
>> Can you try to access the datasource directly outside of OSGi and make
>> sure that it is correct?
>>
>> Christian
>>
>> Am 26.04.2012 12:29, schrieb Borut Bolčina:
>>
>> Hi,
>>
>> Dne 26. april 2012 11:09 je Christian Schneider <ch...@die-schneider.net>napisal/-a:
>>
>>>  You can check if the datasource works by using my db commands for karaf:
>>> https://github.com/cschneider/Karaf-Tutorial/tree/master/db/command
>>>
>>
>>  Installed:
>>  karaf@root> install -s
>> mvn:net.lr.tutorial.karaf.db/db-command/1.0-SNAPSHOT
>> Bundle ID: 129
>>
>>  Selected:
>> karaf@root> db:select jdbc/mysqlds
>>
>>  But the query returns nothing:
>> karaf@root> db:exec "select * from my_table_which_holds_some_data"
>>
>>
>>
>>>
>>> You should also check with the service:list command if the blueprint.xml
>>> offers the DataSource service.
>>>
>>
>>  Yes, i think it does:
>>
>>  weather-datasource (123) provides:
>> ----------------------------------
>> javax.sql.DataSource
>> org.osgi.service.blueprint.container.BlueprintContainer
>>
>>  OpenJPA Aggregate Jar (125) provides:
>> -------------------------------------
>> javax.persistence.spi.PersistenceProvider
>>
>>  weather-model (128) provides:
>> -----------------------------
>> javax.persistence.EntityManagerFactory
>>
>>
>>  Thanks for the tips. Will have to dig some more into the issue.
>>
>>  -borut
>>
>>
>>
>>
>>   --
>>
>> Christian Schneiderhttp://www.liquid-reality.de
>>
>> Open Source Architect
>> Talend Application Integration Division http://www.talend.com
>>
>>
>
>
> --
> Christian Schneiderhttp://www.liquid-reality.de
>
> Open Source Architect
> Talend Application Integration Division http://www.talend.com
>
>

Re: Deploying data sources

Posted by Borut Bolcina <bo...@gmail.com>.
Aha, yes it does work as I have several unit tests, one of them is persisting the data just fine with the same route, aka jpa component which is configured with persistence.xml with the same credentials and url connection string.

Borut

Sent from my iPad

On 26. apr. 2012, at 15:50, Christian Schneider <ch...@die-schneider.net> wrote:

> That is not what I meant. Try to connect to the datasource using jdbc in the same way as in the osgi connect but in a simple little java class with a main method.
> So you can test that jdbc, the connection string and your credentials really work.
> 
> Christian
> 
> Am 26.04.2012 13:16, schrieb Borut Bolčina:
>> 
>> Yes I can connect to the database and the data is there. Double checked.
>> 
>> someUser@dev.mycompany.com:~$ mysql -u userA -p
>> Enter password:
>> Welcome to the MySQL monitor.  Commands end with ; or \g.
>> Your MySQL connection id is 251676
>> Server version: 5.1.41-3ubuntu12.10-log (Ubuntu)
>> 
>> userA@localhost:(none)> use weather;
>> Reading table information for completion of table and column names
>> You can turn off this feature to get a quicker startup with -A
>> 
>> Database changed
>> userA@localhost:weather> show tables;
>> +--------------------------+
>> | Tables_in_weather        |
>> +--------------------------+
>> | weather_my_table_which_holds_some_data          |
>> | weather_xxx         |
>> | weather_xxxx |
>> | weather_xxxxx         |
>> | weather_xxxxxx         |
>> +--------------------------+
>> 5 rows in set (0.00 sec)
>> 
>> userA@localhost:weather> select * from  weather_my_table_which_holds_some_data ;
>> +--------+-------------+-----------------+------------+-------------+-------------------------------------------------+-----------------------------------+---------------------+----------------------+
>> | rec_no | skislope_id | skislope        | conditions | temperature | link                                            | phonenum                          | published           | successfully_updated |
>> +--------+-------------+-----------------+------------+-------------+-------------------------------------------------+-----------------------------------+---------------------+----------------------+
>> |   1025 | sneg_1      | ccc     | NULL       |           6 | http://www.xxx.si/default.asp?sid=1  | xxx telefon: 031/041  182501   | 2011-08-10 07:54:00 | 2011-08-10 14:19:46  |
>> 
>> 
>> Maybe permissions are in question.
>> 
>> -borut
>> 
>> Dne 26. april 2012 12:58 je Christian Schneider <ch...@die-schneider.net> napisal/-a:
>> The service lists look good but that the db command does not work shows that there is a problem. The problem seems to be already in the datasource though.
>> 
>> Can you try to access the datasource directly outside of OSGi and make sure that it is correct?
>> 
>> Christian
>> 
>> Am 26.04.2012 12:29, schrieb Borut Bolčina:
>>> Hi,
>>> 
>>> Dne 26. april 2012 11:09 je Christian Schneider <ch...@die-schneider.net> napisal/-a:
>>> You can check if the datasource works by using my db commands for karaf:
>>> https://github.com/cschneider/Karaf-Tutorial/tree/master/db/command
>>> 
>>> Installed:
>>> karaf@root> install -s mvn:net.lr.tutorial.karaf.db/db-command/1.0-SNAPSHOT
>>> Bundle ID: 129
>>> 
>>> Selected:
>>> karaf@root> db:select jdbc/mysqlds
>>> 
>>> But the query returns nothing:
>>> karaf@root> db:exec "select * from my_table_which_holds_some_data"
>>> 
>>> 
>>> 
>>> 
>>> You should also check with the service:list command if the blueprint.xml offers the DataSource service.
>>> 
>>> Yes, i think it does:
>>> 
>>> weather-datasource (123) provides:
>>> ----------------------------------
>>> javax.sql.DataSource
>>> org.osgi.service.blueprint.container.BlueprintContainer
>>> 
>>> OpenJPA Aggregate Jar (125) provides:
>>> -------------------------------------
>>> javax.persistence.spi.PersistenceProvider
>>> 
>>> weather-model (128) provides:
>>> -----------------------------
>>> javax.persistence.EntityManagerFactory
>>> 
>>> 
>>> Thanks for the tips. Will have to dig some more into the issue.
>>> 
>>> -borut
>>> 
>>>  
>> 
>> -- 
>>  
>> Christian Schneider
>> http://www.liquid-reality.de
>> 
>> Open Source Architect
>> Talend Application Integration Division http://www.talend.com 
>> 
> 
> 
> -- 
> Christian Schneider
> http://www.liquid-reality.de
> 
> Open Source Architect
> Talend Application Integration Division http://www.talend.com 

Re: Deploying data sources

Posted by Christian Schneider <ch...@die-schneider.net>.
That is not what I meant. Try to connect to the datasource using jdbc in 
the same way as in the osgi connect but in a simple little java class 
with a main method.
So you can test that jdbc, the connection string and your credentials 
really work.

Christian

Am 26.04.2012 13:16, schrieb Borut Bolčina:
> Yes I can connect to the database and the data is there. Double checked.
>
> someUser@dev.mycompany.com:~$ mysql -u userA -p
> Enter password:
> Welcome to the MySQL monitor.  Commands end with ; or \g.
> Your MySQL connection id is 251676
> Server version: 5.1.41-3ubuntu12.10-log (Ubuntu)
>
> userA@localhost:(none)> use weather;
> Reading table information for completion of table and column names
> You can turn off this feature to get a quicker startup with -A
>
> Database changed
> userA@localhost:weather> show tables;
> +--------------------------+
> | Tables_in_weather        |
> +--------------------------+
> | weather_my_table_which_holds_some_data          |
> | weather_xxx         |
> | weather_xxxx |
> | weather_xxxxx         |
> | weather_xxxxxx         |
> +--------------------------+
> 5 rows in set (0.00 sec)
>
> userA@localhost:weather> select * from  
> weather_my_table_which_holds_some_data ;
> +--------+-------------+-----------------+------------+-------------+-------------------------------------------------+-----------------------------------+---------------------+----------------------+
> | rec_no | skislope_id | skislope        | conditions | temperature | 
> link                                            | phonenum             
>              | published           | successfully_updated |
> +--------+-------------+-----------------+------------+-------------+-------------------------------------------------+-----------------------------------+---------------------+----------------------+
> |   1025 | sneg_1      | ccc     | NULL       |           6 | 
> http://www.xxx.si/default.asp?sid=1  | xxx telefon: 031/041  182501   
> | 2011-08-10 07:54:00 | 2011-08-10 14:19:46  |
>
>
> Maybe permissions are in question.
>
> -borut
>
> Dne 26. april 2012 12:58 je Christian Schneider 
> <chris@die-schneider.net <ma...@die-schneider.net>> napisal/-a:
>
>     The service lists look good but that the db command does not work
>     shows that there is a problem. The problem seems to be already in
>     the datasource though.
>
>     Can you try to access the datasource directly outside of OSGi and
>     make sure that it is correct?
>
>     Christian
>
>     Am 26.04.2012 12 <tel:26.04.2012%2012>:29, schrieb Borut Bolčina:
>>     Hi,
>>
>>     Dne 26. april 2012 11:09 je Christian Schneider
>>     <chris@die-schneider.net <ma...@die-schneider.net>>
>>     napisal/-a:
>>
>>         You can check if the datasource works by using my db commands
>>         for karaf:
>>         https://github.com/cschneider/Karaf-Tutorial/tree/master/db/command
>>
>>
>>     Installed:
>>     karaf@root> install -s
>>     mvn:net.lr.tutorial.karaf.db/db-command/1.0-SNAPSHOT
>>     Bundle ID: 129
>>
>>     Selected:
>>     karaf@root> db:select jdbc/mysqlds
>>
>>     But the query returns nothing:
>>     karaf@root> db:exec "select * from my_table_which_holds_some_data"
>>
>>
>>
>>
>>         You should also check with the service:list command if the
>>         blueprint.xml offers the DataSource service.
>>
>>
>>     Yes, i think it does:
>>
>>     weather-datasource (123) provides:
>>     ----------------------------------
>>     javax.sql.DataSource
>>     org.osgi.service.blueprint.container.BlueprintContainer
>>
>>     OpenJPA Aggregate Jar (125) provides:
>>     -------------------------------------
>>     javax.persistence.spi.PersistenceProvider
>>
>>     weather-model (128) provides:
>>     -----------------------------
>>     javax.persistence.EntityManagerFactory
>>
>>
>>     Thanks for the tips. Will have to dig some more into the issue.
>>
>>     -borut
>>
>>
>
>     -- 
>
>     Christian Schneider
>     http://www.liquid-reality.de
>
>     Open Source Architect
>     Talend Application Integration Divisionhttp://www.talend.com  
>
>


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com


Re: Deploying data sources

Posted by Borut Bolčina <bo...@gmail.com>.
Yes I can connect to the database and the data is there. Double checked.

someUser@dev.mycompany.com:~$ mysql -u userA -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 251676
Server version: 5.1.41-3ubuntu12.10-log (Ubuntu)

userA@localhost:(none)> use weather;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
userA@localhost:weather> show tables;
+--------------------------+
| Tables_in_weather        |
+--------------------------+
| weather_my_table_which_holds_some_data          |
| weather_xxx         |
| weather_xxxx |
| weather_xxxxx         |
| weather_xxxxxx         |
+--------------------------+
5 rows in set (0.00 sec)

userA@localhost:weather> select * from
weather_my_table_which_holds_some_data ;
+--------+-------------+-----------------+------------+-------------+-------------------------------------------------+-----------------------------------+---------------------+----------------------+
| rec_no | skislope_id | skislope        | conditions | temperature | link
                                           | phonenum
   | published           | successfully_updated |
+--------+-------------+-----------------+------------+-------------+-------------------------------------------------+-----------------------------------+---------------------+----------------------+
|   1025 | sneg_1      | ccc     | NULL       |           6 |
http://www.xxx.si/default.asp?sid=1  | xxx telefon: 031/041  182501   |
2011-08-10 07:54:00 | 2011-08-10 14:19:46  |


Maybe permissions are in question.

-borut

Dne 26. april 2012 12:58 je Christian Schneider
<ch...@die-schneider.net>napisal/-a:

>  The service lists look good but that the db command does not work shows
> that there is a problem. The problem seems to be already in the datasource
> though.
>
> Can you try to access the datasource directly outside of OSGi and make
> sure that it is correct?
>
> Christian
>
> Am 26.04.2012 12:29, schrieb Borut Bolčina:
>
> Hi,
>
> Dne 26. april 2012 11:09 je Christian Schneider <ch...@die-schneider.net>napisal/-a:
>
>>  You can check if the datasource works by using my db commands for karaf:
>> https://github.com/cschneider/Karaf-Tutorial/tree/master/db/command
>>
>
>  Installed:
>  karaf@root> install -s
> mvn:net.lr.tutorial.karaf.db/db-command/1.0-SNAPSHOT
> Bundle ID: 129
>
>  Selected:
> karaf@root> db:select jdbc/mysqlds
>
>  But the query returns nothing:
> karaf@root> db:exec "select * from my_table_which_holds_some_data"
>
>
>
>>
>> You should also check with the service:list command if the blueprint.xml
>> offers the DataSource service.
>>
>
>  Yes, i think it does:
>
>  weather-datasource (123) provides:
> ----------------------------------
> javax.sql.DataSource
> org.osgi.service.blueprint.container.BlueprintContainer
>
>  OpenJPA Aggregate Jar (125) provides:
> -------------------------------------
> javax.persistence.spi.PersistenceProvider
>
>  weather-model (128) provides:
> -----------------------------
> javax.persistence.EntityManagerFactory
>
>
>  Thanks for the tips. Will have to dig some more into the issue.
>
>  -borut
>
>
>
>
> --
>
> Christian Schneiderhttp://www.liquid-reality.de
>
> Open Source Architect
> Talend Application Integration Division http://www.talend.com
>
>

Re: Deploying data sources

Posted by Christian Schneider <ch...@die-schneider.net>.
The service lists look good but that the db command does not work shows 
that there is a problem. The problem seems to be already in the 
datasource though.

Can you try to access the datasource directly outside of OSGi and make 
sure that it is correct?

Christian

Am 26.04.2012 12:29, schrieb Borut Bolčina:
> Hi,
>
> Dne 26. april 2012 11:09 je Christian Schneider 
> <chris@die-schneider.net <ma...@die-schneider.net>> napisal/-a:
>
>     You can check if the datasource works by using my db commands for
>     karaf:
>     https://github.com/cschneider/Karaf-Tutorial/tree/master/db/command
>
>
> Installed:
> karaf@root> install -s 
> mvn:net.lr.tutorial.karaf.db/db-command/1.0-SNAPSHOT
> Bundle ID: 129
>
> Selected:
> karaf@root> db:select jdbc/mysqlds
>
> But the query returns nothing:
> karaf@root> db:exec "select * from my_table_which_holds_some_data"
>
>
>
>
>     You should also check with the service:list command if the
>     blueprint.xml offers the DataSource service.
>
>
> Yes, i think it does:
>
> weather-datasource (123) provides:
> ----------------------------------
> javax.sql.DataSource
> org.osgi.service.blueprint.container.BlueprintContainer
>
> OpenJPA Aggregate Jar (125) provides:
> -------------------------------------
> javax.persistence.spi.PersistenceProvider
>
> weather-model (128) provides:
> -----------------------------
> javax.persistence.EntityManagerFactory
>
>
> Thanks for the tips. Will have to dig some more into the issue.
>
> -borut
>
>

-- 

Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com


Re: Deploying data sources

Posted by Borut Bolčina <bo...@gmail.com>.
Hi,

Dne 26. april 2012 11:09 je Christian Schneider
<ch...@die-schneider.net>napisal/-a:

>  You can check if the datasource works by using my db commands for karaf:
> https://github.com/cschneider/Karaf-Tutorial/tree/master/db/command
>

Installed:
karaf@root> install -s mvn:net.lr.tutorial.karaf.db/db-command/1.0-SNAPSHOT
Bundle ID: 129

Selected:
karaf@root> db:select jdbc/mysqlds

But the query returns nothing:
karaf@root> db:exec "select * from my_table_which_holds_some_data"



>
> You should also check with the service:list command if the blueprint.xml
> offers the DataSource service.
>

Yes, i think it does:

weather-datasource (123) provides:
----------------------------------
javax.sql.DataSource
org.osgi.service.blueprint.container.BlueprintContainer

OpenJPA Aggregate Jar (125) provides:
-------------------------------------
javax.persistence.spi.PersistenceProvider

weather-model (128) provides:
-----------------------------
javax.persistence.EntityManagerFactory


Thanks for the tips. Will have to dig some more into the issue.

-borut



>
> Christian
>
>
> Am 26.04.2012 10:45, schrieb Borut Bolčina:
>
> Hello,
>
>  thanks Bengt for your input, I really appreciate you took the time!
>
>  My work on this is somehow sporadic, but now I have managed to get the
> Camel route running in Karaf
>
>   from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
>  .log("Getting weather from: " + sourceUrl)
>  .to(sourceUrl)
>  .split()
>  .tokenizeXML("metData")
>  .unmarshal(jaxbDataFormat)
>
> .to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
>
>  with the exception of saving the data to the database which fails with:
>
>   Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
> DataSource class name must be specified in
> the ConnectionDriverName property. Available properties in configuration
> are "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>         at
> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>         at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>         at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>         at
> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>         at
> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
> ....
>
>  My datasource bundle is deployed in OSGi (later the username and
> password will be configurable, that is - outside of the bundle)
>
>  <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>
>   <bean id="weatherDataSource"
> class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
>  <property name="url"
>  value="jdbc:mysql://
> dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8<http://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>"
> />
>  <property name="user" value="myUsername" />
>  <property name="password" value="myPassword" />
>  </bean>
>
>  <service interface="javax.sql.DataSource" ref="weatherDataSource">
>  <service-properties>
>  <entry key="osgi.jndi.service.name" value="jdbc/mysqlds" />
>  </service-properties>
>  </service>
>  </blueprint>
>
>  which is used by my model bundle's persistence.xml
>
>  <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>   <persistence-unit name="weather" transaction-type="JTA">
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>  <jta-data-source>osgi:service/javax.sql.DataSource/(
> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>  <class>my.company.weather.entities.WeatherCurrent</class>
>  <exclude-unlisted-classes>true</exclude-unlisted-classes>
>  </persistence-unit>
> </persistence>
>
>   I think the problem is that my model bundle is not seeing the
> datasource service. How do I confirm that or how should my model's
>  MANIFEST look like?
>
>  Cheers,
> borut
>
>
> --
> Christian Schneiderhttp://www.liquid-reality.de
>
> Open Source Architect
> Talend Application Integration Division http://www.talend.com
>
>

Re: Deploying data sources

Posted by Christian Schneider <ch...@die-schneider.net>.
You can check if the datasource works by using my db commands for karaf:
https://github.com/cschneider/Karaf-Tutorial/tree/master/db/command

You should also check with the service:list command if the blueprint.xml 
offers the DataSource service.

Christian


Am 26.04.2012 10:45, schrieb Borut Bolčina:
> Hello,
>
> thanks Bengt for your input, I really appreciate you took the time!
>
> My work on this is somehow sporadic, but now I have managed to get the 
> Camel route running in Karaf
>
> from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
> .log("Getting weather from: " + sourceUrl)
> .to(sourceUrl)
> .split()
> .tokenizeXML("metData")
> .unmarshal(jaxbDataFormat)
> .to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
>
> with the exception of saving the data to the database which fails with:
>
> Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error> 
> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or 
> DataSource class name must be specified in
> the ConnectionDriverName property. Available properties in 
> configuration are 
> "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>         at 
> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>         at 
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>         at 
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>         at 
> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>         at 
> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
> ....
>
> My datasource bundle is deployed in OSGi (later the username and 
> password will be configurable, that is - outside of the bundle)
>
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>
> <bean id="weatherDataSource" 
> class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
> <property name="url"
> value="jdbc:mysql://dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8 
> <http://dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8>" 
> />
> <property name="user" value="myUsername" />
> <property name="password" value="myPassword" />
> </bean>
>
> <service interface="javax.sql.DataSource" ref="weatherDataSource">
> <service-properties>
> <entry key="osgi.jndi.service.name <http://osgi.jndi.service.name>" 
> value="jdbc/mysqlds" />
> </service-properties>
> </service>
> </blueprint>
>
> which is used by my model bundle's persistence.xml
>
> <persistence version="1.0" 
> xmlns="http://java.sun.com/xml/ns/persistence" 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
> <persistence-unit name="weather" transaction-type="JTA">
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name 
> <http://osgi.jndi.service.name>=jdbc/mysqlds)</jta-data-source>
> <class>my.company.weather.entities.WeatherCurrent</class>
> <exclude-unlisted-classes>true</exclude-unlisted-classes>
> </persistence-unit>
> </persistence>
>
> I think the problem is that my model bundle is not seeing the 
> datasource service. How do I confirm that or how should my model's 
>  MANIFEST look like?
>
> Cheers,
> borut
>

-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com


Re: Deploying data sources

Posted by Borut Bolčina <bo...@gmail.com>.
Dne 27. april 2012 08:29 je Bengt Rodehav <be...@rodehav.com> napisal/-a:


> OK - I didn't realize that you were using JPA 1.0. I've only used JPA 2.0.
> What version of OpenJPA do you use then?
>
>
I am using 2.2.0, it was just the persistence.xml file version="1.0" and
the namespaces and schema location that were for the jpa 1.0. The warning
about validation is gone now that I replaced the attributes of the
persistence element to conform to jpa 2.0. The Hibernate validator bundle
got installed automatically, but I do not know from the top of my head by
which bundle or feature - I am not at the office right now to check the
version of the validator.


> About the validator. Note that it is not enough to verify that the
> validator works outside of OSGi since you cannot use an ordinary validator
> implementation in OSGi - it will not be found. In the ServiceMix project
> they provide an OSGi'ified version of Hibernate's reference implementation
> that you can use in OSGi. The problem is that java's standard way of
> finding resources does not work in OSGi.
>
> What validator (and version) implementation do you use?
>

Will check, but I will be away for several days now.

Thanks for XP debugging!


>
> /Bengt
>
>
> 2012/4/26 Borut Bolcina <bo...@gmail.com>
>
>> A minute later after sending the email below, I saw I was using jpa 1.0
>> persistence.xml, god knows where I copied/pasted the template from.
>>
>> I have validator installed, so this is not a problem. I need it as I am
>> using some annotations on my model pojo to validate incoming values from
>> xml input source.
>>
>> Right now I am clueless.
>>
>> Borut
>>
>> Sent from my iPad
>>
>> On 26. apr. 2012, at 15:06, Bengt Rodehav <be...@rodehav.com> wrote:
>>
>> Hello again,
>>
>> The Warning is know at OpenJPA. I think it is reported in JIRA. It turns
>> up now and then but noone seems to know exactly what triggers it. I've had
>> it too but it doesn't seem to be a problem.
>>
>> About validation - I should have though of that...
>>
>> I also have this line in my persistence.xml:
>>
>> *    <validation-mode>NONE</validation-mode>*
>>
>> This tells OpenJPA not to validate. Otherwise you must also deploy a
>> validation provider. I've used the reference implementation from Hibernate
>> for this but normally I turn it off with the above line.
>>
>> /Bengt
>>
>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>
>>> I modified the model bundle to include properties section in
>>> persistence.xml
>>>
>>> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>>
>>> <persistence-unit name="weather" transaction-type="JTA">
>>>
>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>>  <class>si.najdi.weather.entities.WeatherCurrent</class>
>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>>
>>> <properties>
>>> <property name="openjpa.ConnectionFactoryMode" value="managed" />
>>>  <property name="openjpa.jdbc.DBDictionary"
>>> value="mysql(TableType=innodb)" />
>>>  <property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO" />
>>> </properties>
>>>
>>> </persistence-unit>
>>> </persistence>
>>>
>>> and reinstalled all my bundles, but it makes no difference.
>>>
>>> I notices this in my console when the route is started:
>>>
>>> 20  WARN   [Blueprint Extender: 2] openjpa.Runtime - The configuration
>>> property named "openjpa.Id" was not recognized and will be ignored,
>>> although the name closely matches a valid property called "openjpa.Id".
>>>
>>> With the TRACE level enabled, I see:
>>>
>>> karaf@root> osgi:install -s
>>> mvn:com.mycompany/weather-model/1.0.5-SNAPSHOT
>>> 35  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following
>>> properties from "?" into configuration:
>>> {openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
>>> openjpa.ConnectionFactoryMode=managed,
>>> javax.persistence.validation.mode=AUTO,
>>> javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
>>> openjpa.TransactionMode=managed,
>>> openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
>>> openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac,
>>> javax.persistence.sharedCache.mode=UNSPECIFIED,
>>> openjpa.Log=DefaultLevel=TRACE, Tool=INFO,
>>> openjpa.jdbc.DBDictionary=mysql(TableType=innodb), PersistenceVersion=1.0,
>>> openjpa.Id=weather}
>>> 58  weather  TRACE  [Thread-10] openjpa.Runtime - No cache marshaller
>>> found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
>>> 104  weather  TRACE  [Thread-10] openjpa.MetaData - Scanning resource
>>> "META-INF/orm.xml" for persistent types.
>>> 105  weather  TRACE  [Thread-10] openjpa.MetaData - The persistent unit
>>> root url is "null"
>>> 105  weather  TRACE  [Thread-10] openjpa.MetaData -
>>> parsePersistentTypeNames() found
>>> [com.mycompany.weather.entities.WeatherCurrent].
>>> 106  weather  TRACE  [Thread-10] openjpa.MetaData - Found 1 classes with
>>> metadata in 48 milliseconds.
>>> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following
>>> properties from "?" into configuration: {openjpa.BrokerFactory=jdbc,
>>> javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
>>> javax.persistence.sharedCache.mode=UNSPECIFIED, PersistenceVersion=1.0,
>>> openjpa.jdbc.DBDictionary=mysql(TableType=innodb),
>>> openjpa.Log=DefaultLevel=TRACE, Tool=INFO, openjpa.Id=weather,
>>> openjpa.ConnectionFactoryMode=managed,
>>> openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
>>> javax.persistence.validation.mode=AUTO, openjpa.TransactionMode=managed,
>>> openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
>>> openjpa.BrokerImpl=non-finalizing,
>>> openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac
>>> }
>>> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Not creating a
>>> ValidatorImpl because this app is using the JPA 1.0 Spec
>>> 1  weather  TRACE  [Thread-10] openjpa.Runtime -
>>> org.apache.openjpa.persistence.PersistenceProviderImpl@1ad69f1 creating
>>> container org.apache.openjpa.persistence.EntityManagerFactoryImpl@6888bfor PU weather.
>>> Bundle ID: 137
>>>
>>>
>>> Certanly this look strange:
>>> Not creating a ValidatorImpl because this app is using the JPA 1.0 Spec
>>>
>>> Digging...
>>>
>>>
>>>
>>>
>>> Dne 26. april 2012 12:57 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>
>>> Then I guess OpenJPA can't find or does not try to find your datasource
>>>> service. Looking at my different persistence.xml's I usually have a few
>>>> OpenJPA properties defined, like this:
>>>>
>>>> *<properties>*
>>>> *      <property name="openjpa.ConnectionFactoryMode" value="managed"
>>>> />*
>>>> *      <property name="openjpa.jdbc.SynchronizeMappings"
>>>> value="buildSchema(ForeignKeys=true)" />*
>>>> *      <property name="openjpa.jdbc.DBDictionary"
>>>> value="org.apache.openjpa.jdbc.sql.SQLServerDictionary" />*
>>>> *      <property name="openjpa.jdbc.UpdateManager"
>>>> value="operation-order" />*
>>>> *      <property name="openjpa.Log" value="DefaultLevel=INFO,
>>>> Tool=INFO" />*
>>>> *<!--      <property name="openjpa.Log" value="DefaultLevel=TRACE,
>>>> Tool=INFO" />-->*
>>>> *    </properties>*
>>>>
>>>> One idea is to enable TRACE logging to see what OpenJPA complains
>>>> about. Another one is that maybe the first property (the
>>>> ConnectionFactoryMode) must be set to "managed" for this to work. I'm not
>>>> sure but there is probably a reason why I always have that property defined.
>>>>
>>>> /Bengt
>>>>
>>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>>
>>>>> Hello,
>>>>>
>>>>> yes I find this comments very useful!
>>>>>
>>>>> karaf@root> ls | grep -B 4 javax.sql.DataSource
>>>>> org.apache.aries.jpa.container.context.PersistenceContextProvider
>>>>>
>>>>> weather-datasource (123) provides:
>>>>> ----------------------------------
>>>>> javax.sql.DataSource
>>>>> karaf@root> ls 123
>>>>>
>>>>> weather-datasource (123) provides:
>>>>> ----------------------------------
>>>>> objectClass = javax.sql.DataSource
>>>>> osgi.jndi.service.name = jdbc/mysqlds
>>>>> osgi.service.blueprint.compname = weatherDataSource
>>>>> service.id = 222
>>>>> ----
>>>>> objectClass = org.osgi.service.blueprint.container.BlueprintContainer
>>>>> osgi.blueprint.container.symbolicname = weather-datasource
>>>>> osgi.blueprint.container.version = 1.0.5.SNAPSHOT
>>>>> service.id = 223
>>>>>
>>>>> I guess the datasource service is published correctly.
>>>>>
>>>>> Thanks,
>>>>> borut
>>>>>
>>>>> Dne 26. april 2012 11:09 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>>
>>>>> Hello there,
>>>>>>
>>>>>> I guess you should check that your datasource has been published as a
>>>>>> service. I'm not the best Karaf guru but I would do something like this:
>>>>>>
>>>>>> Check what services provides datasources:
>>>>>>
>>>>>> *ls | grep -B 4 javax.sql.DataSource*
>>>>>>
>>>>>> This should identify what bundles provide datasources as services.
>>>>>> Assume that one of the bundles had the bundle id 78, you could then look
>>>>>> more closely at that bundles services with the following command:
>>>>>>
>>>>>> *ls 78*
>>>>>> *
>>>>>> *
>>>>>> You will now see the services provided by this bundle and also its
>>>>>> service properties. You should see a line similar to:
>>>>>>
>>>>>> *osgi.jndi.service.name = jdbc/mysqlds*
>>>>>>
>>>>>> Hope that helps,
>>>>>>
>>>>>> /Bengt
>>>>>>
>>>>>>
>>>>>>
>>>>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> thanks Bengt for your input, I really appreciate you took the time!
>>>>>>>
>>>>>>> My work on this is somehow sporadic, but now I have managed to get
>>>>>>> the Camel route running in Karaf
>>>>>>>
>>>>>>> from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
>>>>>>>  .log("Getting weather from: " + sourceUrl)
>>>>>>> .to(sourceUrl)
>>>>>>>  .split()
>>>>>>> .tokenizeXML("metData")
>>>>>>>  .unmarshal(jaxbDataFormat)
>>>>>>>
>>>>>>> .to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
>>>>>>>
>>>>>>> with the exception of saving the data to the database which fails
>>>>>>> with:
>>>>>>>
>>>>>>> Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
>>>>>>> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
>>>>>>> DataSource class name must be specified in
>>>>>>> the ConnectionDriverName property. Available properties in
>>>>>>> configuration are
>>>>>>> "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>>>>>>>         at
>>>>>>> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>>>>>>>         at
>>>>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>>>>>>>         at
>>>>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>>>>>>>         at
>>>>>>> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>>>>>>>         at
>>>>>>> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
>>>>>>> ....
>>>>>>>
>>>>>>> My datasource bundle is deployed in OSGi (later the username and
>>>>>>> password will be configurable, that is - outside of the bundle)
>>>>>>>
>>>>>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>>>>>>>
>>>>>>>  <bean id="weatherDataSource"
>>>>>>> class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
>>>>>>> <property name="url"
>>>>>>>  value="jdbc:mysql://
>>>>>>> dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8<http://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>"
>>>>>>> />
>>>>>>>  <property name="user" value="myUsername" />
>>>>>>> <property name="password" value="myPassword" />
>>>>>>>  </bean>
>>>>>>>
>>>>>>> <service interface="javax.sql.DataSource" ref="weatherDataSource">
>>>>>>>  <service-properties>
>>>>>>> <entry key="osgi.jndi.service.name" value="jdbc/mysqlds" />
>>>>>>>  </service-properties>
>>>>>>> </service>
>>>>>>>  </blueprint>
>>>>>>>
>>>>>>> which is used by my model bundle's persistence.xml
>>>>>>>
>>>>>>> <persistence version="1.0" xmlns="
>>>>>>> http://java.sun.com/xml/ns/persistence" xmlns:xsi="
>>>>>>> http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>>>>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>>>>>>   <persistence-unit name="weather" transaction-type="JTA">
>>>>>>>
>>>>>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>>>>>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>>>>>>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>>>>>>  <class>my.company.weather.entities.WeatherCurrent</class>
>>>>>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>>>>>>  </persistence-unit>
>>>>>>> </persistence>
>>>>>>>
>>>>>>> I think the problem is that my model bundle is not seeing the
>>>>>>> datasource service. How do I confirm that or how should my model's
>>>>>>>  MANIFEST look like?
>>>>>>>
>>>>>>> Cheers,
>>>>>>> borut
>>>>>>>
>>>>>>>
>>>>>>> Dne 19. april 2012 20:35 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>>>>
>>>>>>> A few years back Hibernate was my choice. The past two years I have
>>>>>>>> moved to OpenJPA. The main reason is that OpenJPA works much better with
>>>>>>>> OSGi. I did try EclipseLink as well but had OSGi problems. This was a while
>>>>>>>> back and has probably been improved by now.
>>>>>>>>
>>>>>>>> Another reason why I prefer OpenJPA to Hibernate is that the Apache
>>>>>>>> community is so much better - much more open. I'm sure this is a matter of
>>>>>>>> taste but I would not go for Hibernate.
>>>>>>>>
>>>>>>>> That said, OpenJPA also has some classloading issues under OSGi. In
>>>>>>>> normal situations it works though. A final compelling reason to use OpenJPA
>>>>>>>> is that it is much more common choice when using Apache Karaf (I think).
>>>>>>>> It's normally easier to use different Apache projects together since
>>>>>>>> someone else has always done it before.
>>>>>>>>
>>>>>>>> What I don't like is the way JPA uses the persistence.xml. I tend
>>>>>>>> to go with the approach Christian recommended - to put the datasource in a
>>>>>>>> separate bundle. It can then easily be switched. In practice, though, it's
>>>>>>>> hard to actually change database type (not just url) without having to
>>>>>>>> affect the application.
>>>>>>>>
>>>>>>>> First, the JPA implementation is configured in persistence.xml. E g
>>>>>>>> that's where you specify database dialect for OpenJPA. Ideally this would
>>>>>>>> be separated from the persistence.xml and possible to configure (e g with
>>>>>>>> OSGi's config admin).
>>>>>>>>
>>>>>>>> Second, at least when using JPA annotations (which I do), your
>>>>>>>> source code becomes tailored for a certain database type. I often startup
>>>>>>>> with a simple Derby database for testing and then move  to SQLServer for
>>>>>>>> production. In that process I often have to change some annotations to make
>>>>>>>> it work in SQLServer.
>>>>>>>>
>>>>>>>> Overall I'm quite content with the OpenJPA+Aries+Karaf combo
>>>>>>>> though. I just wish that Aries could get their release process straightened
>>>>>>>> out soon.
>>>>>>>>
>>>>>>>> /Bengt
>>>>>>>>
>>>>>>>>
>>>>>>>> 2012/4/19 Borut Bolcina <bo...@gmail.com>
>>>>>>>>
>>>>>>>>> On 19. apr. 2012, at 16:11, Christian Schneider <
>>>>>>>>> chris@die-schneider.net> wrote:
>>>>>>>>>
>>>>>>>>> > I guess the suggested way is to not run hibernate :-) For me the
>>>>>>>>> fact that they do not create bundles says that jboss does not care about
>>>>>>>>> OSGi in hibernate. As they now have an OSGi server with JBoss 7 that may
>>>>>>>>> change soon though.
>>>>>>>>>
>>>>>>>>> I just looked at JBoss website and their support is not even in
>>>>>>>>> dipers. See https://issues.jboss.org/browse/JBOSGI-260.
>>>>>>>>>
>>>>>>>>> > I had some good experience with apache openjpa together with
>>>>>>>>> apache aries jpa. Together they solve the classloading problem where the
>>>>>>>>> jpa provider can not see the user classes. I have not built bigger
>>>>>>>>> applications with it though.
>>>>>>>>>
>>>>>>>>> I will try with OpenJPA, but would really like to hear other
>>>>>>>>> people's hibernate stories!
>>>>>>>>>
>>>>>>>>> >
>>>>>>>>> > There is also Eclipselink. With their affiliation to Eclipse
>>>>>>>>> they will surely have an eye on OSGi compatibility. The problem there was
>>>>>>>>> that they did not put their jas into the maven central repo.
>>>>>>>>> >
>>>>>>>>> > So all in all I am not sure what to recommend. Perhaps others
>>>>>>>>> already have experience with some jpa solution in bigger projects?
>>>>>>>>>
>>>>>>>>> Please share some stories to make my decision easier.
>>>>>>>>>
>>>>>>>>> Borut
>>>>>>>>>
>>>>>>>>> >
>>>>>>>>> > Christian
>>>>>>>>> >
>>>>>>>>> > Am 19.04.2012 15:56, schrieb Borut Bolčina:
>>>>>>>>> >> Thanks Christian,
>>>>>>>>> >>
>>>>>>>>> >> I understand now what you were suggesting. The database type
>>>>>>>>> (vendor) will be the same in all environments (mysql), but with different
>>>>>>>>> addresses, engine types, usernames and passwords, which brings another
>>>>>>>>> topic up - configuration (I will probably ask this in days to come).
>>>>>>>>> >>
>>>>>>>>> >> I will be separating datasources, it is just the case that I
>>>>>>>>> want a working solution and then smooth it out.
>>>>>>>>> >>
>>>>>>>>> >> For a begginer it is very hard to get a hibernate mysql combo
>>>>>>>>> to work (mine still does not). There are examples for persistence, but I
>>>>>>>>> had to read a lot until I found that Hibernate does not even has bundles,
>>>>>>>>> therefore tricks has to be performed.
>>>>>>>>> >>
>>>>>>>>> >> Is there "an official Karaf Hibernate Feature"? If not, what is
>>>>>>>>> the suggested way to run Hibernate in Karaf? I am planning to use Hibernate
>>>>>>>>> Search, Solr and Lucene by using Camel components, so I have lots of ground
>>>>>>>>> to cover.
>>>>>>>>> >>
>>>>>>>>> >> Cheers,
>>>>>>>>> >> borut
>>>>>>>>> >>
>>>>>>>>> >
>>>>>>>>> > --
>>>>>>>>> > Christian Schneider
>>>>>>>>> > http://www.liquid-reality.de
>>>>>>>>> >
>>>>>>>>> > Open Source Architect
>>>>>>>>> > Talend Application Integration Division http://www.talend.com
>>>>>>>>> >
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Re: Deploying data sources

Posted by Bengt Rodehav <be...@rodehav.com>.
JDBCConfiguraionImpl seems to be a class that holds the OpenJPA
configuration. I guess the intention is to log the properties used. They
have probably done that with a simple toString() which has not been
overridden to produce something readable.

/Bengt

2012/4/27 Borut Bolčina <bo...@gmail.com>

> The exception is still the same:
>
> Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
> DataSource class name must be specified in
> the ConnectionDriverName property. Available properties in configuration
> are "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>         at
> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>         at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>         at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>         at
> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>         at
> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
> ....
>
> What does that mean: "Available properties in configuration are..."?
>
>
> -borut
>
>
>
> Dne 27. april 2012 08:31 je Bengt Rodehav <be...@rodehav.com> napisal/-a:
>
> Just realized that when looking at the log messages that you sent, there
>> was one warning and a lot of traces but no error. What exactly does not
>> work for your right now? Do you get an exception or error log?
>>
>> /Bengt
>>
>>
>> 2012/4/27 Bengt Rodehav <be...@rodehav.com>
>>
>>> OK - I didn't realize that you were using JPA 1.0. I've only used JPA
>>> 2.0. What version of OpenJPA do you use then?
>>>
>>> About the validator. Note that it is not enough to verify that the
>>> validator works outside of OSGi since you cannot use an ordinary validator
>>> implementation in OSGi - it will not be found. In the ServiceMix project
>>> they provide an OSGi'ified version of Hibernate's reference implementation
>>> that you can use in OSGi. The problem is that java's standard way of
>>> finding resources does not work in OSGi.
>>>
>>> What validator (and version) implementation do you use?
>>>
>>> /Bengt
>>>
>>>
>>> 2012/4/26 Borut Bolcina <bo...@gmail.com>
>>>
>>>> A minute later after sending the email below, I saw I was using jpa 1.0
>>>> persistence.xml, god knows where I copied/pasted the template from.
>>>>
>>>> I have validator installed, so this is not a problem. I need it as I am
>>>> using some annotations on my model pojo to validate incoming values from
>>>> xml input source.
>>>>
>>>> Right now I am clueless.
>>>>
>>>> Borut
>>>>
>>>> Sent from my iPad
>>>>
>>>> On 26. apr. 2012, at 15:06, Bengt Rodehav <be...@rodehav.com> wrote:
>>>>
>>>> Hello again,
>>>>
>>>> The Warning is know at OpenJPA. I think it is reported in JIRA. It
>>>> turns up now and then but noone seems to know exactly what triggers it.
>>>> I've had it too but it doesn't seem to be a problem.
>>>>
>>>> About validation - I should have though of that...
>>>>
>>>> I also have this line in my persistence.xml:
>>>>
>>>> *    <validation-mode>NONE</validation-mode>*
>>>>
>>>> This tells OpenJPA not to validate. Otherwise you must also deploy a
>>>> validation provider. I've used the reference implementation from Hibernate
>>>> for this but normally I turn it off with the above line.
>>>>
>>>> /Bengt
>>>>
>>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>>
>>>>> I modified the model bundle to include properties section in
>>>>> persistence.xml
>>>>>
>>>>> <persistence version="1.0" xmlns="
>>>>> http://java.sun.com/xml/ns/persistence" xmlns:xsi="
>>>>> http://www.w3.org/2001/XMLSchema-instance"
>>>>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>>>>
>>>>> <persistence-unit name="weather" transaction-type="JTA">
>>>>>
>>>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>>>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>>>>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>>>>  <class>si.najdi.weather.entities.WeatherCurrent</class>
>>>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>>>>
>>>>> <properties>
>>>>> <property name="openjpa.ConnectionFactoryMode" value="managed" />
>>>>>  <property name="openjpa.jdbc.DBDictionary"
>>>>> value="mysql(TableType=innodb)" />
>>>>>  <property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO" />
>>>>> </properties>
>>>>>
>>>>> </persistence-unit>
>>>>> </persistence>
>>>>>
>>>>> and reinstalled all my bundles, but it makes no difference.
>>>>>
>>>>> I notices this in my console when the route is started:
>>>>>
>>>>> 20  WARN   [Blueprint Extender: 2] openjpa.Runtime - The configuration
>>>>> property named "openjpa.Id" was not recognized and will be ignored,
>>>>> although the name closely matches a valid property called "openjpa.Id".
>>>>>
>>>>> With the TRACE level enabled, I see:
>>>>>
>>>>> karaf@root> osgi:install -s
>>>>> mvn:com.mycompany/weather-model/1.0.5-SNAPSHOT
>>>>> 35  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the
>>>>> following properties from "?" into configuration:
>>>>> {openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
>>>>> openjpa.ConnectionFactoryMode=managed,
>>>>> javax.persistence.validation.mode=AUTO,
>>>>> javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
>>>>> openjpa.TransactionMode=managed,
>>>>> openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
>>>>> openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac,
>>>>> javax.persistence.sharedCache.mode=UNSPECIFIED,
>>>>> openjpa.Log=DefaultLevel=TRACE, Tool=INFO,
>>>>> openjpa.jdbc.DBDictionary=mysql(TableType=innodb), PersistenceVersion=1.0,
>>>>> openjpa.Id=weather}
>>>>> 58  weather  TRACE  [Thread-10] openjpa.Runtime - No cache marshaller
>>>>> found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
>>>>> 104  weather  TRACE  [Thread-10] openjpa.MetaData - Scanning resource
>>>>> "META-INF/orm.xml" for persistent types.
>>>>> 105  weather  TRACE  [Thread-10] openjpa.MetaData - The persistent
>>>>> unit root url is "null"
>>>>> 105  weather  TRACE  [Thread-10] openjpa.MetaData -
>>>>> parsePersistentTypeNames() found
>>>>> [com.mycompany.weather.entities.WeatherCurrent].
>>>>> 106  weather  TRACE  [Thread-10] openjpa.MetaData - Found 1 classes
>>>>> with metadata in 48 milliseconds.
>>>>> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following
>>>>> properties from "?" into configuration: {openjpa.BrokerFactory=jdbc,
>>>>> javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
>>>>> javax.persistence.sharedCache.mode=UNSPECIFIED, PersistenceVersion=1.0,
>>>>> openjpa.jdbc.DBDictionary=mysql(TableType=innodb),
>>>>> openjpa.Log=DefaultLevel=TRACE, Tool=INFO, openjpa.Id=weather,
>>>>> openjpa.ConnectionFactoryMode=managed,
>>>>> openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
>>>>> javax.persistence.validation.mode=AUTO, openjpa.TransactionMode=managed,
>>>>> openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
>>>>> openjpa.BrokerImpl=non-finalizing,
>>>>> openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac
>>>>> }
>>>>> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Not creating a
>>>>> ValidatorImpl because this app is using the JPA 1.0 Spec
>>>>> 1  weather  TRACE  [Thread-10] openjpa.Runtime -
>>>>> org.apache.openjpa.persistence.PersistenceProviderImpl@1ad69f1creating container
>>>>> org.apache.openjpa.persistence.EntityManagerFactoryImpl@6888b for PU
>>>>> weather.
>>>>> Bundle ID: 137
>>>>>
>>>>>
>>>>> Certanly this look strange:
>>>>> Not creating a ValidatorImpl because this app is using the JPA 1.0 Spec
>>>>>
>>>>> Digging...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Dne 26. april 2012 12:57 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>>
>>>>> Then I guess OpenJPA can't find or does not try to find your
>>>>>> datasource service. Looking at my different persistence.xml's I usually
>>>>>> have a few OpenJPA properties defined, like this:
>>>>>>
>>>>>> *<properties>*
>>>>>> *      <property name="openjpa.ConnectionFactoryMode"
>>>>>> value="managed" />*
>>>>>> *      <property name="openjpa.jdbc.SynchronizeMappings"
>>>>>> value="buildSchema(ForeignKeys=true)" />*
>>>>>> *      <property name="openjpa.jdbc.DBDictionary"
>>>>>> value="org.apache.openjpa.jdbc.sql.SQLServerDictionary" />*
>>>>>> *      <property name="openjpa.jdbc.UpdateManager"
>>>>>> value="operation-order" />*
>>>>>> *      <property name="openjpa.Log" value="DefaultLevel=INFO,
>>>>>> Tool=INFO" />*
>>>>>> *<!--      <property name="openjpa.Log" value="DefaultLevel=TRACE,
>>>>>> Tool=INFO" />-->*
>>>>>> *    </properties>*
>>>>>>
>>>>>> One idea is to enable TRACE logging to see what OpenJPA complains
>>>>>> about. Another one is that maybe the first property (the
>>>>>> ConnectionFactoryMode) must be set to "managed" for this to work. I'm not
>>>>>> sure but there is probably a reason why I always have that property defined.
>>>>>>
>>>>>> /Bengt
>>>>>>
>>>>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> yes I find this comments very useful!
>>>>>>>
>>>>>>> karaf@root> ls | grep -B 4 javax.sql.DataSource
>>>>>>> org.apache.aries.jpa.container.context.PersistenceContextProvider
>>>>>>>
>>>>>>> weather-datasource (123) provides:
>>>>>>> ----------------------------------
>>>>>>> javax.sql.DataSource
>>>>>>> karaf@root> ls 123
>>>>>>>
>>>>>>> weather-datasource (123) provides:
>>>>>>> ----------------------------------
>>>>>>> objectClass = javax.sql.DataSource
>>>>>>> osgi.jndi.service.name = jdbc/mysqlds
>>>>>>> osgi.service.blueprint.compname = weatherDataSource
>>>>>>> service.id = 222
>>>>>>> ----
>>>>>>> objectClass = org.osgi.service.blueprint.container.BlueprintContainer
>>>>>>> osgi.blueprint.container.symbolicname = weather-datasource
>>>>>>> osgi.blueprint.container.version = 1.0.5.SNAPSHOT
>>>>>>> service.id = 223
>>>>>>>
>>>>>>> I guess the datasource service is published correctly.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> borut
>>>>>>>
>>>>>>> Dne 26. april 2012 11:09 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>>>>
>>>>>>> Hello there,
>>>>>>>>
>>>>>>>> I guess you should check that your datasource has been published as
>>>>>>>> a service. I'm not the best Karaf guru but I would do something like this:
>>>>>>>>
>>>>>>>> Check what services provides datasources:
>>>>>>>>
>>>>>>>> *ls | grep -B 4 javax.sql.DataSource*
>>>>>>>>
>>>>>>>> This should identify what bundles provide datasources as services.
>>>>>>>> Assume that one of the bundles had the bundle id 78, you could then look
>>>>>>>> more closely at that bundles services with the following command:
>>>>>>>>
>>>>>>>> *ls 78*
>>>>>>>> *
>>>>>>>> *
>>>>>>>> You will now see the services provided by this bundle and also its
>>>>>>>> service properties. You should see a line similar to:
>>>>>>>>
>>>>>>>> *osgi.jndi.service.name = jdbc/mysqlds*
>>>>>>>>
>>>>>>>> Hope that helps,
>>>>>>>>
>>>>>>>> /Bengt
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>>>>>>
>>>>>>>>> Hello,
>>>>>>>>>
>>>>>>>>> thanks Bengt for your input, I really appreciate you took the time!
>>>>>>>>>
>>>>>>>>> My work on this is somehow sporadic, but now I have managed to get
>>>>>>>>> the Camel route running in Karaf
>>>>>>>>>
>>>>>>>>> from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
>>>>>>>>>  .log("Getting weather from: " + sourceUrl)
>>>>>>>>> .to(sourceUrl)
>>>>>>>>>  .split()
>>>>>>>>> .tokenizeXML("metData")
>>>>>>>>>  .unmarshal(jaxbDataFormat)
>>>>>>>>>
>>>>>>>>> .to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
>>>>>>>>>
>>>>>>>>> with the exception of saving the data to the database which fails
>>>>>>>>> with:
>>>>>>>>>
>>>>>>>>> Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
>>>>>>>>> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
>>>>>>>>> DataSource class name must be specified in
>>>>>>>>> the ConnectionDriverName property. Available properties in
>>>>>>>>> configuration are
>>>>>>>>> "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>>>>>>>>>         at
>>>>>>>>> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>>>>>>>>>         at
>>>>>>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>>>>>>>>>         at
>>>>>>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>>>>>>>>>         at
>>>>>>>>> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>>>>>>>>>         at
>>>>>>>>> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
>>>>>>>>> ....
>>>>>>>>>
>>>>>>>>> My datasource bundle is deployed in OSGi (later the username and
>>>>>>>>> password will be configurable, that is - outside of the bundle)
>>>>>>>>>
>>>>>>>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>>>>>>>>>
>>>>>>>>>  <bean id="weatherDataSource"
>>>>>>>>> class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
>>>>>>>>> <property name="url"
>>>>>>>>>  value="jdbc:mysql://
>>>>>>>>> dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8<http://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>"
>>>>>>>>> />
>>>>>>>>>  <property name="user" value="myUsername" />
>>>>>>>>> <property name="password" value="myPassword" />
>>>>>>>>>  </bean>
>>>>>>>>>
>>>>>>>>> <service interface="javax.sql.DataSource" ref="weatherDataSource">
>>>>>>>>>  <service-properties>
>>>>>>>>> <entry key="osgi.jndi.service.name" value="jdbc/mysqlds" />
>>>>>>>>>  </service-properties>
>>>>>>>>> </service>
>>>>>>>>>  </blueprint>
>>>>>>>>>
>>>>>>>>> which is used by my model bundle's persistence.xml
>>>>>>>>>
>>>>>>>>> <persistence version="1.0" xmlns="
>>>>>>>>> http://java.sun.com/xml/ns/persistence" xmlns:xsi="
>>>>>>>>> http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>>>>>>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>>>>>>>>   <persistence-unit name="weather" transaction-type="JTA">
>>>>>>>>>
>>>>>>>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>>>>>>>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>>>>>>>>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>>>>>>>>  <class>my.company.weather.entities.WeatherCurrent</class>
>>>>>>>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>>>>>>>>  </persistence-unit>
>>>>>>>>> </persistence>
>>>>>>>>>
>>>>>>>>> I think the problem is that my model bundle is not seeing the
>>>>>>>>> datasource service. How do I confirm that or how should my model's
>>>>>>>>>  MANIFEST look like?
>>>>>>>>>
>>>>>>>>> Cheers,
>>>>>>>>> borut
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Dne 19. april 2012 20:35 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>>>>>>
>>>>>>>>> A few years back Hibernate was my choice. The past two years I
>>>>>>>>>> have moved to OpenJPA. The main reason is that OpenJPA works much better
>>>>>>>>>> with OSGi. I did try EclipseLink as well but had OSGi problems. This was a
>>>>>>>>>> while back and has probably been improved by now.
>>>>>>>>>>
>>>>>>>>>> Another reason why I prefer OpenJPA to Hibernate is that the
>>>>>>>>>> Apache community is so much better - much more open. I'm sure this is a
>>>>>>>>>> matter of taste but I would not go for Hibernate.
>>>>>>>>>>
>>>>>>>>>> That said, OpenJPA also has some classloading issues under OSGi.
>>>>>>>>>> In normal situations it works though. A final compelling reason to use
>>>>>>>>>> OpenJPA is that it is much more common choice when using Apache Karaf (I
>>>>>>>>>> think). It's normally easier to use different Apache projects together
>>>>>>>>>> since someone else has always done it before.
>>>>>>>>>>
>>>>>>>>>> What I don't like is the way JPA uses the persistence.xml. I tend
>>>>>>>>>> to go with the approach Christian recommended - to put the datasource in a
>>>>>>>>>> separate bundle. It can then easily be switched. In practice, though, it's
>>>>>>>>>> hard to actually change database type (not just url) without having to
>>>>>>>>>> affect the application.
>>>>>>>>>>
>>>>>>>>>> First, the JPA implementation is configured in persistence.xml. E
>>>>>>>>>> g that's where you specify database dialect for OpenJPA. Ideally this would
>>>>>>>>>> be separated from the persistence.xml and possible to configure (e g with
>>>>>>>>>> OSGi's config admin).
>>>>>>>>>>
>>>>>>>>>> Second, at least when using JPA annotations (which I do), your
>>>>>>>>>> source code becomes tailored for a certain database type. I often startup
>>>>>>>>>> with a simple Derby database for testing and then move  to SQLServer for
>>>>>>>>>> production. In that process I often have to change some annotations to make
>>>>>>>>>> it work in SQLServer.
>>>>>>>>>>
>>>>>>>>>> Overall I'm quite content with the OpenJPA+Aries+Karaf combo
>>>>>>>>>> though. I just wish that Aries could get their release process straightened
>>>>>>>>>> out soon.
>>>>>>>>>>
>>>>>>>>>> /Bengt
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 2012/4/19 Borut Bolcina <bo...@gmail.com>
>>>>>>>>>>
>>>>>>>>>>> On 19. apr. 2012, at 16:11, Christian Schneider <
>>>>>>>>>>> chris@die-schneider.net> wrote:
>>>>>>>>>>>
>>>>>>>>>>> > I guess the suggested way is to not run hibernate :-) For me
>>>>>>>>>>> the fact that they do not create bundles says that jboss does not care
>>>>>>>>>>> about OSGi in hibernate. As they now have an OSGi server with JBoss 7 that
>>>>>>>>>>> may change soon though.
>>>>>>>>>>>
>>>>>>>>>>> I just looked at JBoss website and their support is not even in
>>>>>>>>>>> dipers. See https://issues.jboss.org/browse/JBOSGI-260.
>>>>>>>>>>>
>>>>>>>>>>> > I had some good experience with apache openjpa together with
>>>>>>>>>>> apache aries jpa. Together they solve the classloading problem where the
>>>>>>>>>>> jpa provider can not see the user classes. I have not built bigger
>>>>>>>>>>> applications with it though.
>>>>>>>>>>>
>>>>>>>>>>> I will try with OpenJPA, but would really like to hear other
>>>>>>>>>>> people's hibernate stories!
>>>>>>>>>>>
>>>>>>>>>>> >
>>>>>>>>>>> > There is also Eclipselink. With their affiliation to Eclipse
>>>>>>>>>>> they will surely have an eye on OSGi compatibility. The problem there was
>>>>>>>>>>> that they did not put their jas into the maven central repo.
>>>>>>>>>>> >
>>>>>>>>>>> > So all in all I am not sure what to recommend. Perhaps others
>>>>>>>>>>> already have experience with some jpa solution in bigger projects?
>>>>>>>>>>>
>>>>>>>>>>> Please share some stories to make my decision easier.
>>>>>>>>>>>
>>>>>>>>>>> Borut
>>>>>>>>>>>
>>>>>>>>>>> >
>>>>>>>>>>> > Christian
>>>>>>>>>>> >
>>>>>>>>>>> > Am 19.04.2012 15:56, schrieb Borut Bolčina:
>>>>>>>>>>> >> Thanks Christian,
>>>>>>>>>>> >>
>>>>>>>>>>> >> I understand now what you were suggesting. The database type
>>>>>>>>>>> (vendor) will be the same in all environments (mysql), but with different
>>>>>>>>>>> addresses, engine types, usernames and passwords, which brings another
>>>>>>>>>>> topic up - configuration (I will probably ask this in days to come).
>>>>>>>>>>> >>
>>>>>>>>>>> >> I will be separating datasources, it is just the case that I
>>>>>>>>>>> want a working solution and then smooth it out.
>>>>>>>>>>> >>
>>>>>>>>>>> >> For a begginer it is very hard to get a hibernate mysql combo
>>>>>>>>>>> to work (mine still does not). There are examples for persistence, but I
>>>>>>>>>>> had to read a lot until I found that Hibernate does not even has bundles,
>>>>>>>>>>> therefore tricks has to be performed.
>>>>>>>>>>> >>
>>>>>>>>>>> >> Is there "an official Karaf Hibernate Feature"? If not, what
>>>>>>>>>>> is the suggested way to run Hibernate in Karaf? I am planning to use
>>>>>>>>>>> Hibernate Search, Solr and Lucene by using Camel components, so I have lots
>>>>>>>>>>> of ground to cover.
>>>>>>>>>>> >>
>>>>>>>>>>> >> Cheers,
>>>>>>>>>>> >> borut
>>>>>>>>>>> >>
>>>>>>>>>>> >
>>>>>>>>>>> > --
>>>>>>>>>>> > Christian Schneider
>>>>>>>>>>> > http://www.liquid-reality.de
>>>>>>>>>>> >
>>>>>>>>>>> > Open Source Architect
>>>>>>>>>>> > Talend Application Integration Division http://www.talend.com
>>>>>>>>>>> >
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Re: Deploying data sources

Posted by Borut Bolčina <bo...@gmail.com>.
The exception is still the same:

Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
DataSource class name must be specified in
the ConnectionDriverName property. Available properties in configuration
are "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
        at
org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
        at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
        at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
        at
org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
        at
org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
....

What does that mean: "Available properties in configuration are..."?


-borut



Dne 27. april 2012 08:31 je Bengt Rodehav <be...@rodehav.com> napisal/-a:

> Just realized that when looking at the log messages that you sent, there
> was one warning and a lot of traces but no error. What exactly does not
> work for your right now? Do you get an exception or error log?
>
> /Bengt
>
>
> 2012/4/27 Bengt Rodehav <be...@rodehav.com>
>
>> OK - I didn't realize that you were using JPA 1.0. I've only used JPA
>> 2.0. What version of OpenJPA do you use then?
>>
>> About the validator. Note that it is not enough to verify that the
>> validator works outside of OSGi since you cannot use an ordinary validator
>> implementation in OSGi - it will not be found. In the ServiceMix project
>> they provide an OSGi'ified version of Hibernate's reference implementation
>> that you can use in OSGi. The problem is that java's standard way of
>> finding resources does not work in OSGi.
>>
>> What validator (and version) implementation do you use?
>>
>> /Bengt
>>
>>
>> 2012/4/26 Borut Bolcina <bo...@gmail.com>
>>
>>> A minute later after sending the email below, I saw I was using jpa 1.0
>>> persistence.xml, god knows where I copied/pasted the template from.
>>>
>>> I have validator installed, so this is not a problem. I need it as I am
>>> using some annotations on my model pojo to validate incoming values from
>>> xml input source.
>>>
>>> Right now I am clueless.
>>>
>>> Borut
>>>
>>> Sent from my iPad
>>>
>>> On 26. apr. 2012, at 15:06, Bengt Rodehav <be...@rodehav.com> wrote:
>>>
>>> Hello again,
>>>
>>> The Warning is know at OpenJPA. I think it is reported in JIRA. It turns
>>> up now and then but noone seems to know exactly what triggers it. I've had
>>> it too but it doesn't seem to be a problem.
>>>
>>> About validation - I should have though of that...
>>>
>>> I also have this line in my persistence.xml:
>>>
>>> *    <validation-mode>NONE</validation-mode>*
>>>
>>> This tells OpenJPA not to validate. Otherwise you must also deploy a
>>> validation provider. I've used the reference implementation from Hibernate
>>> for this but normally I turn it off with the above line.
>>>
>>> /Bengt
>>>
>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>
>>>> I modified the model bundle to include properties section in
>>>> persistence.xml
>>>>
>>>> <persistence version="1.0" xmlns="
>>>> http://java.sun.com/xml/ns/persistence" xmlns:xsi="
>>>> http://www.w3.org/2001/XMLSchema-instance"
>>>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>>>
>>>> <persistence-unit name="weather" transaction-type="JTA">
>>>>
>>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>>>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>>>  <class>si.najdi.weather.entities.WeatherCurrent</class>
>>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>>>
>>>> <properties>
>>>> <property name="openjpa.ConnectionFactoryMode" value="managed" />
>>>>  <property name="openjpa.jdbc.DBDictionary"
>>>> value="mysql(TableType=innodb)" />
>>>>  <property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO" />
>>>> </properties>
>>>>
>>>> </persistence-unit>
>>>> </persistence>
>>>>
>>>> and reinstalled all my bundles, but it makes no difference.
>>>>
>>>> I notices this in my console when the route is started:
>>>>
>>>> 20  WARN   [Blueprint Extender: 2] openjpa.Runtime - The configuration
>>>> property named "openjpa.Id" was not recognized and will be ignored,
>>>> although the name closely matches a valid property called "openjpa.Id".
>>>>
>>>> With the TRACE level enabled, I see:
>>>>
>>>> karaf@root> osgi:install -s
>>>> mvn:com.mycompany/weather-model/1.0.5-SNAPSHOT
>>>> 35  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following
>>>> properties from "?" into configuration:
>>>> {openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
>>>> openjpa.ConnectionFactoryMode=managed,
>>>> javax.persistence.validation.mode=AUTO,
>>>> javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
>>>> openjpa.TransactionMode=managed,
>>>> openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
>>>> openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac,
>>>> javax.persistence.sharedCache.mode=UNSPECIFIED,
>>>> openjpa.Log=DefaultLevel=TRACE, Tool=INFO,
>>>> openjpa.jdbc.DBDictionary=mysql(TableType=innodb), PersistenceVersion=1.0,
>>>> openjpa.Id=weather}
>>>> 58  weather  TRACE  [Thread-10] openjpa.Runtime - No cache marshaller
>>>> found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
>>>> 104  weather  TRACE  [Thread-10] openjpa.MetaData - Scanning resource
>>>> "META-INF/orm.xml" for persistent types.
>>>> 105  weather  TRACE  [Thread-10] openjpa.MetaData - The persistent unit
>>>> root url is "null"
>>>> 105  weather  TRACE  [Thread-10] openjpa.MetaData -
>>>> parsePersistentTypeNames() found
>>>> [com.mycompany.weather.entities.WeatherCurrent].
>>>> 106  weather  TRACE  [Thread-10] openjpa.MetaData - Found 1 classes
>>>> with metadata in 48 milliseconds.
>>>> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following
>>>> properties from "?" into configuration: {openjpa.BrokerFactory=jdbc,
>>>> javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
>>>> javax.persistence.sharedCache.mode=UNSPECIFIED, PersistenceVersion=1.0,
>>>> openjpa.jdbc.DBDictionary=mysql(TableType=innodb),
>>>> openjpa.Log=DefaultLevel=TRACE, Tool=INFO, openjpa.Id=weather,
>>>> openjpa.ConnectionFactoryMode=managed,
>>>> openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
>>>> javax.persistence.validation.mode=AUTO, openjpa.TransactionMode=managed,
>>>> openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
>>>> openjpa.BrokerImpl=non-finalizing,
>>>> openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac
>>>> }
>>>> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Not creating a
>>>> ValidatorImpl because this app is using the JPA 1.0 Spec
>>>> 1  weather  TRACE  [Thread-10] openjpa.Runtime -
>>>> org.apache.openjpa.persistence.PersistenceProviderImpl@1ad69f1creating container
>>>> org.apache.openjpa.persistence.EntityManagerFactoryImpl@6888b for PU
>>>> weather.
>>>> Bundle ID: 137
>>>>
>>>>
>>>> Certanly this look strange:
>>>> Not creating a ValidatorImpl because this app is using the JPA 1.0 Spec
>>>>
>>>> Digging...
>>>>
>>>>
>>>>
>>>>
>>>> Dne 26. april 2012 12:57 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>
>>>> Then I guess OpenJPA can't find or does not try to find your datasource
>>>>> service. Looking at my different persistence.xml's I usually have a few
>>>>> OpenJPA properties defined, like this:
>>>>>
>>>>> *<properties>*
>>>>> *      <property name="openjpa.ConnectionFactoryMode" value="managed"
>>>>> />*
>>>>> *      <property name="openjpa.jdbc.SynchronizeMappings"
>>>>> value="buildSchema(ForeignKeys=true)" />*
>>>>> *      <property name="openjpa.jdbc.DBDictionary"
>>>>> value="org.apache.openjpa.jdbc.sql.SQLServerDictionary" />*
>>>>> *      <property name="openjpa.jdbc.UpdateManager"
>>>>> value="operation-order" />*
>>>>> *      <property name="openjpa.Log" value="DefaultLevel=INFO,
>>>>> Tool=INFO" />*
>>>>> *<!--      <property name="openjpa.Log" value="DefaultLevel=TRACE,
>>>>> Tool=INFO" />-->*
>>>>> *    </properties>*
>>>>>
>>>>> One idea is to enable TRACE logging to see what OpenJPA complains
>>>>> about. Another one is that maybe the first property (the
>>>>> ConnectionFactoryMode) must be set to "managed" for this to work. I'm not
>>>>> sure but there is probably a reason why I always have that property defined.
>>>>>
>>>>> /Bengt
>>>>>
>>>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> yes I find this comments very useful!
>>>>>>
>>>>>> karaf@root> ls | grep -B 4 javax.sql.DataSource
>>>>>> org.apache.aries.jpa.container.context.PersistenceContextProvider
>>>>>>
>>>>>> weather-datasource (123) provides:
>>>>>> ----------------------------------
>>>>>> javax.sql.DataSource
>>>>>> karaf@root> ls 123
>>>>>>
>>>>>> weather-datasource (123) provides:
>>>>>> ----------------------------------
>>>>>> objectClass = javax.sql.DataSource
>>>>>> osgi.jndi.service.name = jdbc/mysqlds
>>>>>> osgi.service.blueprint.compname = weatherDataSource
>>>>>> service.id = 222
>>>>>> ----
>>>>>> objectClass = org.osgi.service.blueprint.container.BlueprintContainer
>>>>>> osgi.blueprint.container.symbolicname = weather-datasource
>>>>>> osgi.blueprint.container.version = 1.0.5.SNAPSHOT
>>>>>> service.id = 223
>>>>>>
>>>>>> I guess the datasource service is published correctly.
>>>>>>
>>>>>> Thanks,
>>>>>> borut
>>>>>>
>>>>>> Dne 26. april 2012 11:09 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>>>
>>>>>> Hello there,
>>>>>>>
>>>>>>> I guess you should check that your datasource has been published as
>>>>>>> a service. I'm not the best Karaf guru but I would do something like this:
>>>>>>>
>>>>>>> Check what services provides datasources:
>>>>>>>
>>>>>>> *ls | grep -B 4 javax.sql.DataSource*
>>>>>>>
>>>>>>> This should identify what bundles provide datasources as services.
>>>>>>> Assume that one of the bundles had the bundle id 78, you could then look
>>>>>>> more closely at that bundles services with the following command:
>>>>>>>
>>>>>>> *ls 78*
>>>>>>> *
>>>>>>> *
>>>>>>> You will now see the services provided by this bundle and also its
>>>>>>> service properties. You should see a line similar to:
>>>>>>>
>>>>>>> *osgi.jndi.service.name = jdbc/mysqlds*
>>>>>>>
>>>>>>> Hope that helps,
>>>>>>>
>>>>>>> /Bengt
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>>>>>
>>>>>>>> Hello,
>>>>>>>>
>>>>>>>> thanks Bengt for your input, I really appreciate you took the time!
>>>>>>>>
>>>>>>>> My work on this is somehow sporadic, but now I have managed to get
>>>>>>>> the Camel route running in Karaf
>>>>>>>>
>>>>>>>> from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
>>>>>>>>  .log("Getting weather from: " + sourceUrl)
>>>>>>>> .to(sourceUrl)
>>>>>>>>  .split()
>>>>>>>> .tokenizeXML("metData")
>>>>>>>>  .unmarshal(jaxbDataFormat)
>>>>>>>>
>>>>>>>> .to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
>>>>>>>>
>>>>>>>> with the exception of saving the data to the database which fails
>>>>>>>> with:
>>>>>>>>
>>>>>>>> Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
>>>>>>>> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
>>>>>>>> DataSource class name must be specified in
>>>>>>>> the ConnectionDriverName property. Available properties in
>>>>>>>> configuration are
>>>>>>>> "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>>>>>>>>         at
>>>>>>>> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>>>>>>>>         at
>>>>>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>>>>>>>>         at
>>>>>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>>>>>>>>         at
>>>>>>>> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>>>>>>>>         at
>>>>>>>> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
>>>>>>>> ....
>>>>>>>>
>>>>>>>> My datasource bundle is deployed in OSGi (later the username and
>>>>>>>> password will be configurable, that is - outside of the bundle)
>>>>>>>>
>>>>>>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>>>>>>>>
>>>>>>>>  <bean id="weatherDataSource"
>>>>>>>> class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
>>>>>>>> <property name="url"
>>>>>>>>  value="jdbc:mysql://
>>>>>>>> dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8<http://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>"
>>>>>>>> />
>>>>>>>>  <property name="user" value="myUsername" />
>>>>>>>> <property name="password" value="myPassword" />
>>>>>>>>  </bean>
>>>>>>>>
>>>>>>>> <service interface="javax.sql.DataSource" ref="weatherDataSource">
>>>>>>>>  <service-properties>
>>>>>>>> <entry key="osgi.jndi.service.name" value="jdbc/mysqlds" />
>>>>>>>>  </service-properties>
>>>>>>>> </service>
>>>>>>>>  </blueprint>
>>>>>>>>
>>>>>>>> which is used by my model bundle's persistence.xml
>>>>>>>>
>>>>>>>> <persistence version="1.0" xmlns="
>>>>>>>> http://java.sun.com/xml/ns/persistence" xmlns:xsi="
>>>>>>>> http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>>>>>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>>>>>>>   <persistence-unit name="weather" transaction-type="JTA">
>>>>>>>>
>>>>>>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>>>>>>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>>>>>>>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>>>>>>>  <class>my.company.weather.entities.WeatherCurrent</class>
>>>>>>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>>>>>>>  </persistence-unit>
>>>>>>>> </persistence>
>>>>>>>>
>>>>>>>> I think the problem is that my model bundle is not seeing the
>>>>>>>> datasource service. How do I confirm that or how should my model's
>>>>>>>>  MANIFEST look like?
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>> borut
>>>>>>>>
>>>>>>>>
>>>>>>>> Dne 19. april 2012 20:35 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>>>>>
>>>>>>>> A few years back Hibernate was my choice. The past two years I have
>>>>>>>>> moved to OpenJPA. The main reason is that OpenJPA works much better with
>>>>>>>>> OSGi. I did try EclipseLink as well but had OSGi problems. This was a while
>>>>>>>>> back and has probably been improved by now.
>>>>>>>>>
>>>>>>>>> Another reason why I prefer OpenJPA to Hibernate is that the
>>>>>>>>> Apache community is so much better - much more open. I'm sure this is a
>>>>>>>>> matter of taste but I would not go for Hibernate.
>>>>>>>>>
>>>>>>>>> That said, OpenJPA also has some classloading issues under OSGi.
>>>>>>>>> In normal situations it works though. A final compelling reason to use
>>>>>>>>> OpenJPA is that it is much more common choice when using Apache Karaf (I
>>>>>>>>> think). It's normally easier to use different Apache projects together
>>>>>>>>> since someone else has always done it before.
>>>>>>>>>
>>>>>>>>> What I don't like is the way JPA uses the persistence.xml. I tend
>>>>>>>>> to go with the approach Christian recommended - to put the datasource in a
>>>>>>>>> separate bundle. It can then easily be switched. In practice, though, it's
>>>>>>>>> hard to actually change database type (not just url) without having to
>>>>>>>>> affect the application.
>>>>>>>>>
>>>>>>>>> First, the JPA implementation is configured in persistence.xml. E
>>>>>>>>> g that's where you specify database dialect for OpenJPA. Ideally this would
>>>>>>>>> be separated from the persistence.xml and possible to configure (e g with
>>>>>>>>> OSGi's config admin).
>>>>>>>>>
>>>>>>>>> Second, at least when using JPA annotations (which I do), your
>>>>>>>>> source code becomes tailored for a certain database type. I often startup
>>>>>>>>> with a simple Derby database for testing and then move  to SQLServer for
>>>>>>>>> production. In that process I often have to change some annotations to make
>>>>>>>>> it work in SQLServer.
>>>>>>>>>
>>>>>>>>> Overall I'm quite content with the OpenJPA+Aries+Karaf combo
>>>>>>>>> though. I just wish that Aries could get their release process straightened
>>>>>>>>> out soon.
>>>>>>>>>
>>>>>>>>> /Bengt
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 2012/4/19 Borut Bolcina <bo...@gmail.com>
>>>>>>>>>
>>>>>>>>>> On 19. apr. 2012, at 16:11, Christian Schneider <
>>>>>>>>>> chris@die-schneider.net> wrote:
>>>>>>>>>>
>>>>>>>>>> > I guess the suggested way is to not run hibernate :-) For me
>>>>>>>>>> the fact that they do not create bundles says that jboss does not care
>>>>>>>>>> about OSGi in hibernate. As they now have an OSGi server with JBoss 7 that
>>>>>>>>>> may change soon though.
>>>>>>>>>>
>>>>>>>>>> I just looked at JBoss website and their support is not even in
>>>>>>>>>> dipers. See https://issues.jboss.org/browse/JBOSGI-260.
>>>>>>>>>>
>>>>>>>>>> > I had some good experience with apache openjpa together with
>>>>>>>>>> apache aries jpa. Together they solve the classloading problem where the
>>>>>>>>>> jpa provider can not see the user classes. I have not built bigger
>>>>>>>>>> applications with it though.
>>>>>>>>>>
>>>>>>>>>> I will try with OpenJPA, but would really like to hear other
>>>>>>>>>> people's hibernate stories!
>>>>>>>>>>
>>>>>>>>>> >
>>>>>>>>>> > There is also Eclipselink. With their affiliation to Eclipse
>>>>>>>>>> they will surely have an eye on OSGi compatibility. The problem there was
>>>>>>>>>> that they did not put their jas into the maven central repo.
>>>>>>>>>> >
>>>>>>>>>> > So all in all I am not sure what to recommend. Perhaps others
>>>>>>>>>> already have experience with some jpa solution in bigger projects?
>>>>>>>>>>
>>>>>>>>>> Please share some stories to make my decision easier.
>>>>>>>>>>
>>>>>>>>>> Borut
>>>>>>>>>>
>>>>>>>>>> >
>>>>>>>>>> > Christian
>>>>>>>>>> >
>>>>>>>>>> > Am 19.04.2012 15:56, schrieb Borut Bolčina:
>>>>>>>>>> >> Thanks Christian,
>>>>>>>>>> >>
>>>>>>>>>> >> I understand now what you were suggesting. The database type
>>>>>>>>>> (vendor) will be the same in all environments (mysql), but with different
>>>>>>>>>> addresses, engine types, usernames and passwords, which brings another
>>>>>>>>>> topic up - configuration (I will probably ask this in days to come).
>>>>>>>>>> >>
>>>>>>>>>> >> I will be separating datasources, it is just the case that I
>>>>>>>>>> want a working solution and then smooth it out.
>>>>>>>>>> >>
>>>>>>>>>> >> For a begginer it is very hard to get a hibernate mysql combo
>>>>>>>>>> to work (mine still does not). There are examples for persistence, but I
>>>>>>>>>> had to read a lot until I found that Hibernate does not even has bundles,
>>>>>>>>>> therefore tricks has to be performed.
>>>>>>>>>> >>
>>>>>>>>>> >> Is there "an official Karaf Hibernate Feature"? If not, what
>>>>>>>>>> is the suggested way to run Hibernate in Karaf? I am planning to use
>>>>>>>>>> Hibernate Search, Solr and Lucene by using Camel components, so I have lots
>>>>>>>>>> of ground to cover.
>>>>>>>>>> >>
>>>>>>>>>> >> Cheers,
>>>>>>>>>> >> borut
>>>>>>>>>> >>
>>>>>>>>>> >
>>>>>>>>>> > --
>>>>>>>>>> > Christian Schneider
>>>>>>>>>> > http://www.liquid-reality.de
>>>>>>>>>> >
>>>>>>>>>> > Open Source Architect
>>>>>>>>>> > Talend Application Integration Division http://www.talend.com
>>>>>>>>>> >
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Re: Deploying data sources

Posted by Bengt Rodehav <be...@rodehav.com>.
Just realized that when looking at the log messages that you sent, there
was one warning and a lot of traces but no error. What exactly does not
work for your right now? Do you get an exception or error log?

/Bengt

2012/4/27 Bengt Rodehav <be...@rodehav.com>

> OK - I didn't realize that you were using JPA 1.0. I've only used JPA 2.0.
> What version of OpenJPA do you use then?
>
> About the validator. Note that it is not enough to verify that the
> validator works outside of OSGi since you cannot use an ordinary validator
> implementation in OSGi - it will not be found. In the ServiceMix project
> they provide an OSGi'ified version of Hibernate's reference implementation
> that you can use in OSGi. The problem is that java's standard way of
> finding resources does not work in OSGi.
>
> What validator (and version) implementation do you use?
>
> /Bengt
>
>
> 2012/4/26 Borut Bolcina <bo...@gmail.com>
>
>> A minute later after sending the email below, I saw I was using jpa 1.0
>> persistence.xml, god knows where I copied/pasted the template from.
>>
>> I have validator installed, so this is not a problem. I need it as I am
>> using some annotations on my model pojo to validate incoming values from
>> xml input source.
>>
>> Right now I am clueless.
>>
>> Borut
>>
>> Sent from my iPad
>>
>> On 26. apr. 2012, at 15:06, Bengt Rodehav <be...@rodehav.com> wrote:
>>
>> Hello again,
>>
>> The Warning is know at OpenJPA. I think it is reported in JIRA. It turns
>> up now and then but noone seems to know exactly what triggers it. I've had
>> it too but it doesn't seem to be a problem.
>>
>> About validation - I should have though of that...
>>
>> I also have this line in my persistence.xml:
>>
>> *    <validation-mode>NONE</validation-mode>*
>>
>> This tells OpenJPA not to validate. Otherwise you must also deploy a
>> validation provider. I've used the reference implementation from Hibernate
>> for this but normally I turn it off with the above line.
>>
>> /Bengt
>>
>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>
>>> I modified the model bundle to include properties section in
>>> persistence.xml
>>>
>>> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>>
>>> <persistence-unit name="weather" transaction-type="JTA">
>>>
>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>>  <class>si.najdi.weather.entities.WeatherCurrent</class>
>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>>
>>> <properties>
>>> <property name="openjpa.ConnectionFactoryMode" value="managed" />
>>>  <property name="openjpa.jdbc.DBDictionary"
>>> value="mysql(TableType=innodb)" />
>>>  <property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO" />
>>> </properties>
>>>
>>> </persistence-unit>
>>> </persistence>
>>>
>>> and reinstalled all my bundles, but it makes no difference.
>>>
>>> I notices this in my console when the route is started:
>>>
>>> 20  WARN   [Blueprint Extender: 2] openjpa.Runtime - The configuration
>>> property named "openjpa.Id" was not recognized and will be ignored,
>>> although the name closely matches a valid property called "openjpa.Id".
>>>
>>> With the TRACE level enabled, I see:
>>>
>>> karaf@root> osgi:install -s
>>> mvn:com.mycompany/weather-model/1.0.5-SNAPSHOT
>>> 35  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following
>>> properties from "?" into configuration:
>>> {openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
>>> openjpa.ConnectionFactoryMode=managed,
>>> javax.persistence.validation.mode=AUTO,
>>> javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
>>> openjpa.TransactionMode=managed,
>>> openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
>>> openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac,
>>> javax.persistence.sharedCache.mode=UNSPECIFIED,
>>> openjpa.Log=DefaultLevel=TRACE, Tool=INFO,
>>> openjpa.jdbc.DBDictionary=mysql(TableType=innodb), PersistenceVersion=1.0,
>>> openjpa.Id=weather}
>>> 58  weather  TRACE  [Thread-10] openjpa.Runtime - No cache marshaller
>>> found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
>>> 104  weather  TRACE  [Thread-10] openjpa.MetaData - Scanning resource
>>> "META-INF/orm.xml" for persistent types.
>>> 105  weather  TRACE  [Thread-10] openjpa.MetaData - The persistent unit
>>> root url is "null"
>>> 105  weather  TRACE  [Thread-10] openjpa.MetaData -
>>> parsePersistentTypeNames() found
>>> [com.mycompany.weather.entities.WeatherCurrent].
>>> 106  weather  TRACE  [Thread-10] openjpa.MetaData - Found 1 classes with
>>> metadata in 48 milliseconds.
>>> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following
>>> properties from "?" into configuration: {openjpa.BrokerFactory=jdbc,
>>> javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
>>> javax.persistence.sharedCache.mode=UNSPECIFIED, PersistenceVersion=1.0,
>>> openjpa.jdbc.DBDictionary=mysql(TableType=innodb),
>>> openjpa.Log=DefaultLevel=TRACE, Tool=INFO, openjpa.Id=weather,
>>> openjpa.ConnectionFactoryMode=managed,
>>> openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
>>> javax.persistence.validation.mode=AUTO, openjpa.TransactionMode=managed,
>>> openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
>>> openjpa.BrokerImpl=non-finalizing,
>>> openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac
>>> }
>>> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Not creating a
>>> ValidatorImpl because this app is using the JPA 1.0 Spec
>>> 1  weather  TRACE  [Thread-10] openjpa.Runtime -
>>> org.apache.openjpa.persistence.PersistenceProviderImpl@1ad69f1 creating
>>> container org.apache.openjpa.persistence.EntityManagerFactoryImpl@6888bfor PU weather.
>>> Bundle ID: 137
>>>
>>>
>>> Certanly this look strange:
>>> Not creating a ValidatorImpl because this app is using the JPA 1.0 Spec
>>>
>>> Digging...
>>>
>>>
>>>
>>>
>>> Dne 26. april 2012 12:57 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>
>>> Then I guess OpenJPA can't find or does not try to find your datasource
>>>> service. Looking at my different persistence.xml's I usually have a few
>>>> OpenJPA properties defined, like this:
>>>>
>>>> *<properties>*
>>>> *      <property name="openjpa.ConnectionFactoryMode" value="managed"
>>>> />*
>>>> *      <property name="openjpa.jdbc.SynchronizeMappings"
>>>> value="buildSchema(ForeignKeys=true)" />*
>>>> *      <property name="openjpa.jdbc.DBDictionary"
>>>> value="org.apache.openjpa.jdbc.sql.SQLServerDictionary" />*
>>>> *      <property name="openjpa.jdbc.UpdateManager"
>>>> value="operation-order" />*
>>>> *      <property name="openjpa.Log" value="DefaultLevel=INFO,
>>>> Tool=INFO" />*
>>>> *<!--      <property name="openjpa.Log" value="DefaultLevel=TRACE,
>>>> Tool=INFO" />-->*
>>>> *    </properties>*
>>>>
>>>> One idea is to enable TRACE logging to see what OpenJPA complains
>>>> about. Another one is that maybe the first property (the
>>>> ConnectionFactoryMode) must be set to "managed" for this to work. I'm not
>>>> sure but there is probably a reason why I always have that property defined.
>>>>
>>>> /Bengt
>>>>
>>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>>
>>>>> Hello,
>>>>>
>>>>> yes I find this comments very useful!
>>>>>
>>>>> karaf@root> ls | grep -B 4 javax.sql.DataSource
>>>>> org.apache.aries.jpa.container.context.PersistenceContextProvider
>>>>>
>>>>> weather-datasource (123) provides:
>>>>> ----------------------------------
>>>>> javax.sql.DataSource
>>>>> karaf@root> ls 123
>>>>>
>>>>> weather-datasource (123) provides:
>>>>> ----------------------------------
>>>>> objectClass = javax.sql.DataSource
>>>>> osgi.jndi.service.name = jdbc/mysqlds
>>>>> osgi.service.blueprint.compname = weatherDataSource
>>>>> service.id = 222
>>>>> ----
>>>>> objectClass = org.osgi.service.blueprint.container.BlueprintContainer
>>>>> osgi.blueprint.container.symbolicname = weather-datasource
>>>>> osgi.blueprint.container.version = 1.0.5.SNAPSHOT
>>>>> service.id = 223
>>>>>
>>>>> I guess the datasource service is published correctly.
>>>>>
>>>>> Thanks,
>>>>> borut
>>>>>
>>>>> Dne 26. april 2012 11:09 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>>
>>>>> Hello there,
>>>>>>
>>>>>> I guess you should check that your datasource has been published as a
>>>>>> service. I'm not the best Karaf guru but I would do something like this:
>>>>>>
>>>>>> Check what services provides datasources:
>>>>>>
>>>>>> *ls | grep -B 4 javax.sql.DataSource*
>>>>>>
>>>>>> This should identify what bundles provide datasources as services.
>>>>>> Assume that one of the bundles had the bundle id 78, you could then look
>>>>>> more closely at that bundles services with the following command:
>>>>>>
>>>>>> *ls 78*
>>>>>> *
>>>>>> *
>>>>>> You will now see the services provided by this bundle and also its
>>>>>> service properties. You should see a line similar to:
>>>>>>
>>>>>> *osgi.jndi.service.name = jdbc/mysqlds*
>>>>>>
>>>>>> Hope that helps,
>>>>>>
>>>>>> /Bengt
>>>>>>
>>>>>>
>>>>>>
>>>>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>>>>
>>>>>>> Hello,
>>>>>>>
>>>>>>> thanks Bengt for your input, I really appreciate you took the time!
>>>>>>>
>>>>>>> My work on this is somehow sporadic, but now I have managed to get
>>>>>>> the Camel route running in Karaf
>>>>>>>
>>>>>>> from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
>>>>>>>  .log("Getting weather from: " + sourceUrl)
>>>>>>> .to(sourceUrl)
>>>>>>>  .split()
>>>>>>> .tokenizeXML("metData")
>>>>>>>  .unmarshal(jaxbDataFormat)
>>>>>>>
>>>>>>> .to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
>>>>>>>
>>>>>>> with the exception of saving the data to the database which fails
>>>>>>> with:
>>>>>>>
>>>>>>> Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
>>>>>>> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
>>>>>>> DataSource class name must be specified in
>>>>>>> the ConnectionDriverName property. Available properties in
>>>>>>> configuration are
>>>>>>> "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>>>>>>>         at
>>>>>>> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>>>>>>>         at
>>>>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>>>>>>>         at
>>>>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>>>>>>>         at
>>>>>>> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>>>>>>>         at
>>>>>>> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
>>>>>>> ....
>>>>>>>
>>>>>>> My datasource bundle is deployed in OSGi (later the username and
>>>>>>> password will be configurable, that is - outside of the bundle)
>>>>>>>
>>>>>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>>>>>>>
>>>>>>>  <bean id="weatherDataSource"
>>>>>>> class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
>>>>>>> <property name="url"
>>>>>>>  value="jdbc:mysql://
>>>>>>> dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8<http://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>"
>>>>>>> />
>>>>>>>  <property name="user" value="myUsername" />
>>>>>>> <property name="password" value="myPassword" />
>>>>>>>  </bean>
>>>>>>>
>>>>>>> <service interface="javax.sql.DataSource" ref="weatherDataSource">
>>>>>>>  <service-properties>
>>>>>>> <entry key="osgi.jndi.service.name" value="jdbc/mysqlds" />
>>>>>>>  </service-properties>
>>>>>>> </service>
>>>>>>>  </blueprint>
>>>>>>>
>>>>>>> which is used by my model bundle's persistence.xml
>>>>>>>
>>>>>>> <persistence version="1.0" xmlns="
>>>>>>> http://java.sun.com/xml/ns/persistence" xmlns:xsi="
>>>>>>> http://www.w3.org/2001/XMLSchema-instance"
>>>>>>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>>>>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>>>>>>   <persistence-unit name="weather" transaction-type="JTA">
>>>>>>>
>>>>>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>>>>>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>>>>>>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>>>>>>  <class>my.company.weather.entities.WeatherCurrent</class>
>>>>>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>>>>>>  </persistence-unit>
>>>>>>> </persistence>
>>>>>>>
>>>>>>> I think the problem is that my model bundle is not seeing the
>>>>>>> datasource service. How do I confirm that or how should my model's
>>>>>>>  MANIFEST look like?
>>>>>>>
>>>>>>> Cheers,
>>>>>>> borut
>>>>>>>
>>>>>>>
>>>>>>> Dne 19. april 2012 20:35 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>>>>
>>>>>>> A few years back Hibernate was my choice. The past two years I have
>>>>>>>> moved to OpenJPA. The main reason is that OpenJPA works much better with
>>>>>>>> OSGi. I did try EclipseLink as well but had OSGi problems. This was a while
>>>>>>>> back and has probably been improved by now.
>>>>>>>>
>>>>>>>> Another reason why I prefer OpenJPA to Hibernate is that the Apache
>>>>>>>> community is so much better - much more open. I'm sure this is a matter of
>>>>>>>> taste but I would not go for Hibernate.
>>>>>>>>
>>>>>>>> That said, OpenJPA also has some classloading issues under OSGi. In
>>>>>>>> normal situations it works though. A final compelling reason to use OpenJPA
>>>>>>>> is that it is much more common choice when using Apache Karaf (I think).
>>>>>>>> It's normally easier to use different Apache projects together since
>>>>>>>> someone else has always done it before.
>>>>>>>>
>>>>>>>> What I don't like is the way JPA uses the persistence.xml. I tend
>>>>>>>> to go with the approach Christian recommended - to put the datasource in a
>>>>>>>> separate bundle. It can then easily be switched. In practice, though, it's
>>>>>>>> hard to actually change database type (not just url) without having to
>>>>>>>> affect the application.
>>>>>>>>
>>>>>>>> First, the JPA implementation is configured in persistence.xml. E g
>>>>>>>> that's where you specify database dialect for OpenJPA. Ideally this would
>>>>>>>> be separated from the persistence.xml and possible to configure (e g with
>>>>>>>> OSGi's config admin).
>>>>>>>>
>>>>>>>> Second, at least when using JPA annotations (which I do), your
>>>>>>>> source code becomes tailored for a certain database type. I often startup
>>>>>>>> with a simple Derby database for testing and then move  to SQLServer for
>>>>>>>> production. In that process I often have to change some annotations to make
>>>>>>>> it work in SQLServer.
>>>>>>>>
>>>>>>>> Overall I'm quite content with the OpenJPA+Aries+Karaf combo
>>>>>>>> though. I just wish that Aries could get their release process straightened
>>>>>>>> out soon.
>>>>>>>>
>>>>>>>> /Bengt
>>>>>>>>
>>>>>>>>
>>>>>>>> 2012/4/19 Borut Bolcina <bo...@gmail.com>
>>>>>>>>
>>>>>>>>> On 19. apr. 2012, at 16:11, Christian Schneider <
>>>>>>>>> chris@die-schneider.net> wrote:
>>>>>>>>>
>>>>>>>>> > I guess the suggested way is to not run hibernate :-) For me the
>>>>>>>>> fact that they do not create bundles says that jboss does not care about
>>>>>>>>> OSGi in hibernate. As they now have an OSGi server with JBoss 7 that may
>>>>>>>>> change soon though.
>>>>>>>>>
>>>>>>>>> I just looked at JBoss website and their support is not even in
>>>>>>>>> dipers. See https://issues.jboss.org/browse/JBOSGI-260.
>>>>>>>>>
>>>>>>>>> > I had some good experience with apache openjpa together with
>>>>>>>>> apache aries jpa. Together they solve the classloading problem where the
>>>>>>>>> jpa provider can not see the user classes. I have not built bigger
>>>>>>>>> applications with it though.
>>>>>>>>>
>>>>>>>>> I will try with OpenJPA, but would really like to hear other
>>>>>>>>> people's hibernate stories!
>>>>>>>>>
>>>>>>>>> >
>>>>>>>>> > There is also Eclipselink. With their affiliation to Eclipse
>>>>>>>>> they will surely have an eye on OSGi compatibility. The problem there was
>>>>>>>>> that they did not put their jas into the maven central repo.
>>>>>>>>> >
>>>>>>>>> > So all in all I am not sure what to recommend. Perhaps others
>>>>>>>>> already have experience with some jpa solution in bigger projects?
>>>>>>>>>
>>>>>>>>> Please share some stories to make my decision easier.
>>>>>>>>>
>>>>>>>>> Borut
>>>>>>>>>
>>>>>>>>> >
>>>>>>>>> > Christian
>>>>>>>>> >
>>>>>>>>> > Am 19.04.2012 15:56, schrieb Borut Bolčina:
>>>>>>>>> >> Thanks Christian,
>>>>>>>>> >>
>>>>>>>>> >> I understand now what you were suggesting. The database type
>>>>>>>>> (vendor) will be the same in all environments (mysql), but with different
>>>>>>>>> addresses, engine types, usernames and passwords, which brings another
>>>>>>>>> topic up - configuration (I will probably ask this in days to come).
>>>>>>>>> >>
>>>>>>>>> >> I will be separating datasources, it is just the case that I
>>>>>>>>> want a working solution and then smooth it out.
>>>>>>>>> >>
>>>>>>>>> >> For a begginer it is very hard to get a hibernate mysql combo
>>>>>>>>> to work (mine still does not). There are examples for persistence, but I
>>>>>>>>> had to read a lot until I found that Hibernate does not even has bundles,
>>>>>>>>> therefore tricks has to be performed.
>>>>>>>>> >>
>>>>>>>>> >> Is there "an official Karaf Hibernate Feature"? If not, what is
>>>>>>>>> the suggested way to run Hibernate in Karaf? I am planning to use Hibernate
>>>>>>>>> Search, Solr and Lucene by using Camel components, so I have lots of ground
>>>>>>>>> to cover.
>>>>>>>>> >>
>>>>>>>>> >> Cheers,
>>>>>>>>> >> borut
>>>>>>>>> >>
>>>>>>>>> >
>>>>>>>>> > --
>>>>>>>>> > Christian Schneider
>>>>>>>>> > http://www.liquid-reality.de
>>>>>>>>> >
>>>>>>>>> > Open Source Architect
>>>>>>>>> > Talend Application Integration Division http://www.talend.com
>>>>>>>>> >
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Re: Deploying data sources

Posted by Bengt Rodehav <be...@rodehav.com>.
OK - I didn't realize that you were using JPA 1.0. I've only used JPA 2.0.
What version of OpenJPA do you use then?

About the validator. Note that it is not enough to verify that the
validator works outside of OSGi since you cannot use an ordinary validator
implementation in OSGi - it will not be found. In the ServiceMix project
they provide an OSGi'ified version of Hibernate's reference implementation
that you can use in OSGi. The problem is that java's standard way of
finding resources does not work in OSGi.

What validator (and version) implementation do you use?

/Bengt

2012/4/26 Borut Bolcina <bo...@gmail.com>

> A minute later after sending the email below, I saw I was using jpa 1.0
> persistence.xml, god knows where I copied/pasted the template from.
>
> I have validator installed, so this is not a problem. I need it as I am
> using some annotations on my model pojo to validate incoming values from
> xml input source.
>
> Right now I am clueless.
>
> Borut
>
> Sent from my iPad
>
> On 26. apr. 2012, at 15:06, Bengt Rodehav <be...@rodehav.com> wrote:
>
> Hello again,
>
> The Warning is know at OpenJPA. I think it is reported in JIRA. It turns
> up now and then but noone seems to know exactly what triggers it. I've had
> it too but it doesn't seem to be a problem.
>
> About validation - I should have though of that...
>
> I also have this line in my persistence.xml:
>
> *    <validation-mode>NONE</validation-mode>*
>
> This tells OpenJPA not to validate. Otherwise you must also deploy a
> validation provider. I've used the reference implementation from Hibernate
> for this but normally I turn it off with the above line.
>
> /Bengt
>
> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>
>> I modified the model bundle to include properties section in
>> persistence.xml
>>
>> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>
>> <persistence-unit name="weather" transaction-type="JTA">
>>
>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>  <class>si.najdi.weather.entities.WeatherCurrent</class>
>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>
>> <properties>
>> <property name="openjpa.ConnectionFactoryMode" value="managed" />
>>  <property name="openjpa.jdbc.DBDictionary"
>> value="mysql(TableType=innodb)" />
>>  <property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO" />
>> </properties>
>>
>> </persistence-unit>
>> </persistence>
>>
>> and reinstalled all my bundles, but it makes no difference.
>>
>> I notices this in my console when the route is started:
>>
>> 20  WARN   [Blueprint Extender: 2] openjpa.Runtime - The configuration
>> property named "openjpa.Id" was not recognized and will be ignored,
>> although the name closely matches a valid property called "openjpa.Id".
>>
>> With the TRACE level enabled, I see:
>>
>> karaf@root> osgi:install -s
>> mvn:com.mycompany/weather-model/1.0.5-SNAPSHOT
>> 35  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following
>> properties from "?" into configuration:
>> {openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
>> openjpa.ConnectionFactoryMode=managed,
>> javax.persistence.validation.mode=AUTO,
>> javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
>> openjpa.TransactionMode=managed,
>> openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
>> openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac,
>> javax.persistence.sharedCache.mode=UNSPECIFIED,
>> openjpa.Log=DefaultLevel=TRACE, Tool=INFO,
>> openjpa.jdbc.DBDictionary=mysql(TableType=innodb), PersistenceVersion=1.0,
>> openjpa.Id=weather}
>> 58  weather  TRACE  [Thread-10] openjpa.Runtime - No cache marshaller
>> found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
>> 104  weather  TRACE  [Thread-10] openjpa.MetaData - Scanning resource
>> "META-INF/orm.xml" for persistent types.
>> 105  weather  TRACE  [Thread-10] openjpa.MetaData - The persistent unit
>> root url is "null"
>> 105  weather  TRACE  [Thread-10] openjpa.MetaData -
>> parsePersistentTypeNames() found
>> [com.mycompany.weather.entities.WeatherCurrent].
>> 106  weather  TRACE  [Thread-10] openjpa.MetaData - Found 1 classes with
>> metadata in 48 milliseconds.
>> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following
>> properties from "?" into configuration: {openjpa.BrokerFactory=jdbc,
>> javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
>> javax.persistence.sharedCache.mode=UNSPECIFIED, PersistenceVersion=1.0,
>> openjpa.jdbc.DBDictionary=mysql(TableType=innodb),
>> openjpa.Log=DefaultLevel=TRACE, Tool=INFO, openjpa.Id=weather,
>> openjpa.ConnectionFactoryMode=managed,
>> openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
>> javax.persistence.validation.mode=AUTO, openjpa.TransactionMode=managed,
>> openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
>> openjpa.BrokerImpl=non-finalizing,
>> openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac
>> }
>> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Not creating a
>> ValidatorImpl because this app is using the JPA 1.0 Spec
>> 1  weather  TRACE  [Thread-10] openjpa.Runtime -
>> org.apache.openjpa.persistence.PersistenceProviderImpl@1ad69f1 creating
>> container org.apache.openjpa.persistence.EntityManagerFactoryImpl@6888bfor PU weather.
>> Bundle ID: 137
>>
>>
>> Certanly this look strange:
>> Not creating a ValidatorImpl because this app is using the JPA 1.0 Spec
>>
>> Digging...
>>
>>
>>
>>
>> Dne 26. april 2012 12:57 je Bengt Rodehav <be...@rodehav.com> napisal/-a:
>>
>> Then I guess OpenJPA can't find or does not try to find your datasource
>>> service. Looking at my different persistence.xml's I usually have a few
>>> OpenJPA properties defined, like this:
>>>
>>> *<properties>*
>>> *      <property name="openjpa.ConnectionFactoryMode" value="managed" />
>>> *
>>> *      <property name="openjpa.jdbc.SynchronizeMappings"
>>> value="buildSchema(ForeignKeys=true)" />*
>>> *      <property name="openjpa.jdbc.DBDictionary"
>>> value="org.apache.openjpa.jdbc.sql.SQLServerDictionary" />*
>>> *      <property name="openjpa.jdbc.UpdateManager"
>>> value="operation-order" />*
>>> *      <property name="openjpa.Log" value="DefaultLevel=INFO,
>>> Tool=INFO" />*
>>> *<!--      <property name="openjpa.Log" value="DefaultLevel=TRACE,
>>> Tool=INFO" />-->*
>>> *    </properties>*
>>>
>>> One idea is to enable TRACE logging to see what OpenJPA complains about.
>>> Another one is that maybe the first property (the ConnectionFactoryMode)
>>> must be set to "managed" for this to work. I'm not sure but there is
>>> probably a reason why I always have that property defined.
>>>
>>> /Bengt
>>>
>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>
>>>> Hello,
>>>>
>>>> yes I find this comments very useful!
>>>>
>>>> karaf@root> ls | grep -B 4 javax.sql.DataSource
>>>> org.apache.aries.jpa.container.context.PersistenceContextProvider
>>>>
>>>> weather-datasource (123) provides:
>>>> ----------------------------------
>>>> javax.sql.DataSource
>>>> karaf@root> ls 123
>>>>
>>>> weather-datasource (123) provides:
>>>> ----------------------------------
>>>> objectClass = javax.sql.DataSource
>>>> osgi.jndi.service.name = jdbc/mysqlds
>>>> osgi.service.blueprint.compname = weatherDataSource
>>>> service.id = 222
>>>> ----
>>>> objectClass = org.osgi.service.blueprint.container.BlueprintContainer
>>>> osgi.blueprint.container.symbolicname = weather-datasource
>>>> osgi.blueprint.container.version = 1.0.5.SNAPSHOT
>>>> service.id = 223
>>>>
>>>> I guess the datasource service is published correctly.
>>>>
>>>> Thanks,
>>>> borut
>>>>
>>>> Dne 26. april 2012 11:09 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>
>>>> Hello there,
>>>>>
>>>>> I guess you should check that your datasource has been published as a
>>>>> service. I'm not the best Karaf guru but I would do something like this:
>>>>>
>>>>> Check what services provides datasources:
>>>>>
>>>>> *ls | grep -B 4 javax.sql.DataSource*
>>>>>
>>>>> This should identify what bundles provide datasources as services.
>>>>> Assume that one of the bundles had the bundle id 78, you could then look
>>>>> more closely at that bundles services with the following command:
>>>>>
>>>>> *ls 78*
>>>>> *
>>>>> *
>>>>> You will now see the services provided by this bundle and also its
>>>>> service properties. You should see a line similar to:
>>>>>
>>>>> *osgi.jndi.service.name = jdbc/mysqlds*
>>>>>
>>>>> Hope that helps,
>>>>>
>>>>> /Bengt
>>>>>
>>>>>
>>>>>
>>>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> thanks Bengt for your input, I really appreciate you took the time!
>>>>>>
>>>>>> My work on this is somehow sporadic, but now I have managed to get
>>>>>> the Camel route running in Karaf
>>>>>>
>>>>>> from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
>>>>>>  .log("Getting weather from: " + sourceUrl)
>>>>>> .to(sourceUrl)
>>>>>>  .split()
>>>>>> .tokenizeXML("metData")
>>>>>>  .unmarshal(jaxbDataFormat)
>>>>>>
>>>>>> .to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
>>>>>>
>>>>>> with the exception of saving the data to the database which fails
>>>>>> with:
>>>>>>
>>>>>> Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
>>>>>> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
>>>>>> DataSource class name must be specified in
>>>>>> the ConnectionDriverName property. Available properties in
>>>>>> configuration are
>>>>>> "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>>>>>>         at
>>>>>> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>>>>>>         at
>>>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>>>>>>         at
>>>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>>>>>>         at
>>>>>> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>>>>>>         at
>>>>>> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
>>>>>> ....
>>>>>>
>>>>>> My datasource bundle is deployed in OSGi (later the username and
>>>>>> password will be configurable, that is - outside of the bundle)
>>>>>>
>>>>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>>>>>>
>>>>>>  <bean id="weatherDataSource"
>>>>>> class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
>>>>>> <property name="url"
>>>>>>  value="jdbc:mysql://
>>>>>> dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8<http://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>"
>>>>>> />
>>>>>>  <property name="user" value="myUsername" />
>>>>>> <property name="password" value="myPassword" />
>>>>>>  </bean>
>>>>>>
>>>>>> <service interface="javax.sql.DataSource" ref="weatherDataSource">
>>>>>>  <service-properties>
>>>>>> <entry key="osgi.jndi.service.name" value="jdbc/mysqlds" />
>>>>>>  </service-properties>
>>>>>> </service>
>>>>>>  </blueprint>
>>>>>>
>>>>>> which is used by my model bundle's persistence.xml
>>>>>>
>>>>>> <persistence version="1.0" xmlns="
>>>>>> http://java.sun.com/xml/ns/persistence" xmlns:xsi="
>>>>>> http://www.w3.org/2001/XMLSchema-instance"
>>>>>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>>>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>>>>>   <persistence-unit name="weather" transaction-type="JTA">
>>>>>>
>>>>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>>>>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>>>>>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>>>>>  <class>my.company.weather.entities.WeatherCurrent</class>
>>>>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>>>>>  </persistence-unit>
>>>>>> </persistence>
>>>>>>
>>>>>> I think the problem is that my model bundle is not seeing the
>>>>>> datasource service. How do I confirm that or how should my model's
>>>>>>  MANIFEST look like?
>>>>>>
>>>>>> Cheers,
>>>>>> borut
>>>>>>
>>>>>>
>>>>>> Dne 19. april 2012 20:35 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>>>
>>>>>> A few years back Hibernate was my choice. The past two years I have
>>>>>>> moved to OpenJPA. The main reason is that OpenJPA works much better with
>>>>>>> OSGi. I did try EclipseLink as well but had OSGi problems. This was a while
>>>>>>> back and has probably been improved by now.
>>>>>>>
>>>>>>> Another reason why I prefer OpenJPA to Hibernate is that the Apache
>>>>>>> community is so much better - much more open. I'm sure this is a matter of
>>>>>>> taste but I would not go for Hibernate.
>>>>>>>
>>>>>>> That said, OpenJPA also has some classloading issues under OSGi. In
>>>>>>> normal situations it works though. A final compelling reason to use OpenJPA
>>>>>>> is that it is much more common choice when using Apache Karaf (I think).
>>>>>>> It's normally easier to use different Apache projects together since
>>>>>>> someone else has always done it before.
>>>>>>>
>>>>>>> What I don't like is the way JPA uses the persistence.xml. I tend to
>>>>>>> go with the approach Christian recommended - to put the datasource in a
>>>>>>> separate bundle. It can then easily be switched. In practice, though, it's
>>>>>>> hard to actually change database type (not just url) without having to
>>>>>>> affect the application.
>>>>>>>
>>>>>>> First, the JPA implementation is configured in persistence.xml. E g
>>>>>>> that's where you specify database dialect for OpenJPA. Ideally this would
>>>>>>> be separated from the persistence.xml and possible to configure (e g with
>>>>>>> OSGi's config admin).
>>>>>>>
>>>>>>> Second, at least when using JPA annotations (which I do), your
>>>>>>> source code becomes tailored for a certain database type. I often startup
>>>>>>> with a simple Derby database for testing and then move  to SQLServer for
>>>>>>> production. In that process I often have to change some annotations to make
>>>>>>> it work in SQLServer.
>>>>>>>
>>>>>>> Overall I'm quite content with the OpenJPA+Aries+Karaf combo though.
>>>>>>> I just wish that Aries could get their release process straightened out
>>>>>>> soon.
>>>>>>>
>>>>>>> /Bengt
>>>>>>>
>>>>>>>
>>>>>>> 2012/4/19 Borut Bolcina <bo...@gmail.com>
>>>>>>>
>>>>>>>> On 19. apr. 2012, at 16:11, Christian Schneider <
>>>>>>>> chris@die-schneider.net> wrote:
>>>>>>>>
>>>>>>>> > I guess the suggested way is to not run hibernate :-) For me the
>>>>>>>> fact that they do not create bundles says that jboss does not care about
>>>>>>>> OSGi in hibernate. As they now have an OSGi server with JBoss 7 that may
>>>>>>>> change soon though.
>>>>>>>>
>>>>>>>> I just looked at JBoss website and their support is not even in
>>>>>>>> dipers. See https://issues.jboss.org/browse/JBOSGI-260.
>>>>>>>>
>>>>>>>> > I had some good experience with apache openjpa together with
>>>>>>>> apache aries jpa. Together they solve the classloading problem where the
>>>>>>>> jpa provider can not see the user classes. I have not built bigger
>>>>>>>> applications with it though.
>>>>>>>>
>>>>>>>> I will try with OpenJPA, but would really like to hear other
>>>>>>>> people's hibernate stories!
>>>>>>>>
>>>>>>>> >
>>>>>>>> > There is also Eclipselink. With their affiliation to Eclipse they
>>>>>>>> will surely have an eye on OSGi compatibility. The problem there was that
>>>>>>>> they did not put their jas into the maven central repo.
>>>>>>>> >
>>>>>>>> > So all in all I am not sure what to recommend. Perhaps others
>>>>>>>> already have experience with some jpa solution in bigger projects?
>>>>>>>>
>>>>>>>> Please share some stories to make my decision easier.
>>>>>>>>
>>>>>>>> Borut
>>>>>>>>
>>>>>>>> >
>>>>>>>> > Christian
>>>>>>>> >
>>>>>>>> > Am 19.04.2012 15:56, schrieb Borut Bolčina:
>>>>>>>> >> Thanks Christian,
>>>>>>>> >>
>>>>>>>> >> I understand now what you were suggesting. The database type
>>>>>>>> (vendor) will be the same in all environments (mysql), but with different
>>>>>>>> addresses, engine types, usernames and passwords, which brings another
>>>>>>>> topic up - configuration (I will probably ask this in days to come).
>>>>>>>> >>
>>>>>>>> >> I will be separating datasources, it is just the case that I
>>>>>>>> want a working solution and then smooth it out.
>>>>>>>> >>
>>>>>>>> >> For a begginer it is very hard to get a hibernate mysql combo to
>>>>>>>> work (mine still does not). There are examples for persistence, but I had
>>>>>>>> to read a lot until I found that Hibernate does not even has bundles,
>>>>>>>> therefore tricks has to be performed.
>>>>>>>> >>
>>>>>>>> >> Is there "an official Karaf Hibernate Feature"? If not, what is
>>>>>>>> the suggested way to run Hibernate in Karaf? I am planning to use Hibernate
>>>>>>>> Search, Solr and Lucene by using Camel components, so I have lots of ground
>>>>>>>> to cover.
>>>>>>>> >>
>>>>>>>> >> Cheers,
>>>>>>>> >> borut
>>>>>>>> >>
>>>>>>>> >
>>>>>>>> > --
>>>>>>>> > Christian Schneider
>>>>>>>> > http://www.liquid-reality.de
>>>>>>>> >
>>>>>>>> > Open Source Architect
>>>>>>>> > Talend Application Integration Division http://www.talend.com
>>>>>>>> >
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Re: Deploying data sources

Posted by Borut Bolcina <bo...@gmail.com>.
A minute later after sending the email below, I saw I was using jpa 1.0 persistence.xml, god knows where I copied/pasted the template from. 

I have validator installed, so this is not a problem. I need it as I am using some annotations on my model pojo to validate incoming values from xml input source.

Right now I am clueless.

Borut

Sent from my iPad

On 26. apr. 2012, at 15:06, Bengt Rodehav <be...@rodehav.com> wrote:

> Hello again,
> 
> The Warning is know at OpenJPA. I think it is reported in JIRA. It turns up now and then but noone seems to know exactly what triggers it. I've had it too but it doesn't seem to be a problem.
> 
> About validation - I should have though of that...
> 
> I also have this line in my persistence.xml:
> 
>     <validation-mode>NONE</validation-mode>
> 
> This tells OpenJPA not to validate. Otherwise you must also deploy a validation provider. I've used the reference implementation from Hibernate for this but normally I turn it off with the above line.
> 
> /Bengt
> 
> 2012/4/26 Borut Bolčina <bo...@gmail.com>
> I modified the model bundle to include properties section in persistence.xml
> 
> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
> 
> 	<persistence-unit name="weather" transaction-type="JTA">
> 		<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> 		<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
> 		<class>si.najdi.weather.entities.WeatherCurrent</class>
> 		<exclude-unlisted-classes>true</exclude-unlisted-classes>
> 
> 		<properties>
> 			<property name="openjpa.ConnectionFactoryMode" value="managed" />
> 			<property name="openjpa.jdbc.DBDictionary" value="mysql(TableType=innodb)" />
> 			<property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO" />
> 		</properties>
> 
> 	</persistence-unit>
> </persistence>
> 
> and reinstalled all my bundles, but it makes no difference.
> 
> I notices this in my console when the route is started:
> 
> 20  WARN   [Blueprint Extender: 2] openjpa.Runtime - The configuration property named "openjpa.Id" was not recognized and will be ignored, although the name closely matches a valid property called "openjpa.Id".
> 
> With the TRACE level enabled, I see:
> 
> karaf@root> osgi:install -s mvn:com.mycompany/weather-model/1.0.5-SNAPSHOT
> 35  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following properties from "?" into configuration: {openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b, openjpa.ConnectionFactoryMode=managed, javax.persistence.validation.mode=AUTO, javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl, openjpa.TransactionMode=managed, openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent), openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac, javax.persistence.sharedCache.mode=UNSPECIFIED, openjpa.Log=DefaultLevel=TRACE, Tool=INFO, openjpa.jdbc.DBDictionary=mysql(TableType=innodb), PersistenceVersion=1.0, openjpa.Id=weather}
> 58  weather  TRACE  [Thread-10] openjpa.Runtime - No cache marshaller found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
> 104  weather  TRACE  [Thread-10] openjpa.MetaData - Scanning resource "META-INF/orm.xml" for persistent types.
> 105  weather  TRACE  [Thread-10] openjpa.MetaData - The persistent unit root url is "null"
> 105  weather  TRACE  [Thread-10] openjpa.MetaData - parsePersistentTypeNames() found [com.mycompany.weather.entities.WeatherCurrent].
> 106  weather  TRACE  [Thread-10] openjpa.MetaData - Found 1 classes with metadata in 48 milliseconds.
> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following properties from "?" into configuration: {openjpa.BrokerFactory=jdbc, javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl, javax.persistence.sharedCache.mode=UNSPECIFIED, PersistenceVersion=1.0, openjpa.jdbc.DBDictionary=mysql(TableType=innodb), openjpa.Log=DefaultLevel=TRACE, Tool=INFO, openjpa.Id=weather, openjpa.ConnectionFactoryMode=managed, openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b, javax.persistence.validation.mode=AUTO, openjpa.TransactionMode=managed, openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent), openjpa.BrokerImpl=non-finalizing, openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac}
> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Not creating a ValidatorImpl because this app is using the JPA 1.0 Spec
> 1  weather  TRACE  [Thread-10] openjpa.Runtime - org.apache.openjpa.persistence.PersistenceProviderImpl@1ad69f1 creating container org.apache.openjpa.persistence.EntityManagerFactoryImpl@6888b for PU weather.
> Bundle ID: 137
> 
> 
> Certanly this look strange:
> Not creating a ValidatorImpl because this app is using the JPA 1.0 Spec
> 
> Digging...
> 
> 
> 
> 
> Dne 26. april 2012 12:57 je Bengt Rodehav <be...@rodehav.com> napisal/-a:
> 
> Then I guess OpenJPA can't find or does not try to find your datasource service. Looking at my different persistence.xml's I usually have a few OpenJPA properties defined, like this:
> 
> <properties>
>       <property name="openjpa.ConnectionFactoryMode" value="managed" />
>       <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />
>       <property name="openjpa.jdbc.DBDictionary" value="org.apache.openjpa.jdbc.sql.SQLServerDictionary" />
>       <property name="openjpa.jdbc.UpdateManager" value="operation-order" />
>       <property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO" />
> <!--      <property name="openjpa.Log" value="DefaultLevel=TRACE, Tool=INFO" />-->
>     </properties>
> 
> One idea is to enable TRACE logging to see what OpenJPA complains about. Another one is that maybe the first property (the ConnectionFactoryMode) must be set to "managed" for this to work. I'm not sure but there is probably a reason why I always have that property defined.
> 
> /Bengt
> 
> 2012/4/26 Borut Bolčina <bo...@gmail.com>
> Hello,
> 
> yes I find this comments very useful!
> 
> karaf@root> ls | grep -B 4 javax.sql.DataSource
> org.apache.aries.jpa.container.context.PersistenceContextProvider
> 
> weather-datasource (123) provides:
> ----------------------------------
> javax.sql.DataSource
> karaf@root> ls 123
> 
> weather-datasource (123) provides:
> ----------------------------------
> objectClass = javax.sql.DataSource
> osgi.jndi.service.name = jdbc/mysqlds
> osgi.service.blueprint.compname = weatherDataSource
> service.id = 222
> ----
> objectClass = org.osgi.service.blueprint.container.BlueprintContainer
> osgi.blueprint.container.symbolicname = weather-datasource
> osgi.blueprint.container.version = 1.0.5.SNAPSHOT
> service.id = 223
> 
> I guess the datasource service is published correctly.
> 
> Thanks,
> borut
> 
> Dne 26. april 2012 11:09 je Bengt Rodehav <be...@rodehav.com> napisal/-a:
> 
> Hello there,
> 
> I guess you should check that your datasource has been published as a service. I'm not the best Karaf guru but I would do something like this:
> 
> Check what services provides datasources:
> 
> ls | grep -B 4 javax.sql.DataSource
> 
> This should identify what bundles provide datasources as services. Assume that one of the bundles had the bundle id 78, you could then look more closely at that bundles services with the following command:
> 
> ls 78
> 
> You will now see the services provided by this bundle and also its service properties. You should see a line similar to:
> 
> osgi.jndi.service.name = jdbc/mysqlds
> 
> Hope that helps,
> 
> /Bengt
> 
> 
> 
> 2012/4/26 Borut Bolčina <bo...@gmail.com>
> Hello,
> 
> thanks Bengt for your input, I really appreciate you took the time!
> 
> My work on this is somehow sporadic, but now I have managed to get the Camel route running in Karaf
> 
> 		from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
> 			.log("Getting weather from: " + sourceUrl)
> 			.to(sourceUrl)
> 			.split()
> 			.tokenizeXML("metData")
> 			.unmarshal(jaxbDataFormat)
> 			.to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
> 
> with the exception of saving the data to the database which fails with:
> 
> Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in
> the ConnectionDriverName property. Available properties in configuration are "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>         at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>         at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>         at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>         at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>         at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
> ....
> 
> My datasource bundle is deployed in OSGi (later the username and password will be configurable, that is - outside of the bundle)
> 
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
> 
> 	<bean id="weatherDataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
> 		<property name="url"
> 			value="jdbc:mysql://dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8" />
> 		<property name="user" value="myUsername" />
> 		<property name="password" value="myPassword" />
> 	</bean>
> 
> 	<service interface="javax.sql.DataSource" ref="weatherDataSource">
> 		<service-properties>
> 			<entry key="osgi.jndi.service.name" value="jdbc/mysqlds" />
> 		</service-properties>
> 	</service>
> 	
> </blueprint>
> 
> which is used by my model bundle's persistence.xml
> 
> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> 	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
> 	
> 	<persistence-unit name="weather" transaction-type="JTA">
> 		<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> 		<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
> 		<class>my.company.weather.entities.WeatherCurrent</class>
> 		<exclude-unlisted-classes>true</exclude-unlisted-classes>
> 	</persistence-unit>
> </persistence>
> 
> I think the problem is that my model bundle is not seeing the datasource service. How do I confirm that or how should my model's  MANIFEST look like?
> 
> Cheers,
> borut
> 
> 
> Dne 19. april 2012 20:35 je Bengt Rodehav <be...@rodehav.com> napisal/-a:
> 
> A few years back Hibernate was my choice. The past two years I have moved to OpenJPA. The main reason is that OpenJPA works much better with OSGi. I did try EclipseLink as well but had OSGi problems. This was a while back and has probably been improved by now.
> 
> Another reason why I prefer OpenJPA to Hibernate is that the Apache community is so much better - much more open. I'm sure this is a matter of taste but I would not go for Hibernate.
> 
> That said, OpenJPA also has some classloading issues under OSGi. In normal situations it works though. A final compelling reason to use OpenJPA is that it is much more common choice when using Apache Karaf (I think). It's normally easier to use different Apache projects together since someone else has always done it before.
> 
> What I don't like is the way JPA uses the persistence.xml. I tend to go with the approach Christian recommended - to put the datasource in a separate bundle. It can then easily be switched. In practice, though, it's hard to actually change database type (not just url) without having to affect the application.
> 
> First, the JPA implementation is configured in persistence.xml. E g that's where you specify database dialect for OpenJPA. Ideally this would be separated from the persistence.xml and possible to configure (e g with OSGi's config admin).
> 
> Second, at least when using JPA annotations (which I do), your source code becomes tailored for a certain database type. I often startup with a simple Derby database for testing and then move  to SQLServer for production. In that process I often have to change some annotations to make it work in SQLServer.
> 
> Overall I'm quite content with the OpenJPA+Aries+Karaf combo though. I just wish that Aries could get their release process straightened out soon.
> 
> /Bengt
> 
> 
> 2012/4/19 Borut Bolcina <bo...@gmail.com>
> On 19. apr. 2012, at 16:11, Christian Schneider <ch...@die-schneider.net> wrote:
> 
> > I guess the suggested way is to not run hibernate :-) For me the fact that they do not create bundles says that jboss does not care about OSGi in hibernate. As they now have an OSGi server with JBoss 7 that may change soon though.
> 
> I just looked at JBoss website and their support is not even in dipers. See https://issues.jboss.org/browse/JBOSGI-260.
> 
> > I had some good experience with apache openjpa together with apache aries jpa. Together they solve the classloading problem where the jpa provider can not see the user classes. I have not built bigger applications with it though.
> 
> I will try with OpenJPA, but would really like to hear other people's hibernate stories!
> 
> >
> > There is also Eclipselink. With their affiliation to Eclipse they will surely have an eye on OSGi compatibility. The problem there was that they did not put their jas into the maven central repo.
> >
> > So all in all I am not sure what to recommend. Perhaps others already have experience with some jpa solution in bigger projects?
> 
> Please share some stories to make my decision easier.
> 
> Borut
> 
> >
> > Christian
> >
> > Am 19.04.2012 15:56, schrieb Borut Bolčina:
> >> Thanks Christian,
> >>
> >> I understand now what you were suggesting. The database type (vendor) will be the same in all environments (mysql), but with different addresses, engine types, usernames and passwords, which brings another topic up - configuration (I will probably ask this in days to come).
> >>
> >> I will be separating datasources, it is just the case that I want a working solution and then smooth it out.
> >>
> >> For a begginer it is very hard to get a hibernate mysql combo to work (mine still does not). There are examples for persistence, but I had to read a lot until I found that Hibernate does not even has bundles, therefore tricks has to be performed.
> >>
> >> Is there "an official Karaf Hibernate Feature"? If not, what is the suggested way to run Hibernate in Karaf? I am planning to use Hibernate Search, Solr and Lucene by using Camel components, so I have lots of ground to cover.
> >>
> >> Cheers,
> >> borut
> >>
> >
> > --
> > Christian Schneider
> > http://www.liquid-reality.de
> >
> > Open Source Architect
> > Talend Application Integration Division http://www.talend.com
> >
> 
> 
> 
> 
> 
> 
> 

Re: Deploying data sources

Posted by Bengt Rodehav <be...@rodehav.com>.
Hello again,

The Warning is know at OpenJPA. I think it is reported in JIRA. It turns up
now and then but noone seems to know exactly what triggers it. I've had it
too but it doesn't seem to be a problem.

About validation - I should have though of that...

I also have this line in my persistence.xml:

*    <validation-mode>NONE</validation-mode>*

This tells OpenJPA not to validate. Otherwise you must also deploy a
validation provider. I've used the reference implementation from Hibernate
for this but normally I turn it off with the above line.

/Bengt

2012/4/26 Borut Bolčina <bo...@gmail.com>

> I modified the model bundle to include properties section in
> persistence.xml
>
> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>
> <persistence-unit name="weather" transaction-type="JTA">
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name
> =jdbc/mysqlds)</jta-data-source>
>  <class>si.najdi.weather.entities.WeatherCurrent</class>
> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>
> <properties>
> <property name="openjpa.ConnectionFactoryMode" value="managed" />
>  <property name="openjpa.jdbc.DBDictionary"
> value="mysql(TableType=innodb)" />
>  <property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO" />
> </properties>
>
> </persistence-unit>
> </persistence>
>
> and reinstalled all my bundles, but it makes no difference.
>
> I notices this in my console when the route is started:
>
> 20  WARN   [Blueprint Extender: 2] openjpa.Runtime - The configuration
> property named "openjpa.Id" was not recognized and will be ignored,
> although the name closely matches a valid property called "openjpa.Id".
>
> With the TRACE level enabled, I see:
>
> karaf@root> osgi:install -s mvn:com.mycompany/weather-model/1.0.5-SNAPSHOT
> 35  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following
> properties from "?" into configuration:
> {openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
> openjpa.ConnectionFactoryMode=managed,
> javax.persistence.validation.mode=AUTO,
> javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
> openjpa.TransactionMode=managed,
> openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
> openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac,
> javax.persistence.sharedCache.mode=UNSPECIFIED,
> openjpa.Log=DefaultLevel=TRACE, Tool=INFO,
> openjpa.jdbc.DBDictionary=mysql(TableType=innodb), PersistenceVersion=1.0,
> openjpa.Id=weather}
> 58  weather  TRACE  [Thread-10] openjpa.Runtime - No cache marshaller
> found for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
> 104  weather  TRACE  [Thread-10] openjpa.MetaData - Scanning resource
> "META-INF/orm.xml" for persistent types.
> 105  weather  TRACE  [Thread-10] openjpa.MetaData - The persistent unit
> root url is "null"
> 105  weather  TRACE  [Thread-10] openjpa.MetaData -
> parsePersistentTypeNames() found
> [com.mycompany.weather.entities.WeatherCurrent].
> 106  weather  TRACE  [Thread-10] openjpa.MetaData - Found 1 classes with
> metadata in 48 milliseconds.
> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following
> properties from "?" into configuration: {openjpa.BrokerFactory=jdbc,
> javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
> javax.persistence.sharedCache.mode=UNSPECIFIED, PersistenceVersion=1.0,
> openjpa.jdbc.DBDictionary=mysql(TableType=innodb),
> openjpa.Log=DefaultLevel=TRACE, Tool=INFO, openjpa.Id=weather,
> openjpa.ConnectionFactoryMode=managed,
> openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
> javax.persistence.validation.mode=AUTO, openjpa.TransactionMode=managed,
> openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
> openjpa.BrokerImpl=non-finalizing,
> openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac
> }
> 1  weather  TRACE  [Thread-10] openjpa.Runtime - Not creating a
> ValidatorImpl because this app is using the JPA 1.0 Spec
> 1  weather  TRACE  [Thread-10] openjpa.Runtime -
> org.apache.openjpa.persistence.PersistenceProviderImpl@1ad69f1 creating
> container org.apache.openjpa.persistence.EntityManagerFactoryImpl@6888bfor PU weather.
> Bundle ID: 137
>
>
> Certanly this look strange:
> Not creating a ValidatorImpl because this app is using the JPA 1.0 Spec
>
> Digging...
>
>
>
>
> Dne 26. april 2012 12:57 je Bengt Rodehav <be...@rodehav.com> napisal/-a:
>
> Then I guess OpenJPA can't find or does not try to find your datasource
>> service. Looking at my different persistence.xml's I usually have a few
>> OpenJPA properties defined, like this:
>>
>> *<properties>*
>> *      <property name="openjpa.ConnectionFactoryMode" value="managed" />*
>> *      <property name="openjpa.jdbc.SynchronizeMappings"
>> value="buildSchema(ForeignKeys=true)" />*
>> *      <property name="openjpa.jdbc.DBDictionary"
>> value="org.apache.openjpa.jdbc.sql.SQLServerDictionary" />*
>> *      <property name="openjpa.jdbc.UpdateManager"
>> value="operation-order" />*
>> *      <property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO"
>> />*
>> *<!--      <property name="openjpa.Log" value="DefaultLevel=TRACE,
>> Tool=INFO" />-->*
>> *    </properties>*
>>
>> One idea is to enable TRACE logging to see what OpenJPA complains about.
>> Another one is that maybe the first property (the ConnectionFactoryMode)
>> must be set to "managed" for this to work. I'm not sure but there is
>> probably a reason why I always have that property defined.
>>
>> /Bengt
>>
>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>
>>> Hello,
>>>
>>> yes I find this comments very useful!
>>>
>>> karaf@root> ls | grep -B 4 javax.sql.DataSource
>>> org.apache.aries.jpa.container.context.PersistenceContextProvider
>>>
>>> weather-datasource (123) provides:
>>> ----------------------------------
>>> javax.sql.DataSource
>>> karaf@root> ls 123
>>>
>>> weather-datasource (123) provides:
>>> ----------------------------------
>>> objectClass = javax.sql.DataSource
>>> osgi.jndi.service.name = jdbc/mysqlds
>>> osgi.service.blueprint.compname = weatherDataSource
>>> service.id = 222
>>> ----
>>> objectClass = org.osgi.service.blueprint.container.BlueprintContainer
>>> osgi.blueprint.container.symbolicname = weather-datasource
>>> osgi.blueprint.container.version = 1.0.5.SNAPSHOT
>>> service.id = 223
>>>
>>> I guess the datasource service is published correctly.
>>>
>>> Thanks,
>>> borut
>>>
>>> Dne 26. april 2012 11:09 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>
>>> Hello there,
>>>>
>>>> I guess you should check that your datasource has been published as a
>>>> service. I'm not the best Karaf guru but I would do something like this:
>>>>
>>>> Check what services provides datasources:
>>>>
>>>> *ls | grep -B 4 javax.sql.DataSource*
>>>>
>>>> This should identify what bundles provide datasources as services.
>>>> Assume that one of the bundles had the bundle id 78, you could then look
>>>> more closely at that bundles services with the following command:
>>>>
>>>> *ls 78*
>>>> *
>>>> *
>>>> You will now see the services provided by this bundle and also its
>>>> service properties. You should see a line similar to:
>>>>
>>>> *osgi.jndi.service.name = jdbc/mysqlds*
>>>>
>>>> Hope that helps,
>>>>
>>>> /Bengt
>>>>
>>>>
>>>>
>>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>>
>>>>> Hello,
>>>>>
>>>>> thanks Bengt for your input, I really appreciate you took the time!
>>>>>
>>>>> My work on this is somehow sporadic, but now I have managed to get the
>>>>> Camel route running in Karaf
>>>>>
>>>>> from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
>>>>>  .log("Getting weather from: " + sourceUrl)
>>>>> .to(sourceUrl)
>>>>>  .split()
>>>>> .tokenizeXML("metData")
>>>>>  .unmarshal(jaxbDataFormat)
>>>>>
>>>>> .to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
>>>>>
>>>>> with the exception of saving the data to the database which fails with:
>>>>>
>>>>> Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
>>>>> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
>>>>> DataSource class name must be specified in
>>>>> the ConnectionDriverName property. Available properties in
>>>>> configuration are
>>>>> "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>>>>>         at
>>>>> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>>>>>         at
>>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>>>>>         at
>>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>>>>>         at
>>>>> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>>>>>         at
>>>>> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
>>>>> ....
>>>>>
>>>>> My datasource bundle is deployed in OSGi (later the username and
>>>>> password will be configurable, that is - outside of the bundle)
>>>>>
>>>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>>>>>
>>>>>  <bean id="weatherDataSource"
>>>>> class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
>>>>> <property name="url"
>>>>>  value="jdbc:mysql://
>>>>> dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8<http://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>"
>>>>> />
>>>>>  <property name="user" value="myUsername" />
>>>>> <property name="password" value="myPassword" />
>>>>>  </bean>
>>>>>
>>>>> <service interface="javax.sql.DataSource" ref="weatherDataSource">
>>>>>  <service-properties>
>>>>> <entry key="osgi.jndi.service.name" value="jdbc/mysqlds" />
>>>>>  </service-properties>
>>>>> </service>
>>>>>  </blueprint>
>>>>>
>>>>> which is used by my model bundle's persistence.xml
>>>>>
>>>>> <persistence version="1.0" xmlns="
>>>>> http://java.sun.com/xml/ns/persistence" xmlns:xsi="
>>>>> http://www.w3.org/2001/XMLSchema-instance"
>>>>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>>>>   <persistence-unit name="weather" transaction-type="JTA">
>>>>>
>>>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>>>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>>>>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>>>>  <class>my.company.weather.entities.WeatherCurrent</class>
>>>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>>>>  </persistence-unit>
>>>>> </persistence>
>>>>>
>>>>> I think the problem is that my model bundle is not seeing the
>>>>> datasource service. How do I confirm that or how should my model's
>>>>>  MANIFEST look like?
>>>>>
>>>>> Cheers,
>>>>> borut
>>>>>
>>>>>
>>>>> Dne 19. april 2012 20:35 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>>
>>>>> A few years back Hibernate was my choice. The past two years I have
>>>>>> moved to OpenJPA. The main reason is that OpenJPA works much better with
>>>>>> OSGi. I did try EclipseLink as well but had OSGi problems. This was a while
>>>>>> back and has probably been improved by now.
>>>>>>
>>>>>> Another reason why I prefer OpenJPA to Hibernate is that the Apache
>>>>>> community is so much better - much more open. I'm sure this is a matter of
>>>>>> taste but I would not go for Hibernate.
>>>>>>
>>>>>> That said, OpenJPA also has some classloading issues under OSGi. In
>>>>>> normal situations it works though. A final compelling reason to use OpenJPA
>>>>>> is that it is much more common choice when using Apache Karaf (I think).
>>>>>> It's normally easier to use different Apache projects together since
>>>>>> someone else has always done it before.
>>>>>>
>>>>>> What I don't like is the way JPA uses the persistence.xml. I tend to
>>>>>> go with the approach Christian recommended - to put the datasource in a
>>>>>> separate bundle. It can then easily be switched. In practice, though, it's
>>>>>> hard to actually change database type (not just url) without having to
>>>>>> affect the application.
>>>>>>
>>>>>> First, the JPA implementation is configured in persistence.xml. E g
>>>>>> that's where you specify database dialect for OpenJPA. Ideally this would
>>>>>> be separated from the persistence.xml and possible to configure (e g with
>>>>>> OSGi's config admin).
>>>>>>
>>>>>> Second, at least when using JPA annotations (which I do), your source
>>>>>> code becomes tailored for a certain database type. I often startup with a
>>>>>> simple Derby database for testing and then move  to SQLServer for
>>>>>> production. In that process I often have to change some annotations to make
>>>>>> it work in SQLServer.
>>>>>>
>>>>>> Overall I'm quite content with the OpenJPA+Aries+Karaf combo though.
>>>>>> I just wish that Aries could get their release process straightened out
>>>>>> soon.
>>>>>>
>>>>>> /Bengt
>>>>>>
>>>>>>
>>>>>> 2012/4/19 Borut Bolcina <bo...@gmail.com>
>>>>>>
>>>>>>> On 19. apr. 2012, at 16:11, Christian Schneider <
>>>>>>> chris@die-schneider.net> wrote:
>>>>>>>
>>>>>>> > I guess the suggested way is to not run hibernate :-) For me the
>>>>>>> fact that they do not create bundles says that jboss does not care about
>>>>>>> OSGi in hibernate. As they now have an OSGi server with JBoss 7 that may
>>>>>>> change soon though.
>>>>>>>
>>>>>>> I just looked at JBoss website and their support is not even in
>>>>>>> dipers. See https://issues.jboss.org/browse/JBOSGI-260.
>>>>>>>
>>>>>>> > I had some good experience with apache openjpa together with
>>>>>>> apache aries jpa. Together they solve the classloading problem where the
>>>>>>> jpa provider can not see the user classes. I have not built bigger
>>>>>>> applications with it though.
>>>>>>>
>>>>>>> I will try with OpenJPA, but would really like to hear other
>>>>>>> people's hibernate stories!
>>>>>>>
>>>>>>> >
>>>>>>> > There is also Eclipselink. With their affiliation to Eclipse they
>>>>>>> will surely have an eye on OSGi compatibility. The problem there was that
>>>>>>> they did not put their jas into the maven central repo.
>>>>>>> >
>>>>>>> > So all in all I am not sure what to recommend. Perhaps others
>>>>>>> already have experience with some jpa solution in bigger projects?
>>>>>>>
>>>>>>> Please share some stories to make my decision easier.
>>>>>>>
>>>>>>> Borut
>>>>>>>
>>>>>>> >
>>>>>>> > Christian
>>>>>>> >
>>>>>>> > Am 19.04.2012 15:56, schrieb Borut Bolčina:
>>>>>>> >> Thanks Christian,
>>>>>>> >>
>>>>>>> >> I understand now what you were suggesting. The database type
>>>>>>> (vendor) will be the same in all environments (mysql), but with different
>>>>>>> addresses, engine types, usernames and passwords, which brings another
>>>>>>> topic up - configuration (I will probably ask this in days to come).
>>>>>>> >>
>>>>>>> >> I will be separating datasources, it is just the case that I want
>>>>>>> a working solution and then smooth it out.
>>>>>>> >>
>>>>>>> >> For a begginer it is very hard to get a hibernate mysql combo to
>>>>>>> work (mine still does not). There are examples for persistence, but I had
>>>>>>> to read a lot until I found that Hibernate does not even has bundles,
>>>>>>> therefore tricks has to be performed.
>>>>>>> >>
>>>>>>> >> Is there "an official Karaf Hibernate Feature"? If not, what is
>>>>>>> the suggested way to run Hibernate in Karaf? I am planning to use Hibernate
>>>>>>> Search, Solr and Lucene by using Camel components, so I have lots of ground
>>>>>>> to cover.
>>>>>>> >>
>>>>>>> >> Cheers,
>>>>>>> >> borut
>>>>>>> >>
>>>>>>> >
>>>>>>> > --
>>>>>>> > Christian Schneider
>>>>>>> > http://www.liquid-reality.de
>>>>>>> >
>>>>>>> > Open Source Architect
>>>>>>> > Talend Application Integration Division http://www.talend.com
>>>>>>> >
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>

Re: Deploying data sources

Posted by Borut Bolčina <bo...@gmail.com>.
I modified the model bundle to include properties section in persistence.xml

<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">

<persistence-unit name="weather" transaction-type="JTA">
 <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name
=jdbc/mysqlds)</jta-data-source>
 <class>si.najdi.weather.entities.WeatherCurrent</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>

<properties>
<property name="openjpa.ConnectionFactoryMode" value="managed" />
 <property name="openjpa.jdbc.DBDictionary" value="mysql(TableType=innodb)"
/>
 <property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO" />
</properties>

</persistence-unit>
</persistence>

and reinstalled all my bundles, but it makes no difference.

I notices this in my console when the route is started:

20  WARN   [Blueprint Extender: 2] openjpa.Runtime - The configuration
property named "openjpa.Id" was not recognized and will be ignored,
although the name closely matches a valid property called "openjpa.Id".

With the TRACE level enabled, I see:

karaf@root> osgi:install -s mvn:com.mycompany/weather-model/1.0.5-SNAPSHOT
35  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following
properties from "?" into configuration:
{openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
openjpa.ConnectionFactoryMode=managed,
javax.persistence.validation.mode=AUTO,
javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
openjpa.TransactionMode=managed,
openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac,
javax.persistence.sharedCache.mode=UNSPECIFIED,
openjpa.Log=DefaultLevel=TRACE, Tool=INFO,
openjpa.jdbc.DBDictionary=mysql(TableType=innodb), PersistenceVersion=1.0,
openjpa.Id=weather}
58  weather  TRACE  [Thread-10] openjpa.Runtime - No cache marshaller found
for id org.apache.openjpa.conf.MetaDataCacheMaintenance.
104  weather  TRACE  [Thread-10] openjpa.MetaData - Scanning resource
"META-INF/orm.xml" for persistent types.
105  weather  TRACE  [Thread-10] openjpa.MetaData - The persistent unit
root url is "null"
105  weather  TRACE  [Thread-10] openjpa.MetaData -
parsePersistentTypeNames() found
[com.mycompany.weather.entities.WeatherCurrent].
106  weather  TRACE  [Thread-10] openjpa.MetaData - Found 1 classes with
metadata in 48 milliseconds.
1  weather  TRACE  [Thread-10] openjpa.Runtime - Setting the following
properties from "?" into configuration: {openjpa.BrokerFactory=jdbc,
javax.persistence.provider=org.apache.openjpa.persistence.PersistenceProviderImpl,
javax.persistence.sharedCache.mode=UNSPECIFIED, PersistenceVersion=1.0,
openjpa.jdbc.DBDictionary=mysql(TableType=innodb),
openjpa.Log=DefaultLevel=TRACE, Tool=INFO, openjpa.Id=weather,
openjpa.ConnectionFactoryMode=managed,
openjpa.ConnectionFactory=org.apache.aries.jpa.container.unit.impl.DelayedLookupDataSource@92b,
javax.persistence.validation.mode=AUTO, openjpa.TransactionMode=managed,
openjpa.MetaDataFactory=jpa(Types=com.mycompany.weather.entities.WeatherCurrent),
openjpa.BrokerImpl=non-finalizing,
openjpa.ClassResolver=org.apache.openjpa.persistence.PersistenceUnitInfoImpl$ClassResolverImpl@ee7fac
}
1  weather  TRACE  [Thread-10] openjpa.Runtime - Not creating a
ValidatorImpl because this app is using the JPA 1.0 Spec
1  weather  TRACE  [Thread-10] openjpa.Runtime -
org.apache.openjpa.persistence.PersistenceProviderImpl@1ad69f1 creating
container org.apache.openjpa.persistence.EntityManagerFactoryImpl@6888b for
PU weather.
Bundle ID: 137


Certanly this look strange:
Not creating a ValidatorImpl because this app is using the JPA 1.0 Spec

Digging...




Dne 26. april 2012 12:57 je Bengt Rodehav <be...@rodehav.com> napisal/-a:

> Then I guess OpenJPA can't find or does not try to find your datasource
> service. Looking at my different persistence.xml's I usually have a few
> OpenJPA properties defined, like this:
>
> *<properties>*
> *      <property name="openjpa.ConnectionFactoryMode" value="managed" />*
> *      <property name="openjpa.jdbc.SynchronizeMappings"
> value="buildSchema(ForeignKeys=true)" />*
> *      <property name="openjpa.jdbc.DBDictionary"
> value="org.apache.openjpa.jdbc.sql.SQLServerDictionary" />*
> *      <property name="openjpa.jdbc.UpdateManager"
> value="operation-order" />*
> *      <property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO"
> />*
> *<!--      <property name="openjpa.Log" value="DefaultLevel=TRACE,
> Tool=INFO" />-->*
> *    </properties>*
>
> One idea is to enable TRACE logging to see what OpenJPA complains about.
> Another one is that maybe the first property (the ConnectionFactoryMode)
> must be set to "managed" for this to work. I'm not sure but there is
> probably a reason why I always have that property defined.
>
> /Bengt
>
> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>
>> Hello,
>>
>> yes I find this comments very useful!
>>
>> karaf@root> ls | grep -B 4 javax.sql.DataSource
>> org.apache.aries.jpa.container.context.PersistenceContextProvider
>>
>> weather-datasource (123) provides:
>> ----------------------------------
>> javax.sql.DataSource
>> karaf@root> ls 123
>>
>> weather-datasource (123) provides:
>> ----------------------------------
>> objectClass = javax.sql.DataSource
>> osgi.jndi.service.name = jdbc/mysqlds
>> osgi.service.blueprint.compname = weatherDataSource
>> service.id = 222
>> ----
>> objectClass = org.osgi.service.blueprint.container.BlueprintContainer
>> osgi.blueprint.container.symbolicname = weather-datasource
>> osgi.blueprint.container.version = 1.0.5.SNAPSHOT
>> service.id = 223
>>
>> I guess the datasource service is published correctly.
>>
>> Thanks,
>> borut
>>
>> Dne 26. april 2012 11:09 je Bengt Rodehav <be...@rodehav.com> napisal/-a:
>>
>> Hello there,
>>>
>>> I guess you should check that your datasource has been published as a
>>> service. I'm not the best Karaf guru but I would do something like this:
>>>
>>> Check what services provides datasources:
>>>
>>> *ls | grep -B 4 javax.sql.DataSource*
>>>
>>> This should identify what bundles provide datasources as services.
>>> Assume that one of the bundles had the bundle id 78, you could then look
>>> more closely at that bundles services with the following command:
>>>
>>> *ls 78*
>>> *
>>> *
>>> You will now see the services provided by this bundle and also its
>>> service properties. You should see a line similar to:
>>>
>>> *osgi.jndi.service.name = jdbc/mysqlds*
>>>
>>> Hope that helps,
>>>
>>> /Bengt
>>>
>>>
>>>
>>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>>
>>>> Hello,
>>>>
>>>> thanks Bengt for your input, I really appreciate you took the time!
>>>>
>>>> My work on this is somehow sporadic, but now I have managed to get the
>>>> Camel route running in Karaf
>>>>
>>>> from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
>>>>  .log("Getting weather from: " + sourceUrl)
>>>> .to(sourceUrl)
>>>>  .split()
>>>> .tokenizeXML("metData")
>>>>  .unmarshal(jaxbDataFormat)
>>>>
>>>> .to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
>>>>
>>>> with the exception of saving the data to the database which fails with:
>>>>
>>>> Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
>>>> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
>>>> DataSource class name must be specified in
>>>> the ConnectionDriverName property. Available properties in
>>>> configuration are
>>>> "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>>>>         at
>>>> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>>>>         at
>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>>>>         at
>>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>>>>         at
>>>> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>>>>         at
>>>> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
>>>> ....
>>>>
>>>> My datasource bundle is deployed in OSGi (later the username and
>>>> password will be configurable, that is - outside of the bundle)
>>>>
>>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>>>>
>>>>  <bean id="weatherDataSource"
>>>> class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
>>>> <property name="url"
>>>>  value="jdbc:mysql://
>>>> dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8<http://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>"
>>>> />
>>>>  <property name="user" value="myUsername" />
>>>> <property name="password" value="myPassword" />
>>>>  </bean>
>>>>
>>>> <service interface="javax.sql.DataSource" ref="weatherDataSource">
>>>>  <service-properties>
>>>> <entry key="osgi.jndi.service.name" value="jdbc/mysqlds" />
>>>>  </service-properties>
>>>> </service>
>>>>  </blueprint>
>>>>
>>>> which is used by my model bundle's persistence.xml
>>>>
>>>> <persistence version="1.0" xmlns="
>>>> http://java.sun.com/xml/ns/persistence" xmlns:xsi="
>>>> http://www.w3.org/2001/XMLSchema-instance"
>>>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>>>   <persistence-unit name="weather" transaction-type="JTA">
>>>>
>>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>>>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>>>  <class>my.company.weather.entities.WeatherCurrent</class>
>>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>>>  </persistence-unit>
>>>> </persistence>
>>>>
>>>> I think the problem is that my model bundle is not seeing the
>>>> datasource service. How do I confirm that or how should my model's
>>>>  MANIFEST look like?
>>>>
>>>> Cheers,
>>>> borut
>>>>
>>>>
>>>> Dne 19. april 2012 20:35 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>>
>>>> A few years back Hibernate was my choice. The past two years I have
>>>>> moved to OpenJPA. The main reason is that OpenJPA works much better with
>>>>> OSGi. I did try EclipseLink as well but had OSGi problems. This was a while
>>>>> back and has probably been improved by now.
>>>>>
>>>>> Another reason why I prefer OpenJPA to Hibernate is that the Apache
>>>>> community is so much better - much more open. I'm sure this is a matter of
>>>>> taste but I would not go for Hibernate.
>>>>>
>>>>> That said, OpenJPA also has some classloading issues under OSGi. In
>>>>> normal situations it works though. A final compelling reason to use OpenJPA
>>>>> is that it is much more common choice when using Apache Karaf (I think).
>>>>> It's normally easier to use different Apache projects together since
>>>>> someone else has always done it before.
>>>>>
>>>>> What I don't like is the way JPA uses the persistence.xml. I tend to
>>>>> go with the approach Christian recommended - to put the datasource in a
>>>>> separate bundle. It can then easily be switched. In practice, though, it's
>>>>> hard to actually change database type (not just url) without having to
>>>>> affect the application.
>>>>>
>>>>> First, the JPA implementation is configured in persistence.xml. E g
>>>>> that's where you specify database dialect for OpenJPA. Ideally this would
>>>>> be separated from the persistence.xml and possible to configure (e g with
>>>>> OSGi's config admin).
>>>>>
>>>>> Second, at least when using JPA annotations (which I do), your source
>>>>> code becomes tailored for a certain database type. I often startup with a
>>>>> simple Derby database for testing and then move  to SQLServer for
>>>>> production. In that process I often have to change some annotations to make
>>>>> it work in SQLServer.
>>>>>
>>>>> Overall I'm quite content with the OpenJPA+Aries+Karaf combo though. I
>>>>> just wish that Aries could get their release process straightened out soon.
>>>>>
>>>>> /Bengt
>>>>>
>>>>>
>>>>> 2012/4/19 Borut Bolcina <bo...@gmail.com>
>>>>>
>>>>>> On 19. apr. 2012, at 16:11, Christian Schneider <
>>>>>> chris@die-schneider.net> wrote:
>>>>>>
>>>>>> > I guess the suggested way is to not run hibernate :-) For me the
>>>>>> fact that they do not create bundles says that jboss does not care about
>>>>>> OSGi in hibernate. As they now have an OSGi server with JBoss 7 that may
>>>>>> change soon though.
>>>>>>
>>>>>> I just looked at JBoss website and their support is not even in
>>>>>> dipers. See https://issues.jboss.org/browse/JBOSGI-260.
>>>>>>
>>>>>> > I had some good experience with apache openjpa together with apache
>>>>>> aries jpa. Together they solve the classloading problem where the jpa
>>>>>> provider can not see the user classes. I have not built bigger applications
>>>>>> with it though.
>>>>>>
>>>>>> I will try with OpenJPA, but would really like to hear other people's
>>>>>> hibernate stories!
>>>>>>
>>>>>> >
>>>>>> > There is also Eclipselink. With their affiliation to Eclipse they
>>>>>> will surely have an eye on OSGi compatibility. The problem there was that
>>>>>> they did not put their jas into the maven central repo.
>>>>>> >
>>>>>> > So all in all I am not sure what to recommend. Perhaps others
>>>>>> already have experience with some jpa solution in bigger projects?
>>>>>>
>>>>>> Please share some stories to make my decision easier.
>>>>>>
>>>>>> Borut
>>>>>>
>>>>>> >
>>>>>> > Christian
>>>>>> >
>>>>>> > Am 19.04.2012 15:56, schrieb Borut Bolčina:
>>>>>> >> Thanks Christian,
>>>>>> >>
>>>>>> >> I understand now what you were suggesting. The database type
>>>>>> (vendor) will be the same in all environments (mysql), but with different
>>>>>> addresses, engine types, usernames and passwords, which brings another
>>>>>> topic up - configuration (I will probably ask this in days to come).
>>>>>> >>
>>>>>> >> I will be separating datasources, it is just the case that I want
>>>>>> a working solution and then smooth it out.
>>>>>> >>
>>>>>> >> For a begginer it is very hard to get a hibernate mysql combo to
>>>>>> work (mine still does not). There are examples for persistence, but I had
>>>>>> to read a lot until I found that Hibernate does not even has bundles,
>>>>>> therefore tricks has to be performed.
>>>>>> >>
>>>>>> >> Is there "an official Karaf Hibernate Feature"? If not, what is
>>>>>> the suggested way to run Hibernate in Karaf? I am planning to use Hibernate
>>>>>> Search, Solr and Lucene by using Camel components, so I have lots of ground
>>>>>> to cover.
>>>>>> >>
>>>>>> >> Cheers,
>>>>>> >> borut
>>>>>> >>
>>>>>> >
>>>>>> > --
>>>>>> > Christian Schneider
>>>>>> > http://www.liquid-reality.de
>>>>>> >
>>>>>> > Open Source Architect
>>>>>> > Talend Application Integration Division http://www.talend.com
>>>>>> >
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>

Re: Deploying data sources

Posted by Bengt Rodehav <be...@rodehav.com>.
Then I guess OpenJPA can't find or does not try to find your datasource
service. Looking at my different persistence.xml's I usually have a few
OpenJPA properties defined, like this:

*<properties>*
*      <property name="openjpa.ConnectionFactoryMode" value="managed" />*
*      <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)" />*
*      <property name="openjpa.jdbc.DBDictionary"
value="org.apache.openjpa.jdbc.sql.SQLServerDictionary" />*
*      <property name="openjpa.jdbc.UpdateManager" value="operation-order"
/>*
*      <property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO" />*
*<!--      <property name="openjpa.Log" value="DefaultLevel=TRACE,
Tool=INFO" />-->*
*    </properties>*

One idea is to enable TRACE logging to see what OpenJPA complains about.
Another one is that maybe the first property (the ConnectionFactoryMode)
must be set to "managed" for this to work. I'm not sure but there is
probably a reason why I always have that property defined.

/Bengt

2012/4/26 Borut Bolčina <bo...@gmail.com>

> Hello,
>
> yes I find this comments very useful!
>
> karaf@root> ls | grep -B 4 javax.sql.DataSource
> org.apache.aries.jpa.container.context.PersistenceContextProvider
>
> weather-datasource (123) provides:
> ----------------------------------
> javax.sql.DataSource
> karaf@root> ls 123
>
> weather-datasource (123) provides:
> ----------------------------------
> objectClass = javax.sql.DataSource
> osgi.jndi.service.name = jdbc/mysqlds
> osgi.service.blueprint.compname = weatherDataSource
> service.id = 222
> ----
> objectClass = org.osgi.service.blueprint.container.BlueprintContainer
> osgi.blueprint.container.symbolicname = weather-datasource
> osgi.blueprint.container.version = 1.0.5.SNAPSHOT
> service.id = 223
>
> I guess the datasource service is published correctly.
>
> Thanks,
> borut
>
> Dne 26. april 2012 11:09 je Bengt Rodehav <be...@rodehav.com> napisal/-a:
>
> Hello there,
>>
>> I guess you should check that your datasource has been published as a
>> service. I'm not the best Karaf guru but I would do something like this:
>>
>> Check what services provides datasources:
>>
>> *ls | grep -B 4 javax.sql.DataSource*
>>
>> This should identify what bundles provide datasources as services. Assume
>> that one of the bundles had the bundle id 78, you could then look more
>> closely at that bundles services with the following command:
>>
>> *ls 78*
>> *
>> *
>> You will now see the services provided by this bundle and also its
>> service properties. You should see a line similar to:
>>
>> *osgi.jndi.service.name = jdbc/mysqlds*
>>
>> Hope that helps,
>>
>> /Bengt
>>
>>
>>
>> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>>
>>> Hello,
>>>
>>> thanks Bengt for your input, I really appreciate you took the time!
>>>
>>> My work on this is somehow sporadic, but now I have managed to get the
>>> Camel route running in Karaf
>>>
>>> from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
>>>  .log("Getting weather from: " + sourceUrl)
>>> .to(sourceUrl)
>>>  .split()
>>> .tokenizeXML("metData")
>>>  .unmarshal(jaxbDataFormat)
>>>
>>> .to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
>>>
>>> with the exception of saving the data to the database which fails with:
>>>
>>> Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
>>> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
>>> DataSource class name must be specified in
>>> the ConnectionDriverName property. Available properties in configuration
>>> are "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>>>         at
>>> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>>>         at
>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>>>         at
>>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>>>         at
>>> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>>>         at
>>> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
>>> ....
>>>
>>> My datasource bundle is deployed in OSGi (later the username and
>>> password will be configurable, that is - outside of the bundle)
>>>
>>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>>>
>>>  <bean id="weatherDataSource"
>>> class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
>>> <property name="url"
>>>  value="jdbc:mysql://
>>> dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8<http://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>"
>>> />
>>>  <property name="user" value="myUsername" />
>>> <property name="password" value="myPassword" />
>>>  </bean>
>>>
>>> <service interface="javax.sql.DataSource" ref="weatherDataSource">
>>>  <service-properties>
>>> <entry key="osgi.jndi.service.name" value="jdbc/mysqlds" />
>>>  </service-properties>
>>> </service>
>>>  </blueprint>
>>>
>>> which is used by my model bundle's persistence.xml
>>>
>>> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>>   <persistence-unit name="weather" transaction-type="JTA">
>>>
>>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>>  <class>my.company.weather.entities.WeatherCurrent</class>
>>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>>  </persistence-unit>
>>> </persistence>
>>>
>>> I think the problem is that my model bundle is not seeing the datasource
>>> service. How do I confirm that or how should my model's  MANIFEST look like?
>>>
>>> Cheers,
>>> borut
>>>
>>>
>>> Dne 19. april 2012 20:35 je Bengt Rodehav <be...@rodehav.com>napisal/-a:
>>>
>>> A few years back Hibernate was my choice. The past two years I have
>>>> moved to OpenJPA. The main reason is that OpenJPA works much better with
>>>> OSGi. I did try EclipseLink as well but had OSGi problems. This was a while
>>>> back and has probably been improved by now.
>>>>
>>>> Another reason why I prefer OpenJPA to Hibernate is that the Apache
>>>> community is so much better - much more open. I'm sure this is a matter of
>>>> taste but I would not go for Hibernate.
>>>>
>>>> That said, OpenJPA also has some classloading issues under OSGi. In
>>>> normal situations it works though. A final compelling reason to use OpenJPA
>>>> is that it is much more common choice when using Apache Karaf (I think).
>>>> It's normally easier to use different Apache projects together since
>>>> someone else has always done it before.
>>>>
>>>> What I don't like is the way JPA uses the persistence.xml. I tend to go
>>>> with the approach Christian recommended - to put the datasource in a
>>>> separate bundle. It can then easily be switched. In practice, though, it's
>>>> hard to actually change database type (not just url) without having to
>>>> affect the application.
>>>>
>>>> First, the JPA implementation is configured in persistence.xml. E g
>>>> that's where you specify database dialect for OpenJPA. Ideally this would
>>>> be separated from the persistence.xml and possible to configure (e g with
>>>> OSGi's config admin).
>>>>
>>>> Second, at least when using JPA annotations (which I do), your source
>>>> code becomes tailored for a certain database type. I often startup with a
>>>> simple Derby database for testing and then move  to SQLServer for
>>>> production. In that process I often have to change some annotations to make
>>>> it work in SQLServer.
>>>>
>>>> Overall I'm quite content with the OpenJPA+Aries+Karaf combo though. I
>>>> just wish that Aries could get their release process straightened out soon.
>>>>
>>>> /Bengt
>>>>
>>>>
>>>> 2012/4/19 Borut Bolcina <bo...@gmail.com>
>>>>
>>>>> On 19. apr. 2012, at 16:11, Christian Schneider <
>>>>> chris@die-schneider.net> wrote:
>>>>>
>>>>> > I guess the suggested way is to not run hibernate :-) For me the
>>>>> fact that they do not create bundles says that jboss does not care about
>>>>> OSGi in hibernate. As they now have an OSGi server with JBoss 7 that may
>>>>> change soon though.
>>>>>
>>>>> I just looked at JBoss website and their support is not even in
>>>>> dipers. See https://issues.jboss.org/browse/JBOSGI-260.
>>>>>
>>>>> > I had some good experience with apache openjpa together with apache
>>>>> aries jpa. Together they solve the classloading problem where the jpa
>>>>> provider can not see the user classes. I have not built bigger applications
>>>>> with it though.
>>>>>
>>>>> I will try with OpenJPA, but would really like to hear other people's
>>>>> hibernate stories!
>>>>>
>>>>> >
>>>>> > There is also Eclipselink. With their affiliation to Eclipse they
>>>>> will surely have an eye on OSGi compatibility. The problem there was that
>>>>> they did not put their jas into the maven central repo.
>>>>> >
>>>>> > So all in all I am not sure what to recommend. Perhaps others
>>>>> already have experience with some jpa solution in bigger projects?
>>>>>
>>>>> Please share some stories to make my decision easier.
>>>>>
>>>>> Borut
>>>>>
>>>>> >
>>>>> > Christian
>>>>> >
>>>>> > Am 19.04.2012 15:56, schrieb Borut Bolčina:
>>>>> >> Thanks Christian,
>>>>> >>
>>>>> >> I understand now what you were suggesting. The database type
>>>>> (vendor) will be the same in all environments (mysql), but with different
>>>>> addresses, engine types, usernames and passwords, which brings another
>>>>> topic up - configuration (I will probably ask this in days to come).
>>>>> >>
>>>>> >> I will be separating datasources, it is just the case that I want a
>>>>> working solution and then smooth it out.
>>>>> >>
>>>>> >> For a begginer it is very hard to get a hibernate mysql combo to
>>>>> work (mine still does not). There are examples for persistence, but I had
>>>>> to read a lot until I found that Hibernate does not even has bundles,
>>>>> therefore tricks has to be performed.
>>>>> >>
>>>>> >> Is there "an official Karaf Hibernate Feature"? If not, what is the
>>>>> suggested way to run Hibernate in Karaf? I am planning to use Hibernate
>>>>> Search, Solr and Lucene by using Camel components, so I have lots of ground
>>>>> to cover.
>>>>> >>
>>>>> >> Cheers,
>>>>> >> borut
>>>>> >>
>>>>> >
>>>>> > --
>>>>> > Christian Schneider
>>>>> > http://www.liquid-reality.de
>>>>> >
>>>>> > Open Source Architect
>>>>> > Talend Application Integration Division http://www.talend.com
>>>>> >
>>>>>
>>>>
>>>>
>>>
>>
>

Re: Deploying data sources

Posted by Borut Bolčina <bo...@gmail.com>.
Hello,

yes I find this comments very useful!

karaf@root> ls | grep -B 4 javax.sql.DataSource
org.apache.aries.jpa.container.context.PersistenceContextProvider

weather-datasource (123) provides:
----------------------------------
javax.sql.DataSource
karaf@root> ls 123

weather-datasource (123) provides:
----------------------------------
objectClass = javax.sql.DataSource
osgi.jndi.service.name = jdbc/mysqlds
osgi.service.blueprint.compname = weatherDataSource
service.id = 222
----
objectClass = org.osgi.service.blueprint.container.BlueprintContainer
osgi.blueprint.container.symbolicname = weather-datasource
osgi.blueprint.container.version = 1.0.5.SNAPSHOT
service.id = 223

I guess the datasource service is published correctly.

Thanks,
borut

Dne 26. april 2012 11:09 je Bengt Rodehav <be...@rodehav.com> napisal/-a:

> Hello there,
>
> I guess you should check that your datasource has been published as a
> service. I'm not the best Karaf guru but I would do something like this:
>
> Check what services provides datasources:
>
> *ls | grep -B 4 javax.sql.DataSource*
>
> This should identify what bundles provide datasources as services. Assume
> that one of the bundles had the bundle id 78, you could then look more
> closely at that bundles services with the following command:
>
> *ls 78*
> *
> *
> You will now see the services provided by this bundle and also its service
> properties. You should see a line similar to:
>
> *osgi.jndi.service.name = jdbc/mysqlds*
>
> Hope that helps,
>
> /Bengt
>
>
>
> 2012/4/26 Borut Bolčina <bo...@gmail.com>
>
>> Hello,
>>
>> thanks Bengt for your input, I really appreciate you took the time!
>>
>> My work on this is somehow sporadic, but now I have managed to get the
>> Camel route running in Karaf
>>
>> from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
>>  .log("Getting weather from: " + sourceUrl)
>> .to(sourceUrl)
>>  .split()
>> .tokenizeXML("metData")
>>  .unmarshal(jaxbDataFormat)
>>
>> .to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
>>
>> with the exception of saving the data to the database which fails with:
>>
>> Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
>> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
>> DataSource class name must be specified in
>> the ConnectionDriverName property. Available properties in configuration
>> are "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>>         at
>> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>>         at
>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>>         at
>> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>>         at
>> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>>         at
>> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
>> ....
>>
>> My datasource bundle is deployed in OSGi (later the username and password
>> will be configurable, that is - outside of the bundle)
>>
>> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>>
>>  <bean id="weatherDataSource"
>> class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
>> <property name="url"
>>  value="jdbc:mysql://
>> dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8<http://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>"
>> />
>>  <property name="user" value="myUsername" />
>> <property name="password" value="myPassword" />
>>  </bean>
>>
>> <service interface="javax.sql.DataSource" ref="weatherDataSource">
>>  <service-properties>
>> <entry key="osgi.jndi.service.name" value="jdbc/mysqlds" />
>>  </service-properties>
>> </service>
>>  </blueprint>
>>
>> which is used by my model bundle's persistence.xml
>>
>> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>>   <persistence-unit name="weather" transaction-type="JTA">
>>
>> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>> <jta-data-source>osgi:service/javax.sql.DataSource/(
>> osgi.jndi.service.name=jdbc/mysqlds)</jta-data-source>
>>  <class>my.company.weather.entities.WeatherCurrent</class>
>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>>  </persistence-unit>
>> </persistence>
>>
>> I think the problem is that my model bundle is not seeing the datasource
>> service. How do I confirm that or how should my model's  MANIFEST look like?
>>
>> Cheers,
>> borut
>>
>>
>> Dne 19. april 2012 20:35 je Bengt Rodehav <be...@rodehav.com> napisal/-a:
>>
>> A few years back Hibernate was my choice. The past two years I have moved
>>> to OpenJPA. The main reason is that OpenJPA works much better with OSGi. I
>>> did try EclipseLink as well but had OSGi problems. This was a while back
>>> and has probably been improved by now.
>>>
>>> Another reason why I prefer OpenJPA to Hibernate is that the Apache
>>> community is so much better - much more open. I'm sure this is a matter of
>>> taste but I would not go for Hibernate.
>>>
>>> That said, OpenJPA also has some classloading issues under OSGi. In
>>> normal situations it works though. A final compelling reason to use OpenJPA
>>> is that it is much more common choice when using Apache Karaf (I think).
>>> It's normally easier to use different Apache projects together since
>>> someone else has always done it before.
>>>
>>> What I don't like is the way JPA uses the persistence.xml. I tend to go
>>> with the approach Christian recommended - to put the datasource in a
>>> separate bundle. It can then easily be switched. In practice, though, it's
>>> hard to actually change database type (not just url) without having to
>>> affect the application.
>>>
>>> First, the JPA implementation is configured in persistence.xml. E g
>>> that's where you specify database dialect for OpenJPA. Ideally this would
>>> be separated from the persistence.xml and possible to configure (e g with
>>> OSGi's config admin).
>>>
>>> Second, at least when using JPA annotations (which I do), your source
>>> code becomes tailored for a certain database type. I often startup with a
>>> simple Derby database for testing and then move  to SQLServer for
>>> production. In that process I often have to change some annotations to make
>>> it work in SQLServer.
>>>
>>> Overall I'm quite content with the OpenJPA+Aries+Karaf combo though. I
>>> just wish that Aries could get their release process straightened out soon.
>>>
>>> /Bengt
>>>
>>>
>>> 2012/4/19 Borut Bolcina <bo...@gmail.com>
>>>
>>>> On 19. apr. 2012, at 16:11, Christian Schneider <
>>>> chris@die-schneider.net> wrote:
>>>>
>>>> > I guess the suggested way is to not run hibernate :-) For me the fact
>>>> that they do not create bundles says that jboss does not care about OSGi in
>>>> hibernate. As they now have an OSGi server with JBoss 7 that may change
>>>> soon though.
>>>>
>>>> I just looked at JBoss website and their support is not even in dipers.
>>>> See https://issues.jboss.org/browse/JBOSGI-260.
>>>>
>>>> > I had some good experience with apache openjpa together with apache
>>>> aries jpa. Together they solve the classloading problem where the jpa
>>>> provider can not see the user classes. I have not built bigger applications
>>>> with it though.
>>>>
>>>> I will try with OpenJPA, but would really like to hear other people's
>>>> hibernate stories!
>>>>
>>>> >
>>>> > There is also Eclipselink. With their affiliation to Eclipse they
>>>> will surely have an eye on OSGi compatibility. The problem there was that
>>>> they did not put their jas into the maven central repo.
>>>> >
>>>> > So all in all I am not sure what to recommend. Perhaps others already
>>>> have experience with some jpa solution in bigger projects?
>>>>
>>>> Please share some stories to make my decision easier.
>>>>
>>>> Borut
>>>>
>>>> >
>>>> > Christian
>>>> >
>>>> > Am 19.04.2012 15:56, schrieb Borut Bolčina:
>>>> >> Thanks Christian,
>>>> >>
>>>> >> I understand now what you were suggesting. The database type
>>>> (vendor) will be the same in all environments (mysql), but with different
>>>> addresses, engine types, usernames and passwords, which brings another
>>>> topic up - configuration (I will probably ask this in days to come).
>>>> >>
>>>> >> I will be separating datasources, it is just the case that I want a
>>>> working solution and then smooth it out.
>>>> >>
>>>> >> For a begginer it is very hard to get a hibernate mysql combo to
>>>> work (mine still does not). There are examples for persistence, but I had
>>>> to read a lot until I found that Hibernate does not even has bundles,
>>>> therefore tricks has to be performed.
>>>> >>
>>>> >> Is there "an official Karaf Hibernate Feature"? If not, what is the
>>>> suggested way to run Hibernate in Karaf? I am planning to use Hibernate
>>>> Search, Solr and Lucene by using Camel components, so I have lots of ground
>>>> to cover.
>>>> >>
>>>> >> Cheers,
>>>> >> borut
>>>> >>
>>>> >
>>>> > --
>>>> > Christian Schneider
>>>> > http://www.liquid-reality.de
>>>> >
>>>> > Open Source Architect
>>>> > Talend Application Integration Division http://www.talend.com
>>>> >
>>>>
>>>
>>>
>>
>

Re: Deploying data sources

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
You have some good example in the Aries (in the ariestrader or blog sample).

Regards
JB

On 04/26/2012 11:09 AM, Bengt Rodehav wrote:
> Hello there,
>
> I guess you should check that your datasource has been published as a
> service. I'm not the best Karaf guru but I would do something like this:
>
> Check what services provides datasources:
>
> /ls | grep -B 4 javax.sql.DataSource/
>
> This should identify what bundles provide datasources as services.
> Assume that one of the bundles had the bundle id 78, you could then look
> more closely at that bundles services with the following command:
>
> /ls 78/
> /
> /
> You will now see the services provided by this bundle and also its
> service properties. You should see a line similar to:
>
> /osgi.jndi.service.name <http://osgi.jndi.service.name> = jdbc/mysqlds/
>
> Hope that helps,
>
> /Bengt
>
>
>
> 2012/4/26 Borut Bolčina <borut.bolcina@gmail.com
> <ma...@gmail.com>>
>
>     Hello,
>
>     thanks Bengt for your input, I really appreciate you took the time!
>
>     My work on this is somehow sporadic, but now I have managed to get
>     the Camel route running in Karaf
>
>     from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
>     .log("Getting weather from: " + sourceUrl)
>     .to(sourceUrl)
>     .split()
>     .tokenizeXML("metData")
>     .unmarshal(jaxbDataFormat)
>     .to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
>
>     with the exception of saving the data to the database which fails with:
>
>     Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
>     org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
>     DataSource class name must be specified in
>     the ConnectionDriverName property. Available properties in
>     configuration are
>     "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>              at
>     org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>              at
>     org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>              at
>     org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>              at
>     org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>              at
>     org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
>     ....
>
>     My datasource bundle is deployed in OSGi (later the username and
>     password will be configurable, that is - outside of the bundle)
>
>     <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>
>     <bean id="weatherDataSource"
>     class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
>     <property name="url"
>     value="jdbc:mysql://dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8
>     <http://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>"
>     />
>     <property name="user" value="myUsername" />
>     <property name="password" value="myPassword" />
>     </bean>
>
>     <service interface="javax.sql.DataSource" ref="weatherDataSource">
>     <service-properties>
>     <entry key="osgi.jndi.service.name <http://osgi.jndi.service.name>"
>     value="jdbc/mysqlds" />
>     </service-properties>
>     </service>
>     </blueprint>
>
>     which is used by my model bundle's persistence.xml
>
>     <persistence version="1.0"
>     xmlns="http://java.sun.com/xml/ns/persistence"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>     http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>     <persistence-unit name="weather" transaction-type="JTA">
>     <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
>     <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name
>     <http://osgi.jndi.service.name>=jdbc/mysqlds)</jta-data-source>
>     <class>my.company.weather.entities.WeatherCurrent</class>
>     <exclude-unlisted-classes>true</exclude-unlisted-classes>
>     </persistence-unit>
>     </persistence>
>
>     I think the problem is that my model bundle is not seeing the
>     datasource service. How do I confirm that or how should my model's
>       MANIFEST look like?
>
>     Cheers,
>     borut
>
>
>     Dne 19. april 2012 20:35 je Bengt Rodehav <bengt@rodehav.com
>     <ma...@rodehav.com>> napisal/-a:
>
>         A few years back Hibernate was my choice. The past two years I
>         have moved to OpenJPA. The main reason is that OpenJPA works
>         much better with OSGi. I did try EclipseLink as well but had
>         OSGi problems. This was a while back and has probably been
>         improved by now.
>
>         Another reason why I prefer OpenJPA to Hibernate is that the
>         Apache community is so much better - much more open. I'm sure
>         this is a matter of taste but I would not go for Hibernate.
>
>         That said, OpenJPA also has some classloading issues under OSGi.
>         In normal situations it works though. A final compelling reason
>         to use OpenJPA is that it is much more common choice when using
>         Apache Karaf (I think). It's normally easier to use different
>         Apache projects together since someone else has always done it
>         before.
>
>         What I don't like is the way JPA uses the persistence.xml. I
>         tend to go with the approach Christian recommended - to put the
>         datasource in a separate bundle. It can then easily be switched.
>         In practice, though, it's hard to actually change database type
>         (not just url) without having to affect the application.
>
>         First, the JPA implementation is configured in persistence.xml.
>         E g that's where you specify database dialect for OpenJPA.
>         Ideally this would be separated from the persistence.xml and
>         possible to configure (e g with OSGi's config admin).
>
>         Second, at least when using JPA annotations (which I do), your
>         source code becomes tailored for a certain database type. I
>         often startup with a simple Derby database for testing and then
>         move  to SQLServer for production. In that process I often have
>         to change some annotations to make it work in SQLServer.
>
>         Overall I'm quite content with the OpenJPA+Aries+Karaf combo
>         though. I just wish that Aries could get their release process
>         straightened out soon.
>
>         /Bengt
>
>
>         2012/4/19 Borut Bolcina <borut.bolcina@gmail.com
>         <ma...@gmail.com>>
>
>             On 19. apr. 2012, at 16:11, Christian Schneider
>             <chris@die-schneider.net <ma...@die-schneider.net>>
>             wrote:
>
>              > I guess the suggested way is to not run hibernate :-) For
>             me the fact that they do not create bundles says that jboss
>             does not care about OSGi in hibernate. As they now have an
>             OSGi server with JBoss 7 that may change soon though.
>
>             I just looked at JBoss website and their support is not even
>             in dipers. See https://issues.jboss.org/browse/JBOSGI-260.
>
>              > I had some good experience with apache openjpa together
>             with apache aries jpa. Together they solve the classloading
>             problem where the jpa provider can not see the user classes.
>             I have not built bigger applications with it though.
>
>             I will try with OpenJPA, but would really like to hear other
>             people's hibernate stories!
>
>              >
>              > There is also Eclipselink. With their affiliation to
>             Eclipse they will surely have an eye on OSGi compatibility.
>             The problem there was that they did not put their jas into
>             the maven central repo.
>              >
>              > So all in all I am not sure what to recommend. Perhaps
>             others already have experience with some jpa solution in
>             bigger projects?
>
>             Please share some stories to make my decision easier.
>
>             Borut
>
>              >
>              > Christian
>              >
>              > Am 19.04.2012 15:56, schrieb Borut Bolčina:
>              >> Thanks Christian,
>              >>
>              >> I understand now what you were suggesting. The database
>             type (vendor) will be the same in all environments (mysql),
>             but with different addresses, engine types, usernames and
>             passwords, which brings another topic up - configuration (I
>             will probably ask this in days to come).
>              >>
>              >> I will be separating datasources, it is just the case
>             that I want a working solution and then smooth it out.
>              >>
>              >> For a begginer it is very hard to get a hibernate mysql
>             combo to work (mine still does not). There are examples for
>             persistence, but I had to read a lot until I found that
>             Hibernate does not even has bundles, therefore tricks has to
>             be performed.
>              >>
>              >> Is there "an official Karaf Hibernate Feature"? If not,
>             what is the suggested way to run Hibernate in Karaf? I am
>             planning to use Hibernate Search, Solr and Lucene by using
>             Camel components, so I have lots of ground to cover.
>              >>
>              >> Cheers,
>              >> borut
>              >>
>              >
>              > --
>              > Christian Schneider
>              > http://www.liquid-reality.de
>              >
>              > Open Source Architect
>              > Talend Application Integration Division http://www.talend.com
>              >
>
>
>
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Deploying data sources

Posted by Bengt Rodehav <be...@rodehav.com>.
Hello there,

I guess you should check that your datasource has been published as a
service. I'm not the best Karaf guru but I would do something like this:

Check what services provides datasources:

*ls | grep -B 4 javax.sql.DataSource*

This should identify what bundles provide datasources as services. Assume
that one of the bundles had the bundle id 78, you could then look more
closely at that bundles services with the following command:

*ls 78*
*
*
You will now see the services provided by this bundle and also its service
properties. You should see a line similar to:

*osgi.jndi.service.name = jdbc/mysqlds*

Hope that helps,

/Bengt



2012/4/26 Borut Bolčina <bo...@gmail.com>

> Hello,
>
> thanks Bengt for your input, I really appreciate you took the time!
>
> My work on this is somehow sporadic, but now I have managed to get the
> Camel route running in Karaf
>
> from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
>  .log("Getting weather from: " + sourceUrl)
> .to(sourceUrl)
>  .split()
> .tokenizeXML("metData")
>  .unmarshal(jaxbDataFormat)
>
> .to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");
>
> with the exception of saving the data to the database which fails with:
>
> Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
> DataSource class name must be specified in
> the ConnectionDriverName property. Available properties in configuration
> are "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
>         at
> org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
>         at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
>         at
> org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
>         at
> org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
>         at
> org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
> ....
>
> My datasource bundle is deployed in OSGi (later the username and password
> will be configurable, that is - outside of the bundle)
>
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
>
>  <bean id="weatherDataSource"
> class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
> <property name="url"
>  value="jdbc:mysql://
> dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8<http://dev.mycompany.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>"
> />
>  <property name="user" value="myUsername" />
> <property name="password" value="myPassword" />
>  </bean>
>
> <service interface="javax.sql.DataSource" ref="weatherDataSource">
>  <service-properties>
> <entry key="osgi.jndi.service.name" value="jdbc/mysqlds" />
>  </service-properties>
> </service>
>  </blueprint>
>
> which is used by my model bundle's persistence.xml
>
> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>  <persistence-unit name="weather" transaction-type="JTA">
>
> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
> <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name
> =jdbc/mysqlds)</jta-data-source>
>  <class>my.company.weather.entities.WeatherCurrent</class>
> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>  </persistence-unit>
> </persistence>
>
> I think the problem is that my model bundle is not seeing the datasource
> service. How do I confirm that or how should my model's  MANIFEST look like?
>
> Cheers,
> borut
>
>
> Dne 19. april 2012 20:35 je Bengt Rodehav <be...@rodehav.com> napisal/-a:
>
> A few years back Hibernate was my choice. The past two years I have moved
>> to OpenJPA. The main reason is that OpenJPA works much better with OSGi. I
>> did try EclipseLink as well but had OSGi problems. This was a while back
>> and has probably been improved by now.
>>
>> Another reason why I prefer OpenJPA to Hibernate is that the Apache
>> community is so much better - much more open. I'm sure this is a matter of
>> taste but I would not go for Hibernate.
>>
>> That said, OpenJPA also has some classloading issues under OSGi. In
>> normal situations it works though. A final compelling reason to use OpenJPA
>> is that it is much more common choice when using Apache Karaf (I think).
>> It's normally easier to use different Apache projects together since
>> someone else has always done it before.
>>
>> What I don't like is the way JPA uses the persistence.xml. I tend to go
>> with the approach Christian recommended - to put the datasource in a
>> separate bundle. It can then easily be switched. In practice, though, it's
>> hard to actually change database type (not just url) without having to
>> affect the application.
>>
>> First, the JPA implementation is configured in persistence.xml. E g
>> that's where you specify database dialect for OpenJPA. Ideally this would
>> be separated from the persistence.xml and possible to configure (e g with
>> OSGi's config admin).
>>
>> Second, at least when using JPA annotations (which I do), your source
>> code becomes tailored for a certain database type. I often startup with a
>> simple Derby database for testing and then move  to SQLServer for
>> production. In that process I often have to change some annotations to make
>> it work in SQLServer.
>>
>> Overall I'm quite content with the OpenJPA+Aries+Karaf combo though. I
>> just wish that Aries could get their release process straightened out soon.
>>
>> /Bengt
>>
>>
>> 2012/4/19 Borut Bolcina <bo...@gmail.com>
>>
>>> On 19. apr. 2012, at 16:11, Christian Schneider <ch...@die-schneider.net>
>>> wrote:
>>>
>>> > I guess the suggested way is to not run hibernate :-) For me the fact
>>> that they do not create bundles says that jboss does not care about OSGi in
>>> hibernate. As they now have an OSGi server with JBoss 7 that may change
>>> soon though.
>>>
>>> I just looked at JBoss website and their support is not even in dipers.
>>> See https://issues.jboss.org/browse/JBOSGI-260.
>>>
>>> > I had some good experience with apache openjpa together with apache
>>> aries jpa. Together they solve the classloading problem where the jpa
>>> provider can not see the user classes. I have not built bigger applications
>>> with it though.
>>>
>>> I will try with OpenJPA, but would really like to hear other people's
>>> hibernate stories!
>>>
>>> >
>>> > There is also Eclipselink. With their affiliation to Eclipse they will
>>> surely have an eye on OSGi compatibility. The problem there was that they
>>> did not put their jas into the maven central repo.
>>> >
>>> > So all in all I am not sure what to recommend. Perhaps others already
>>> have experience with some jpa solution in bigger projects?
>>>
>>> Please share some stories to make my decision easier.
>>>
>>> Borut
>>>
>>> >
>>> > Christian
>>> >
>>> > Am 19.04.2012 15:56, schrieb Borut Bolčina:
>>> >> Thanks Christian,
>>> >>
>>> >> I understand now what you were suggesting. The database type (vendor)
>>> will be the same in all environments (mysql), but with different addresses,
>>> engine types, usernames and passwords, which brings another topic up -
>>> configuration (I will probably ask this in days to come).
>>> >>
>>> >> I will be separating datasources, it is just the case that I want a
>>> working solution and then smooth it out.
>>> >>
>>> >> For a begginer it is very hard to get a hibernate mysql combo to work
>>> (mine still does not). There are examples for persistence, but I had to
>>> read a lot until I found that Hibernate does not even has bundles,
>>> therefore tricks has to be performed.
>>> >>
>>> >> Is there "an official Karaf Hibernate Feature"? If not, what is the
>>> suggested way to run Hibernate in Karaf? I am planning to use Hibernate
>>> Search, Solr and Lucene by using Camel components, so I have lots of ground
>>> to cover.
>>> >>
>>> >> Cheers,
>>> >> borut
>>> >>
>>> >
>>> > --
>>> > Christian Schneider
>>> > http://www.liquid-reality.de
>>> >
>>> > Open Source Architect
>>> > Talend Application Integration Division http://www.talend.com
>>> >
>>>
>>
>>
>

Re: Deploying data sources

Posted by Borut Bolčina <bo...@gmail.com>.
Hello,

thanks Bengt for your input, I really appreciate you took the time!

My work on this is somehow sporadic, but now I have managed to get the
Camel route running in Karaf

from("quartz://weather/currentWeatherSlovenia?cron=0+0/1+*+?+*+*")
 .log("Getting weather from: " + sourceUrl)
.to(sourceUrl)
 .split()
.tokenizeXML("metData")
 .unmarshal(jaxbDataFormat)
.to("jpa:com.mycompany.weather.entities.WeatherCurrent?persistenceUnit=weather");

with the exception of saving the data to the database which fails with:

Caused by: <openjpa-2.2.0-r422266:1244990 fatal user error>
org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or
DataSource class name must be specified in
the ConnectionDriverName property. Available properties in configuration
are "org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl@442ce698".
        at
org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)[125:org.apache.openjpa:2.2.0]
        at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:844)[125:org.apache.openjpa:2.2.0]
        at
org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:602)[125:org.apache.openjpa:2.2.0]
        at
org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1510)[125:org.apache.openjpa:2.2.0]
        at
org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:518)[125:org.apache.openjpa:2.2.0]
....

My datasource bundle is deployed in OSGi (later the username and password
will be configurable, that is - outside of the bundle)

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">

 <bean id="weatherDataSource"
class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
<property name="url"
 value="jdbc:mysql://
dev.mycompany.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8"
/>
 <property name="user" value="myUsername" />
<property name="password" value="myPassword" />
 </bean>

<service interface="javax.sql.DataSource" ref="weatherDataSource">
 <service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/mysqlds" />
 </service-properties>
</service>
 </blueprint>

which is used by my model bundle's persistence.xml

<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
 <persistence-unit name="weather" transaction-type="JTA">
 <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name
=jdbc/mysqlds)</jta-data-source>
 <class>my.company.weather.entities.WeatherCurrent</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
 </persistence-unit>
</persistence>

I think the problem is that my model bundle is not seeing the datasource
service. How do I confirm that or how should my model's  MANIFEST look like?

Cheers,
borut


Dne 19. april 2012 20:35 je Bengt Rodehav <be...@rodehav.com> napisal/-a:

> A few years back Hibernate was my choice. The past two years I have moved
> to OpenJPA. The main reason is that OpenJPA works much better with OSGi. I
> did try EclipseLink as well but had OSGi problems. This was a while back
> and has probably been improved by now.
>
> Another reason why I prefer OpenJPA to Hibernate is that the Apache
> community is so much better - much more open. I'm sure this is a matter of
> taste but I would not go for Hibernate.
>
> That said, OpenJPA also has some classloading issues under OSGi. In normal
> situations it works though. A final compelling reason to use OpenJPA is
> that it is much more common choice when using Apache Karaf (I think). It's
> normally easier to use different Apache projects together since someone
> else has always done it before.
>
> What I don't like is the way JPA uses the persistence.xml. I tend to go
> with the approach Christian recommended - to put the datasource in a
> separate bundle. It can then easily be switched. In practice, though, it's
> hard to actually change database type (not just url) without having to
> affect the application.
>
> First, the JPA implementation is configured in persistence.xml. E g that's
> where you specify database dialect for OpenJPA. Ideally this would be
> separated from the persistence.xml and possible to configure (e g with
> OSGi's config admin).
>
> Second, at least when using JPA annotations (which I do), your source code
> becomes tailored for a certain database type. I often startup with a simple
> Derby database for testing and then move  to SQLServer for production. In
> that process I often have to change some annotations to make it work in
> SQLServer.
>
> Overall I'm quite content with the OpenJPA+Aries+Karaf combo though. I
> just wish that Aries could get their release process straightened out soon.
>
> /Bengt
>
>
> 2012/4/19 Borut Bolcina <bo...@gmail.com>
>
>> On 19. apr. 2012, at 16:11, Christian Schneider <ch...@die-schneider.net>
>> wrote:
>>
>> > I guess the suggested way is to not run hibernate :-) For me the fact
>> that they do not create bundles says that jboss does not care about OSGi in
>> hibernate. As they now have an OSGi server with JBoss 7 that may change
>> soon though.
>>
>> I just looked at JBoss website and their support is not even in dipers.
>> See https://issues.jboss.org/browse/JBOSGI-260.
>>
>> > I had some good experience with apache openjpa together with apache
>> aries jpa. Together they solve the classloading problem where the jpa
>> provider can not see the user classes. I have not built bigger applications
>> with it though.
>>
>> I will try with OpenJPA, but would really like to hear other people's
>> hibernate stories!
>>
>> >
>> > There is also Eclipselink. With their affiliation to Eclipse they will
>> surely have an eye on OSGi compatibility. The problem there was that they
>> did not put their jas into the maven central repo.
>> >
>> > So all in all I am not sure what to recommend. Perhaps others already
>> have experience with some jpa solution in bigger projects?
>>
>> Please share some stories to make my decision easier.
>>
>> Borut
>>
>> >
>> > Christian
>> >
>> > Am 19.04.2012 15:56, schrieb Borut Bolčina:
>> >> Thanks Christian,
>> >>
>> >> I understand now what you were suggesting. The database type (vendor)
>> will be the same in all environments (mysql), but with different addresses,
>> engine types, usernames and passwords, which brings another topic up -
>> configuration (I will probably ask this in days to come).
>> >>
>> >> I will be separating datasources, it is just the case that I want a
>> working solution and then smooth it out.
>> >>
>> >> For a begginer it is very hard to get a hibernate mysql combo to work
>> (mine still does not). There are examples for persistence, but I had to
>> read a lot until I found that Hibernate does not even has bundles,
>> therefore tricks has to be performed.
>> >>
>> >> Is there "an official Karaf Hibernate Feature"? If not, what is the
>> suggested way to run Hibernate in Karaf? I am planning to use Hibernate
>> Search, Solr and Lucene by using Camel components, so I have lots of ground
>> to cover.
>> >>
>> >> Cheers,
>> >> borut
>> >>
>> >
>> > --
>> > Christian Schneider
>> > http://www.liquid-reality.de
>> >
>> > Open Source Architect
>> > Talend Application Integration Division http://www.talend.com
>> >
>>
>
>

Re: Deploying data sources

Posted by Bengt Rodehav <be...@rodehav.com>.
A few years back Hibernate was my choice. The past two years I have moved
to OpenJPA. The main reason is that OpenJPA works much better with OSGi. I
did try EclipseLink as well but had OSGi problems. This was a while back
and has probably been improved by now.

Another reason why I prefer OpenJPA to Hibernate is that the Apache
community is so much better - much more open. I'm sure this is a matter of
taste but I would not go for Hibernate.

That said, OpenJPA also has some classloading issues under OSGi. In normal
situations it works though. A final compelling reason to use OpenJPA is
that it is much more common choice when using Apache Karaf (I think). It's
normally easier to use different Apache projects together since someone
else has always done it before.

What I don't like is the way JPA uses the persistence.xml. I tend to go
with the approach Christian recommended - to put the datasource in a
separate bundle. It can then easily be switched. In practice, though, it's
hard to actually change database type (not just url) without having to
affect the application.

First, the JPA implementation is configured in persistence.xml. E g that's
where you specify database dialect for OpenJPA. Ideally this would be
separated from the persistence.xml and possible to configure (e g with
OSGi's config admin).

Second, at least when using JPA annotations (which I do), your source code
becomes tailored for a certain database type. I often startup with a simple
Derby database for testing and then move  to SQLServer for production. In
that process I often have to change some annotations to make it work in
SQLServer.

Overall I'm quite content with the OpenJPA+Aries+Karaf combo though. I just
wish that Aries could get their release process straightened out soon.

/Bengt


2012/4/19 Borut Bolcina <bo...@gmail.com>

> On 19. apr. 2012, at 16:11, Christian Schneider <ch...@die-schneider.net>
> wrote:
>
> > I guess the suggested way is to not run hibernate :-) For me the fact
> that they do not create bundles says that jboss does not care about OSGi in
> hibernate. As they now have an OSGi server with JBoss 7 that may change
> soon though.
>
> I just looked at JBoss website and their support is not even in dipers.
> See https://issues.jboss.org/browse/JBOSGI-260.
>
> > I had some good experience with apache openjpa together with apache
> aries jpa. Together they solve the classloading problem where the jpa
> provider can not see the user classes. I have not built bigger applications
> with it though.
>
> I will try with OpenJPA, but would really like to hear other people's
> hibernate stories!
>
> >
> > There is also Eclipselink. With their affiliation to Eclipse they will
> surely have an eye on OSGi compatibility. The problem there was that they
> did not put their jas into the maven central repo.
> >
> > So all in all I am not sure what to recommend. Perhaps others already
> have experience with some jpa solution in bigger projects?
>
> Please share some stories to make my decision easier.
>
> Borut
>
> >
> > Christian
> >
> > Am 19.04.2012 15:56, schrieb Borut Bolčina:
> >> Thanks Christian,
> >>
> >> I understand now what you were suggesting. The database type (vendor)
> will be the same in all environments (mysql), but with different addresses,
> engine types, usernames and passwords, which brings another topic up -
> configuration (I will probably ask this in days to come).
> >>
> >> I will be separating datasources, it is just the case that I want a
> working solution and then smooth it out.
> >>
> >> For a begginer it is very hard to get a hibernate mysql combo to work
> (mine still does not). There are examples for persistence, but I had to
> read a lot until I found that Hibernate does not even has bundles,
> therefore tricks has to be performed.
> >>
> >> Is there "an official Karaf Hibernate Feature"? If not, what is the
> suggested way to run Hibernate in Karaf? I am planning to use Hibernate
> Search, Solr and Lucene by using Camel components, so I have lots of ground
> to cover.
> >>
> >> Cheers,
> >> borut
> >>
> >
> > --
> > Christian Schneider
> > http://www.liquid-reality.de
> >
> > Open Source Architect
> > Talend Application Integration Division http://www.talend.com
> >
>

Re: Deploying data sources

Posted by Borut Bolcina <bo...@gmail.com>.
On 19. apr. 2012, at 16:11, Christian Schneider <ch...@die-schneider.net> wrote:

> I guess the suggested way is to not run hibernate :-) For me the fact that they do not create bundles says that jboss does not care about OSGi in hibernate. As they now have an OSGi server with JBoss 7 that may change soon though.

I just looked at JBoss website and their support is not even in dipers. See https://issues.jboss.org/browse/JBOSGI-260. 

> I had some good experience with apache openjpa together with apache aries jpa. Together they solve the classloading problem where the jpa provider can not see the user classes. I have not built bigger applications with it though.

I will try with OpenJPA, but would really like to hear other people's hibernate stories!

> 
> There is also Eclipselink. With their affiliation to Eclipse they will surely have an eye on OSGi compatibility. The problem there was that they did not put their jas into the maven central repo.
> 
> So all in all I am not sure what to recommend. Perhaps others already have experience with some jpa solution in bigger projects?

Please share some stories to make my decision easier.

Borut

> 
> Christian
> 
> Am 19.04.2012 15:56, schrieb Borut Bolčina:
>> Thanks Christian,
>> 
>> I understand now what you were suggesting. The database type (vendor) will be the same in all environments (mysql), but with different addresses, engine types, usernames and passwords, which brings another topic up - configuration (I will probably ask this in days to come).
>> 
>> I will be separating datasources, it is just the case that I want a working solution and then smooth it out.
>> 
>> For a begginer it is very hard to get a hibernate mysql combo to work (mine still does not). There are examples for persistence, but I had to read a lot until I found that Hibernate does not even has bundles, therefore tricks has to be performed.
>> 
>> Is there "an official Karaf Hibernate Feature"? If not, what is the suggested way to run Hibernate in Karaf? I am planning to use Hibernate Search, Solr and Lucene by using Camel components, so I have lots of ground to cover.
>> 
>> Cheers,
>> borut
>> 
> 
> -- 
> Christian Schneider
> http://www.liquid-reality.de
> 
> Open Source Architect
> Talend Application Integration Division http://www.talend.com
> 

Re: Deploying data sources

Posted by Christian Schneider <ch...@die-schneider.net>.
I guess the suggested way is to not run hibernate :-) For me the fact 
that they do not create bundles says that jboss does not care about OSGi 
in hibernate. As they now have an OSGi server with JBoss 7 that may 
change soon though.

I had some good experience with apache openjpa together with apache 
aries jpa. Together they solve the classloading problem where the jpa 
provider can not see the user classes. I have not built bigger 
applications with it though.

There is also Eclipselink. With their affiliation to Eclipse they will 
surely have an eye on OSGi compatibility. The problem there was that 
they did not put their jas into the maven central repo.

So all in all I am not sure what to recommend. Perhaps others already 
have experience with some jpa solution in bigger projects?

Christian

Am 19.04.2012 15:56, schrieb Borut Bolčina:
> Thanks Christian,
>
> I understand now what you were suggesting. The database type (vendor) 
> will be the same in all environments (mysql), but with different 
> addresses, engine types, usernames and passwords, which brings another 
> topic up - configuration (I will probably ask this in days to come).
>
> I will be separating datasources, it is just the case that I want a 
> working solution and then smooth it out.
>
> For a begginer it is very hard to get a hibernate mysql combo to work 
> (mine still does not). There are examples for persistence, but I had 
> to read a lot until I found that Hibernate does not even has bundles, 
> therefore tricks has to be performed.
>
> Is there "an official Karaf Hibernate Feature"? If not, what is the 
> suggested way to run Hibernate in Karaf? I am planning to use 
> Hibernate Search, Solr and Lucene by using Camel components, so I have 
> lots of ground to cover.
>
> Cheers,
> borut
>

-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
Talend Application Integration Division http://www.talend.com


Re: Deploying data sources

Posted by Borut Bolčina <bo...@gmail.com>.
Thanks Christian,

I understand now what you were suggesting. The database type (vendor) will
be the same in all environments (mysql), but with different addresses,
engine types, usernames and passwords, which brings another topic up -
configuration (I will probably ask this in days to come).

I will be separating datasources, it is just the case that I want a working
solution and then smooth it out.

For a begginer it is very hard to get a hibernate mysql combo to work (mine
still does not). There are examples for persistence, but I had to read a
lot until I found that Hibernate does not even has bundles, therefore
tricks has to be performed.

Is there "an official Karaf Hibernate Feature"? If not, what is the
suggested way to run Hibernate in Karaf? I am planning to use Hibernate
Search, Solr and Lucene by using Camel components, so I have lots of ground
to cover.

Cheers,
borut

On 18. apr. 2012, at 09:05, Christian Schneider <ch...@die-schneider.net>
wrote:

If you define the datasource outside the bundle you avoid that the bundle
has to know the driver class. I guess in your solution you have a
dependency to the db driver. As you only define the driver in the blueprint
xml the dependency is maybe just an import package statement the bundle
plugin adds. Still your bundle is tightly coupled to the db type used.

So as long as you do not plan to change the db or have different db types
in dev and prod you should be fine.

Christian

2012/4/16 Borut Bolčina <bo...@gmail.com>

> I am trying to understand the separation here.
>
> My Camel route has no referenece to where the objects are to be persisted.
> The accompanying persistence.xml in route's bundle is using jta data source
> as osgi service which is (for now) defined in route's blueprint and is also
> configurable via admin service. So I can (in theory) stop the route, change
> the properties (connection to the database), start the route.
>
> What is this another layer of abstraction you are talking about? Can you
> show me on my example please?
>
> -borut
>
>
> Dne 16. april 2012 15:56 je Christian Schneider <ch...@die-schneider.net>napisal/-a:
>
> Absolutely. The nice thing with extracting the datasource to a service is
>> that your route bundle has no dependency to the database driver. So this
>> makes it easier to for example have different database systems in dev and
>> test. In general it supports the idea of having to know as few things about
>> your environment as possible. In fact I think this idea is what makes OSGi
>> so appealing.
>>
>> Christian
>>
>>
>> 2012/4/16 Jean-Baptiste Onofré <jb...@nanthrax.net>
>>
>>> The way that you did work too ;)
>>>
>>> I would prefer a better separation (the Camel route should use a service
>>> reference to the datasource).
>>>
>>> Regards
>>> JB
>>>
>>>
>>> On 04/16/2012 03:17 PM, Borut Bolčina wrote:
>>>
>>>> OK, to make a first step which doesn't involve creating a separate
>>>> bundle for datasource, but instead adding a datasource configuration
>>>> directly to my Camel route bundle's blueprint.xml:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <blueprint xmlns="http://www.osgi.org/**xmlns/blueprint/v1.0.0<http://www.osgi.org/xmlns/blueprint/v1.0.0>
>>>> "
>>>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>>>> "
>>>> xmlns:cm="http://aries.apache.**org/blueprint/xmlns/blueprint-**
>>>> cm/v1.1.0 <http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0>
>>>> "
>>>> xsi:schemaLocation="
>>>> ... ">
>>>> <cm:property-placeholder persistent-id="WeatherCurrent"
>>>> update-strategy="reload">
>>>> <cm:default-properties>
>>>> <cm:property name="sourceUrl"
>>>> value="http://meteo.arso.gov.**si/uploads/probase/www/observ/**
>>>> surface/text/sl/observation_**si_latest.xml<http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml>
>>>> "
>>>> />
>>>> <cm:property name="weatherDbConnectionUrl"
>>>> value="jdbc:mysql://my.**company.com:3306/weather?**useUnicode=yes&amp;
>>>> **characterEncoding=UTF-8<http://my.company.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>>>  <http://my.company.com:3306/**weather?useUnicode=yes&amp;**
>>>> characterEncoding=UTF-8<http://my.company.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>>> >"
>>>>
>>>> />
>>>> <cm:property name="weatherDbUser" value="testUser" />
>>>> <cm:property name="weatherDbPassword" value="testPass" />
>>>> </cm:default-properties>
>>>> </cm:property-placeholder>
>>>> <bean id="dataSource" class="com.mysql.jdbc.jdbc2.**
>>>> optional.MysqlDataSource">
>>>> <property name="url" value="${**weatherDbConnectionUrl}"/>
>>>> <property name="user" value="${weatherDbUser}"/>
>>>> <property name="password" value="${weatherDbPassword}"/>
>>>> </bean>
>>>> <service interface="javax.sql.**DataSource" ref="dataSource">
>>>> <service-properties>
>>>> <entry key="osgi.jndi.service.name <http://osgi.jndi.service.name**>"
>>>>
>>>> value="jdbc/mysqlds"/>
>>>> </service-properties>
>>>> </service>
>>>>
>>>> <bean id="**weatherCurrentRouteBuilder"
>>>> class="com.mycompany.route.**weather.**WeatherCurrentRouteBuilder"
>>>> init-method="refresh">
>>>> <property name="sourceUrl" value="${sourceUrl}"></**property>
>>>> </bean>
>>>>
>>>> <camelContext id="weather-forecast"
>>>> xmlns="http://camel.apache.**org/schema/blueprint<http://camel.apache.org/schema/blueprint>
>>>> ">
>>>> <routeBuilder ref="**weatherCurrentRouteBuilder" />
>>>> </camelContext>
>>>>
>>>> </blueprint>
>>>>
>>>>
>>>> and the configuration file weather.cfg
>>>>
>>>> sourceUrl=http://meteo.arso.**gov.si/uploads/probase/www/**
>>>> observ/surface/text/sl/**observation_si_latest.xml<http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml>
>>>> weatherDbConnectionUrl=jdbc:**mysql://my.comapny.com:3306/**
>>>> weather?useUnicode=yes&amp;**characterEncoding=UTF-8<http://my.comapny.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>>>  <http://my.comapny.com:3306/**weather?useUnicode=yes&amp;**
>>>> characterEncoding=UTF-8<http://my.comapny.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>>> >
>>>>
>>>> weatherDbUser=testUser
>>>> weatherDbPassword=testPass
>>>>
>>>> and the persistence.xml
>>>>
>>>> <persistence xmlns="http://java.sun.com/**xml/ns/persistence<http://java.sun.com/xml/ns/persistence>
>>>> "
>>>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>>>> "
>>>> version="1.0">
>>>>
>>>> <persistence-unit name="weather" transaction-type="JTA">
>>>> <provider>org.hibernate.ejb.**HibernatePersistence</**provider>
>>>> <jta-data-source>osgi:service/**javax.sql.DataSource/(osgi.**
>>>> jndi.service.name <http://osgi.jndi.service.name>
>>>> <http://osgi.jndi.service.name**>=jdbc/mysqlds)</jta-data-**source>
>>>>
>>>> <class>my.company.model.**entities.weather.**WeatherCurrent</class>
>>>> <exclude-unlisted-classes>**true</exclude-unlisted-**classes>
>>>> <properties>
>>>> <property name="hibernate.show_sql" value="true"/>
>>>> <property name="hibernate.format_sql" value="true"/>
>>>> </properties>
>>>> </persistence-unit>
>>>> </persistence>
>>>>
>>>> and features bundle which installs configuration and drivers besides my
>>>> camel route:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <features xmlns="http://karaf.apache.**org/xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>>> "
>>>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>>>> "
>>>> xsi:schemaLocation="http://**karaf.apache.org/xmlns/**features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>>> http://karaf.apache.org/xmlns/**features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>>> ">
>>>>
>>>> <feature name="weather" version="${pom.version}">
>>>> <bundle>mvn:mvn:org.apache.**servicemix.specs/org.apache.**
>>>> servicemix.specs.stax-api-1.0/**1.9.0</bundle>
>>>> <bundle>mvn:mvn:mysql/mysql-**connector-java/5.1.18</bundle>
>>>> <bundle>mvn:my.company/route-**weather-current/${pom.version}**
>>>> </bundle>
>>>> <configfile
>>>> finalname="/etc/weather.cfg">**mvn:my.company/features-**
>>>> weather/${pom.version}/cfg</**configfile>
>>>> </feature>
>>>>
>>>> </features>
>>>>
>>>>
>>>> Am I heading the right way or am I on the Titanic's route?
>>>>
>>>> Cheers,
>>>> borut
>>>>
>>>>
>>>> Dne 16. april 2012 14:51 je Jean-Baptiste Onofré <jb@nanthrax.net
>>>> <ma...@nanthrax.net>> napisal/-a:
>>>>
>>>>
>>>>    Username/password/URL could be in <cm:properties/> and so handle in
>>>>    the "application" config oriented file in etc.
>>>>
>>>>    Regards
>>>>    JB
>>>>
>>>>
>>>>    On 04/16/2012 02:47 PM, Christian Schneider wrote:
>>>>
>>>>        I would simply deploy the blueprint xml by hand. Just treat it
>>>>        like a
>>>>        config file you would have to add.
>>>>        This is of course not everyone´s favorite style.
>>>>
>>>>        The problem with adding the blueprint to the feature is that it
>>>>        would
>>>>        have to be in the maven repo. As the username and password are
>>>>        in this
>>>>        file this is not recommended.
>>>>
>>>>        So another way to achieve what I did is separate the things that
>>>>        should
>>>>        be configured per server or stage from the things that keep the
>>>>        same like
>>>>        driver class name. You could use the config admin service in the
>>>>        blueprint file to move the username / password to a separate
>>>>        config file.
>>>>        This would make the whole thing a bit more complex though but
>>>>        you could
>>>>        then safely put the blueprint file into a feature.
>>>>
>>>>        Christian
>>>>
>>>>
>>>>        2012/4/16 Borut Bolčina <borut.bolcina@gmail.com
>>>>        <mailto:borut.bolcina@gmail.**com <bo...@gmail.com>>
>>>>        <mailto:borut.bolcina@gmail.__**com <mailto:borut.bolcina@gmail.
>>>> **com <bo...@gmail.com>>>>
>>>>
>>>>
>>>>
>>>>            Hello,
>>>>
>>>>            my first post here, so bare with me please - newbie on board.
>>>>
>>>>            I am trying to deploy my first camel route to Karaf and this
>>>>        route
>>>>            must be configurable (html address) and must persist some
>>>>        data with
>>>>            jpa component. This route is happily persisting in my test
>>>>        (outside
>>>>            osgi container).
>>>>
>>>>            Now I am reading
>>>>        https://github.com/cschneider/**__Karaf-Tutorial/blob/master/**
>>>> db/__datasource/datasource-**mysql.__xml<https://github.com/cschneider/__Karaf-Tutorial/blob/master/db/__datasource/datasource-mysql.__xml>
>>>>
>>>>        <https://github.com/**cschneider/Karaf-Tutorial/**
>>>> blob/master/db/datasource/**datasource-mysql.xml<https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-mysql.xml>
>>>> >
>>>>        where
>>>>            it says I should copy the file to Karaf's deploy folder.
>>>>
>>>>            And the question: What is the practice of deploying data
>>>>        sources?
>>>>            Should I create a features project which includes a
>>>>        blueprint for my
>>>>            route's data source?
>>>>
>>>>            Let's say my route needs connection to mysql database, so the
>>>>            feature project would include features.xml
>>>>
>>>>        <?xml version="1.0" encoding="UTF-8"?>
>>>>        <features xmlns="http://karaf.apache.__**
>>>> org/xmlns/features/v1.0.0
>>>>        <http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>>> >"
>>>>            xmlns:xsi="http://www.w3.org/_**_2001/XMLSchema-instance<http://www.w3.org/__2001/XMLSchema-instance>
>>>>        <http://www.w3.org/2001/**XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>>>> >"
>>>>
>>>>          xsi:schemaLocation="http://__k**araf.apache.org/xmlns/__**
>>>> features/v1.0.0 <http://karaf.apache.org/xmlns/__features/v1.0.0> <
>>>> http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>>> >
>>>>        http://karaf.apache.org/xmlns/**__features/v1.0.0<http://karaf.apache.org/xmlns/__features/v1.0.0>
>>>>
>>>>        <http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>>> >">
>>>>
>>>>        <feature name="weather" version="${pom.version}">
>>>>        <bundle>mvn:mvn:org.apache.__**servicemix.specs/org.apache.__**
>>>> servicemix.specs.stax-api-1.0/**__1.9.0</bundle>
>>>>        <bundle>mvn:mvn:mysql/mysql-__**connector-java/5.1.18</bundle>
>>>>        <bundle>mvn:my.company/route-_**_weather-current/${pom.**
>>>> version}__</bundle>
>>>>
>>>>            *<bundle>my datasource blueprint</bundle>*
>>>>
>>>>        <configfile
>>>>
>>>>          finalname="/etc/weather.cfg">_**_mvn:my.company/features-__**
>>>> weather/${pom.version}/cfg</__**configfile>
>>>>
>>>>        </feature>
>>>>        </features>
>>>>
>>>>            I guess then the only command to install my Camel route to
>>>> Karaf
>>>>            would then be feature:install and all the dependencies
>>>> including
>>>>            datasource and configuration would be installed before. And
>>>>        how to
>>>>            package the "my datasource blueprint"?
>>>>
>>>>            Or is there some other practice?
>>>>
>>>>            Thanks,
>>>>            borut
>>>>
>>>>
>>>>
>>>>    --
>>>>    Jean-Baptiste Onofré
>>>>    jbonofre@apache.org <ma...@apache.org>
>>>>
>>>>    http://blog.nanthrax.net
>>>>    Talend - http://www.talend.com
>>>>
>>>>
>>>>
>>> --
>>> Jean-Baptiste Onofré
>>> jbonofre@apache.org
>>> http://blog.nanthrax.net
>>> Talend - http://www.talend.com
>>>
>>
>>
>

Re: Deploying data sources

Posted by Christian Schneider <ch...@die-schneider.net>.
If you define the datasource outside the bundle you avoid that the bundle
has to know the driver class. I guess in your solution you have a
dependency to the db driver. As you only define the driver in the blueprint
xml the dependency is maybe just an import package statement the bundle
plugin adds. Still your bundle is tightly coupled to the db type used.

So as long as you do not plan to change the db or have different db types
in dev and prod you should be fine.

Christian

2012/4/16 Borut Bolčina <bo...@gmail.com>

> I am trying to understand the separation here.
>
> My Camel route has no referenece to where the objects are to be persisted.
> The accompanying persistence.xml in route's bundle is using jta data source
> as osgi service which is (for now) defined in route's blueprint and is also
> configurable via admin service. So I can (in theory) stop the route, change
> the properties (connection to the database), start the route.
>
> What is this another layer of abstraction you are talking about? Can you
> show me on my example please?
>
> -borut
>
>
> Dne 16. april 2012 15:56 je Christian Schneider <ch...@die-schneider.net>napisal/-a:
>
> Absolutely. The nice thing with extracting the datasource to a service is
>> that your route bundle has no dependency to the database driver. So this
>> makes it easier to for example have different database systems in dev and
>> test. In general it supports the idea of having to know as few things about
>> your environment as possible. In fact I think this idea is what makes OSGi
>> so appealing.
>>
>> Christian
>>
>>
>> 2012/4/16 Jean-Baptiste Onofré <jb...@nanthrax.net>
>>
>>> The way that you did work too ;)
>>>
>>> I would prefer a better separation (the Camel route should use a service
>>> reference to the datasource).
>>>
>>> Regards
>>> JB
>>>
>>>
>>> On 04/16/2012 03:17 PM, Borut Bolčina wrote:
>>>
>>>> OK, to make a first step which doesn't involve creating a separate
>>>> bundle for datasource, but instead adding a datasource configuration
>>>> directly to my Camel route bundle's blueprint.xml:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <blueprint xmlns="http://www.osgi.org/**xmlns/blueprint/v1.0.0<http://www.osgi.org/xmlns/blueprint/v1.0.0>
>>>> "
>>>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>>>> "
>>>> xmlns:cm="http://aries.apache.**org/blueprint/xmlns/blueprint-**
>>>> cm/v1.1.0 <http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0>
>>>> "
>>>> xsi:schemaLocation="
>>>> ... ">
>>>> <cm:property-placeholder persistent-id="WeatherCurrent"
>>>> update-strategy="reload">
>>>> <cm:default-properties>
>>>> <cm:property name="sourceUrl"
>>>> value="http://meteo.arso.gov.**si/uploads/probase/www/observ/**
>>>> surface/text/sl/observation_**si_latest.xml<http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml>
>>>> "
>>>> />
>>>> <cm:property name="weatherDbConnectionUrl"
>>>> value="jdbc:mysql://my.**company.com:3306/weather?**useUnicode=yes&amp;
>>>> **characterEncoding=UTF-8<http://my.company.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>>>  <http://my.company.com:3306/**weather?useUnicode=yes&amp;**
>>>> characterEncoding=UTF-8<http://my.company.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>>> >"
>>>>
>>>> />
>>>> <cm:property name="weatherDbUser" value="testUser" />
>>>> <cm:property name="weatherDbPassword" value="testPass" />
>>>> </cm:default-properties>
>>>> </cm:property-placeholder>
>>>> <bean id="dataSource" class="com.mysql.jdbc.jdbc2.**
>>>> optional.MysqlDataSource">
>>>> <property name="url" value="${**weatherDbConnectionUrl}"/>
>>>> <property name="user" value="${weatherDbUser}"/>
>>>> <property name="password" value="${weatherDbPassword}"/>
>>>> </bean>
>>>> <service interface="javax.sql.**DataSource" ref="dataSource">
>>>> <service-properties>
>>>> <entry key="osgi.jndi.service.name <http://osgi.jndi.service.name**>"
>>>>
>>>> value="jdbc/mysqlds"/>
>>>> </service-properties>
>>>> </service>
>>>>
>>>> <bean id="**weatherCurrentRouteBuilder"
>>>> class="com.mycompany.route.**weather.**WeatherCurrentRouteBuilder"
>>>> init-method="refresh">
>>>> <property name="sourceUrl" value="${sourceUrl}"></**property>
>>>> </bean>
>>>>
>>>> <camelContext id="weather-forecast"
>>>> xmlns="http://camel.apache.**org/schema/blueprint<http://camel.apache.org/schema/blueprint>
>>>> ">
>>>> <routeBuilder ref="**weatherCurrentRouteBuilder" />
>>>> </camelContext>
>>>>
>>>> </blueprint>
>>>>
>>>>
>>>> and the configuration file weather.cfg
>>>>
>>>> sourceUrl=http://meteo.arso.**gov.si/uploads/probase/www/**
>>>> observ/surface/text/sl/**observation_si_latest.xml<http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml>
>>>> weatherDbConnectionUrl=jdbc:**mysql://my.comapny.com:3306/**
>>>> weather?useUnicode=yes&amp;**characterEncoding=UTF-8<http://my.comapny.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>>>  <http://my.comapny.com:3306/**weather?useUnicode=yes&amp;**
>>>> characterEncoding=UTF-8<http://my.comapny.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>>> >
>>>>
>>>> weatherDbUser=testUser
>>>> weatherDbPassword=testPass
>>>>
>>>> and the persistence.xml
>>>>
>>>> <persistence xmlns="http://java.sun.com/**xml/ns/persistence<http://java.sun.com/xml/ns/persistence>
>>>> "
>>>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>>>> "
>>>> version="1.0">
>>>>
>>>> <persistence-unit name="weather" transaction-type="JTA">
>>>> <provider>org.hibernate.ejb.**HibernatePersistence</**provider>
>>>> <jta-data-source>osgi:service/**javax.sql.DataSource/(osgi.**
>>>> jndi.service.name <http://osgi.jndi.service.name>
>>>> <http://osgi.jndi.service.name**>=jdbc/mysqlds)</jta-data-**source>
>>>>
>>>> <class>my.company.model.**entities.weather.**WeatherCurrent</class>
>>>> <exclude-unlisted-classes>**true</exclude-unlisted-**classes>
>>>> <properties>
>>>> <property name="hibernate.show_sql" value="true"/>
>>>> <property name="hibernate.format_sql" value="true"/>
>>>> </properties>
>>>> </persistence-unit>
>>>> </persistence>
>>>>
>>>> and features bundle which installs configuration and drivers besides my
>>>> camel route:
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <features xmlns="http://karaf.apache.**org/xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>>> "
>>>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>>>> "
>>>> xsi:schemaLocation="http://**karaf.apache.org/xmlns/**features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>>> http://karaf.apache.org/xmlns/**features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>>> ">
>>>>
>>>> <feature name="weather" version="${pom.version}">
>>>> <bundle>mvn:mvn:org.apache.**servicemix.specs/org.apache.**
>>>> servicemix.specs.stax-api-1.0/**1.9.0</bundle>
>>>> <bundle>mvn:mvn:mysql/mysql-**connector-java/5.1.18</bundle>
>>>> <bundle>mvn:my.company/route-**weather-current/${pom.version}**
>>>> </bundle>
>>>> <configfile
>>>> finalname="/etc/weather.cfg">**mvn:my.company/features-**
>>>> weather/${pom.version}/cfg</**configfile>
>>>> </feature>
>>>>
>>>> </features>
>>>>
>>>>
>>>> Am I heading the right way or am I on the Titanic's route?
>>>>
>>>> Cheers,
>>>> borut
>>>>
>>>>
>>>> Dne 16. april 2012 14:51 je Jean-Baptiste Onofré <jb@nanthrax.net
>>>> <ma...@nanthrax.net>> napisal/-a:
>>>>
>>>>
>>>>    Username/password/URL could be in <cm:properties/> and so handle in
>>>>    the "application" config oriented file in etc.
>>>>
>>>>    Regards
>>>>    JB
>>>>
>>>>
>>>>    On 04/16/2012 02:47 PM, Christian Schneider wrote:
>>>>
>>>>        I would simply deploy the blueprint xml by hand. Just treat it
>>>>        like a
>>>>        config file you would have to add.
>>>>        This is of course not everyone´s favorite style.
>>>>
>>>>        The problem with adding the blueprint to the feature is that it
>>>>        would
>>>>        have to be in the maven repo. As the username and password are
>>>>        in this
>>>>        file this is not recommended.
>>>>
>>>>        So another way to achieve what I did is separate the things that
>>>>        should
>>>>        be configured per server or stage from the things that keep the
>>>>        same like
>>>>        driver class name. You could use the config admin service in the
>>>>        blueprint file to move the username / password to a separate
>>>>        config file.
>>>>        This would make the whole thing a bit more complex though but
>>>>        you could
>>>>        then safely put the blueprint file into a feature.
>>>>
>>>>        Christian
>>>>
>>>>
>>>>        2012/4/16 Borut Bolčina <borut.bolcina@gmail.com
>>>>        <mailto:borut.bolcina@gmail.**com <bo...@gmail.com>>
>>>>        <mailto:borut.bolcina@gmail.__**com <mailto:borut.bolcina@gmail.
>>>> **com <bo...@gmail.com>>>>
>>>>
>>>>
>>>>
>>>>            Hello,
>>>>
>>>>            my first post here, so bare with me please - newbie on board.
>>>>
>>>>            I am trying to deploy my first camel route to Karaf and this
>>>>        route
>>>>            must be configurable (html address) and must persist some
>>>>        data with
>>>>            jpa component. This route is happily persisting in my test
>>>>        (outside
>>>>            osgi container).
>>>>
>>>>            Now I am reading
>>>>        https://github.com/cschneider/**__Karaf-Tutorial/blob/master/**
>>>> db/__datasource/datasource-**mysql.__xml<https://github.com/cschneider/__Karaf-Tutorial/blob/master/db/__datasource/datasource-mysql.__xml>
>>>>
>>>>        <https://github.com/**cschneider/Karaf-Tutorial/**
>>>> blob/master/db/datasource/**datasource-mysql.xml<https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-mysql.xml>
>>>> >
>>>>        where
>>>>            it says I should copy the file to Karaf's deploy folder.
>>>>
>>>>            And the question: What is the practice of deploying data
>>>>        sources?
>>>>            Should I create a features project which includes a
>>>>        blueprint for my
>>>>            route's data source?
>>>>
>>>>            Let's say my route needs connection to mysql database, so the
>>>>            feature project would include features.xml
>>>>
>>>>        <?xml version="1.0" encoding="UTF-8"?>
>>>>        <features xmlns="http://karaf.apache.__**
>>>> org/xmlns/features/v1.0.0
>>>>        <http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>>> >"
>>>>            xmlns:xsi="http://www.w3.org/_**_2001/XMLSchema-instance<http://www.w3.org/__2001/XMLSchema-instance>
>>>>        <http://www.w3.org/2001/**XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>>>> >"
>>>>
>>>>          xsi:schemaLocation="http://__k**araf.apache.org/xmlns/__**
>>>> features/v1.0.0 <http://karaf.apache.org/xmlns/__features/v1.0.0> <
>>>> http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>>> >
>>>>        http://karaf.apache.org/xmlns/**__features/v1.0.0<http://karaf.apache.org/xmlns/__features/v1.0.0>
>>>>
>>>>        <http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>>> >">
>>>>
>>>>        <feature name="weather" version="${pom.version}">
>>>>        <bundle>mvn:mvn:org.apache.__**servicemix.specs/org.apache.__**
>>>> servicemix.specs.stax-api-1.0/**__1.9.0</bundle>
>>>>        <bundle>mvn:mvn:mysql/mysql-__**connector-java/5.1.18</bundle>
>>>>        <bundle>mvn:my.company/route-_**_weather-current/${pom.**
>>>> version}__</bundle>
>>>>
>>>>            *<bundle>my datasource blueprint</bundle>*
>>>>
>>>>        <configfile
>>>>
>>>>          finalname="/etc/weather.cfg">_**_mvn:my.company/features-__**
>>>> weather/${pom.version}/cfg</__**configfile>
>>>>
>>>>        </feature>
>>>>        </features>
>>>>
>>>>            I guess then the only command to install my Camel route to
>>>> Karaf
>>>>            would then be feature:install and all the dependencies
>>>> including
>>>>            datasource and configuration would be installed before. And
>>>>        how to
>>>>            package the "my datasource blueprint"?
>>>>
>>>>            Or is there some other practice?
>>>>
>>>>            Thanks,
>>>>            borut
>>>>
>>>>
>>>>
>>>>    --
>>>>    Jean-Baptiste Onofré
>>>>    jbonofre@apache.org <ma...@apache.org>
>>>>
>>>>    http://blog.nanthrax.net
>>>>    Talend - http://www.talend.com
>>>>
>>>>
>>>>
>>> --
>>> Jean-Baptiste Onofré
>>> jbonofre@apache.org
>>> http://blog.nanthrax.net
>>> Talend - http://www.talend.com
>>>
>>
>>
>

Re: Deploying data sources

Posted by Borut Bolčina <bo...@gmail.com>.
I am trying to understand the separation here.

My Camel route has no referenece to where the objects are to be persisted.
The accompanying persistence.xml in route's bundle is using jta data source
as osgi service which is (for now) defined in route's blueprint and is also
configurable via admin service. So I can (in theory) stop the route, change
the properties (connection to the database), start the route.

What is this another layer of abstraction you are talking about? Can you
show me on my example please?

-borut


Dne 16. april 2012 15:56 je Christian Schneider
<ch...@die-schneider.net>napisal/-a:

> Absolutely. The nice thing with extracting the datasource to a service is
> that your route bundle has no dependency to the database driver. So this
> makes it easier to for example have different database systems in dev and
> test. In general it supports the idea of having to know as few things about
> your environment as possible. In fact I think this idea is what makes OSGi
> so appealing.
>
> Christian
>
>
> 2012/4/16 Jean-Baptiste Onofré <jb...@nanthrax.net>
>
>> The way that you did work too ;)
>>
>> I would prefer a better separation (the Camel route should use a service
>> reference to the datasource).
>>
>> Regards
>> JB
>>
>>
>> On 04/16/2012 03:17 PM, Borut Bolčina wrote:
>>
>>> OK, to make a first step which doesn't involve creating a separate
>>> bundle for datasource, but instead adding a datasource configuration
>>> directly to my Camel route bundle's blueprint.xml:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <blueprint xmlns="http://www.osgi.org/**xmlns/blueprint/v1.0.0<http://www.osgi.org/xmlns/blueprint/v1.0.0>
>>> "
>>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>>> "
>>> xmlns:cm="http://aries.apache.**org/blueprint/xmlns/blueprint-**
>>> cm/v1.1.0 <http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0>"
>>> xsi:schemaLocation="
>>> ... ">
>>> <cm:property-placeholder persistent-id="WeatherCurrent"
>>> update-strategy="reload">
>>> <cm:default-properties>
>>> <cm:property name="sourceUrl"
>>> value="http://meteo.arso.gov.**si/uploads/probase/www/observ/**
>>> surface/text/sl/observation_**si_latest.xml<http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml>
>>> "
>>> />
>>> <cm:property name="weatherDbConnectionUrl"
>>> value="jdbc:mysql://my.**company.com:3306/weather?**useUnicode=yes&amp;*
>>> *characterEncoding=UTF-8<http://my.company.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>>  <http://my.company.com:3306/**weather?useUnicode=yes&amp;**
>>> characterEncoding=UTF-8<http://my.company.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>> >"
>>>
>>> />
>>> <cm:property name="weatherDbUser" value="testUser" />
>>> <cm:property name="weatherDbPassword" value="testPass" />
>>> </cm:default-properties>
>>> </cm:property-placeholder>
>>> <bean id="dataSource" class="com.mysql.jdbc.jdbc2.**
>>> optional.MysqlDataSource">
>>> <property name="url" value="${**weatherDbConnectionUrl}"/>
>>> <property name="user" value="${weatherDbUser}"/>
>>> <property name="password" value="${weatherDbPassword}"/>
>>> </bean>
>>> <service interface="javax.sql.**DataSource" ref="dataSource">
>>> <service-properties>
>>> <entry key="osgi.jndi.service.name <http://osgi.jndi.service.name**>"
>>>
>>> value="jdbc/mysqlds"/>
>>> </service-properties>
>>> </service>
>>>
>>> <bean id="**weatherCurrentRouteBuilder"
>>> class="com.mycompany.route.**weather.**WeatherCurrentRouteBuilder"
>>> init-method="refresh">
>>> <property name="sourceUrl" value="${sourceUrl}"></**property>
>>> </bean>
>>>
>>> <camelContext id="weather-forecast"
>>> xmlns="http://camel.apache.**org/schema/blueprint<http://camel.apache.org/schema/blueprint>
>>> ">
>>> <routeBuilder ref="**weatherCurrentRouteBuilder" />
>>> </camelContext>
>>>
>>> </blueprint>
>>>
>>>
>>> and the configuration file weather.cfg
>>>
>>> sourceUrl=http://meteo.arso.**gov.si/uploads/probase/www/**
>>> observ/surface/text/sl/**observation_si_latest.xml<http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml>
>>> weatherDbConnectionUrl=jdbc:**mysql://my.comapny.com:3306/**
>>> weather?useUnicode=yes&amp;**characterEncoding=UTF-8<http://my.comapny.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>>  <http://my.comapny.com:3306/**weather?useUnicode=yes&amp;**
>>> characterEncoding=UTF-8<http://my.comapny.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>>> >
>>>
>>> weatherDbUser=testUser
>>> weatherDbPassword=testPass
>>>
>>> and the persistence.xml
>>>
>>> <persistence xmlns="http://java.sun.com/**xml/ns/persistence<http://java.sun.com/xml/ns/persistence>
>>> "
>>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>>> "
>>> version="1.0">
>>>
>>> <persistence-unit name="weather" transaction-type="JTA">
>>> <provider>org.hibernate.ejb.**HibernatePersistence</**provider>
>>> <jta-data-source>osgi:service/**javax.sql.DataSource/(osgi.**
>>> jndi.service.name <http://osgi.jndi.service.name>
>>> <http://osgi.jndi.service.name**>=jdbc/mysqlds)</jta-data-**source>
>>>
>>> <class>my.company.model.**entities.weather.**WeatherCurrent</class>
>>> <exclude-unlisted-classes>**true</exclude-unlisted-**classes>
>>> <properties>
>>> <property name="hibernate.show_sql" value="true"/>
>>> <property name="hibernate.format_sql" value="true"/>
>>> </properties>
>>> </persistence-unit>
>>> </persistence>
>>>
>>> and features bundle which installs configuration and drivers besides my
>>> camel route:
>>>
>>> <?xml version="1.0" encoding="UTF-8"?>
>>> <features xmlns="http://karaf.apache.**org/xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>> "
>>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>>> "
>>> xsi:schemaLocation="http://**karaf.apache.org/xmlns/**features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>> http://karaf.apache.org/xmlns/**features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>> ">
>>>
>>> <feature name="weather" version="${pom.version}">
>>> <bundle>mvn:mvn:org.apache.**servicemix.specs/org.apache.**
>>> servicemix.specs.stax-api-1.0/**1.9.0</bundle>
>>> <bundle>mvn:mvn:mysql/mysql-**connector-java/5.1.18</bundle>
>>> <bundle>mvn:my.company/route-**weather-current/${pom.version}**</bundle>
>>> <configfile
>>> finalname="/etc/weather.cfg">**mvn:my.company/features-**
>>> weather/${pom.version}/cfg</**configfile>
>>> </feature>
>>>
>>> </features>
>>>
>>>
>>> Am I heading the right way or am I on the Titanic's route?
>>>
>>> Cheers,
>>> borut
>>>
>>>
>>> Dne 16. april 2012 14:51 je Jean-Baptiste Onofré <jb@nanthrax.net
>>> <ma...@nanthrax.net>> napisal/-a:
>>>
>>>
>>>    Username/password/URL could be in <cm:properties/> and so handle in
>>>    the "application" config oriented file in etc.
>>>
>>>    Regards
>>>    JB
>>>
>>>
>>>    On 04/16/2012 02:47 PM, Christian Schneider wrote:
>>>
>>>        I would simply deploy the blueprint xml by hand. Just treat it
>>>        like a
>>>        config file you would have to add.
>>>        This is of course not everyone´s favorite style.
>>>
>>>        The problem with adding the blueprint to the feature is that it
>>>        would
>>>        have to be in the maven repo. As the username and password are
>>>        in this
>>>        file this is not recommended.
>>>
>>>        So another way to achieve what I did is separate the things that
>>>        should
>>>        be configured per server or stage from the things that keep the
>>>        same like
>>>        driver class name. You could use the config admin service in the
>>>        blueprint file to move the username / password to a separate
>>>        config file.
>>>        This would make the whole thing a bit more complex though but
>>>        you could
>>>        then safely put the blueprint file into a feature.
>>>
>>>        Christian
>>>
>>>
>>>        2012/4/16 Borut Bolčina <borut.bolcina@gmail.com
>>>        <mailto:borut.bolcina@gmail.**com <bo...@gmail.com>>
>>>        <mailto:borut.bolcina@gmail.__**com <mailto:borut.bolcina@gmail.*
>>> *com <bo...@gmail.com>>>>
>>>
>>>
>>>
>>>            Hello,
>>>
>>>            my first post here, so bare with me please - newbie on board.
>>>
>>>            I am trying to deploy my first camel route to Karaf and this
>>>        route
>>>            must be configurable (html address) and must persist some
>>>        data with
>>>            jpa component. This route is happily persisting in my test
>>>        (outside
>>>            osgi container).
>>>
>>>            Now I am reading
>>>        https://github.com/cschneider/**__Karaf-Tutorial/blob/master/**
>>> db/__datasource/datasource-**mysql.__xml<https://github.com/cschneider/__Karaf-Tutorial/blob/master/db/__datasource/datasource-mysql.__xml>
>>>
>>>        <https://github.com/**cschneider/Karaf-Tutorial/**
>>> blob/master/db/datasource/**datasource-mysql.xml<https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-mysql.xml>
>>> >
>>>        where
>>>            it says I should copy the file to Karaf's deploy folder.
>>>
>>>            And the question: What is the practice of deploying data
>>>        sources?
>>>            Should I create a features project which includes a
>>>        blueprint for my
>>>            route's data source?
>>>
>>>            Let's say my route needs connection to mysql database, so the
>>>            feature project would include features.xml
>>>
>>>        <?xml version="1.0" encoding="UTF-8"?>
>>>        <features xmlns="http://karaf.apache.__**
>>> org/xmlns/features/v1.0.0
>>>        <http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>> >"
>>>            xmlns:xsi="http://www.w3.org/_**_2001/XMLSchema-instance<http://www.w3.org/__2001/XMLSchema-instance>
>>>        <http://www.w3.org/2001/**XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>>> >"
>>>
>>>          xsi:schemaLocation="http://__k**araf.apache.org/xmlns/__**
>>> features/v1.0.0 <http://karaf.apache.org/xmlns/__features/v1.0.0> <
>>> http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>> >
>>>        http://karaf.apache.org/xmlns/**__features/v1.0.0<http://karaf.apache.org/xmlns/__features/v1.0.0>
>>>
>>>        <http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>> >">
>>>
>>>        <feature name="weather" version="${pom.version}">
>>>        <bundle>mvn:mvn:org.apache.__**servicemix.specs/org.apache.__**
>>> servicemix.specs.stax-api-1.0/**__1.9.0</bundle>
>>>        <bundle>mvn:mvn:mysql/mysql-__**connector-java/5.1.18</bundle>
>>>        <bundle>mvn:my.company/route-_**_weather-current/${pom.**
>>> version}__</bundle>
>>>
>>>            *<bundle>my datasource blueprint</bundle>*
>>>
>>>        <configfile
>>>
>>>          finalname="/etc/weather.cfg">_**_mvn:my.company/features-__**
>>> weather/${pom.version}/cfg</__**configfile>
>>>
>>>        </feature>
>>>        </features>
>>>
>>>            I guess then the only command to install my Camel route to
>>> Karaf
>>>            would then be feature:install and all the dependencies
>>> including
>>>            datasource and configuration would be installed before. And
>>>        how to
>>>            package the "my datasource blueprint"?
>>>
>>>            Or is there some other practice?
>>>
>>>            Thanks,
>>>            borut
>>>
>>>
>>>
>>>    --
>>>    Jean-Baptiste Onofré
>>>    jbonofre@apache.org <ma...@apache.org>
>>>
>>>    http://blog.nanthrax.net
>>>    Talend - http://www.talend.com
>>>
>>>
>>>
>> --
>> Jean-Baptiste Onofré
>> jbonofre@apache.org
>> http://blog.nanthrax.net
>> Talend - http://www.talend.com
>>
>
>

Re: Deploying data sources

Posted by Christian Schneider <ch...@die-schneider.net>.
Absolutely. The nice thing with extracting the datasource to a service is
that your route bundle has no dependency to the database driver. So this
makes it easier to for example have different database systems in dev and
test. In general it supports the idea of having to know as few things about
your environment as possible. In fact I think this idea is what makes OSGi
so appealing.

Christian

2012/4/16 Jean-Baptiste Onofré <jb...@nanthrax.net>

> The way that you did work too ;)
>
> I would prefer a better separation (the Camel route should use a service
> reference to the datasource).
>
> Regards
> JB
>
>
> On 04/16/2012 03:17 PM, Borut Bolčina wrote:
>
>> OK, to make a first step which doesn't involve creating a separate
>> bundle for datasource, but instead adding a datasource configuration
>> directly to my Camel route bundle's blueprint.xml:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <blueprint xmlns="http://www.osgi.org/**xmlns/blueprint/v1.0.0<http://www.osgi.org/xmlns/blueprint/v1.0.0>
>> "
>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>> "
>> xmlns:cm="http://aries.apache.**org/blueprint/xmlns/blueprint-**cm/v1.1.0<http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0>
>> "
>> xsi:schemaLocation="
>> ... ">
>> <cm:property-placeholder persistent-id="WeatherCurrent"
>> update-strategy="reload">
>> <cm:default-properties>
>> <cm:property name="sourceUrl"
>> value="http://meteo.arso.gov.**si/uploads/probase/www/observ/**
>> surface/text/sl/observation_**si_latest.xml<http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml>
>> "
>> />
>> <cm:property name="weatherDbConnectionUrl"
>> value="jdbc:mysql://my.**company.com:3306/weather?**useUnicode=yes&amp;**
>> characterEncoding=UTF-8<http://my.company.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>> <http://my.company.com:3306/**weather?useUnicode=yes&amp;**
>> characterEncoding=UTF-8<http://my.company.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>> >"
>>
>> />
>> <cm:property name="weatherDbUser" value="testUser" />
>> <cm:property name="weatherDbPassword" value="testPass" />
>> </cm:default-properties>
>> </cm:property-placeholder>
>> <bean id="dataSource" class="com.mysql.jdbc.jdbc2.**
>> optional.MysqlDataSource">
>> <property name="url" value="${**weatherDbConnectionUrl}"/>
>> <property name="user" value="${weatherDbUser}"/>
>> <property name="password" value="${weatherDbPassword}"/>
>> </bean>
>> <service interface="javax.sql.**DataSource" ref="dataSource">
>> <service-properties>
>> <entry key="osgi.jndi.service.name <http://osgi.jndi.service.name**>"
>>
>> value="jdbc/mysqlds"/>
>> </service-properties>
>> </service>
>>
>> <bean id="**weatherCurrentRouteBuilder"
>> class="com.mycompany.route.**weather.**WeatherCurrentRouteBuilder"
>> init-method="refresh">
>> <property name="sourceUrl" value="${sourceUrl}"></**property>
>> </bean>
>>
>> <camelContext id="weather-forecast"
>> xmlns="http://camel.apache.**org/schema/blueprint<http://camel.apache.org/schema/blueprint>
>> ">
>> <routeBuilder ref="**weatherCurrentRouteBuilder" />
>> </camelContext>
>>
>> </blueprint>
>>
>>
>> and the configuration file weather.cfg
>>
>> sourceUrl=http://meteo.arso.**gov.si/uploads/probase/www/**
>> observ/surface/text/sl/**observation_si_latest.xml<http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml>
>> weatherDbConnectionUrl=jdbc:**mysql://my.comapny.com:3306/**
>> weather?useUnicode=yes&amp;**characterEncoding=UTF-8<http://my.comapny.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>> <http://my.comapny.com:3306/**weather?useUnicode=yes&amp;**
>> characterEncoding=UTF-8<http://my.comapny.com:3306/weather?useUnicode=yes&characterEncoding=UTF-8>
>> >
>>
>> weatherDbUser=testUser
>> weatherDbPassword=testPass
>>
>> and the persistence.xml
>>
>> <persistence xmlns="http://java.sun.com/**xml/ns/persistence<http://java.sun.com/xml/ns/persistence>
>> "
>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>> "
>> version="1.0">
>>
>> <persistence-unit name="weather" transaction-type="JTA">
>> <provider>org.hibernate.ejb.**HibernatePersistence</**provider>
>> <jta-data-source>osgi:service/**javax.sql.DataSource/(osgi.**
>> jndi.service.name <http://osgi.jndi.service.name>
>> <http://osgi.jndi.service.name**>=jdbc/mysqlds)</jta-data-**source>
>>
>> <class>my.company.model.**entities.weather.**WeatherCurrent</class>
>> <exclude-unlisted-classes>**true</exclude-unlisted-**classes>
>> <properties>
>> <property name="hibernate.show_sql" value="true"/>
>> <property name="hibernate.format_sql" value="true"/>
>> </properties>
>> </persistence-unit>
>> </persistence>
>>
>> and features bundle which installs configuration and drivers besides my
>> camel route:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <features xmlns="http://karaf.apache.**org/xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> "
>> xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>> "
>> xsi:schemaLocation="http://**karaf.apache.org/xmlns/**features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> http://karaf.apache.org/xmlns/**features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> ">
>>
>> <feature name="weather" version="${pom.version}">
>> <bundle>mvn:mvn:org.apache.**servicemix.specs/org.apache.**
>> servicemix.specs.stax-api-1.0/**1.9.0</bundle>
>> <bundle>mvn:mvn:mysql/mysql-**connector-java/5.1.18</bundle>
>> <bundle>mvn:my.company/route-**weather-current/${pom.version}**</bundle>
>> <configfile
>> finalname="/etc/weather.cfg">**mvn:my.company/features-**
>> weather/${pom.version}/cfg</**configfile>
>> </feature>
>>
>> </features>
>>
>>
>> Am I heading the right way or am I on the Titanic's route?
>>
>> Cheers,
>> borut
>>
>>
>> Dne 16. april 2012 14:51 je Jean-Baptiste Onofré <jb@nanthrax.net
>> <ma...@nanthrax.net>> napisal/-a:
>>
>>
>>    Username/password/URL could be in <cm:properties/> and so handle in
>>    the "application" config oriented file in etc.
>>
>>    Regards
>>    JB
>>
>>
>>    On 04/16/2012 02:47 PM, Christian Schneider wrote:
>>
>>        I would simply deploy the blueprint xml by hand. Just treat it
>>        like a
>>        config file you would have to add.
>>        This is of course not everyone´s favorite style.
>>
>>        The problem with adding the blueprint to the feature is that it
>>        would
>>        have to be in the maven repo. As the username and password are
>>        in this
>>        file this is not recommended.
>>
>>        So another way to achieve what I did is separate the things that
>>        should
>>        be configured per server or stage from the things that keep the
>>        same like
>>        driver class name. You could use the config admin service in the
>>        blueprint file to move the username / password to a separate
>>        config file.
>>        This would make the whole thing a bit more complex though but
>>        you could
>>        then safely put the blueprint file into a feature.
>>
>>        Christian
>>
>>
>>        2012/4/16 Borut Bolčina <borut.bolcina@gmail.com
>>        <mailto:borut.bolcina@gmail.**com <bo...@gmail.com>>
>>        <mailto:borut.bolcina@gmail.__**com <mailto:borut.bolcina@gmail.**
>> com <bo...@gmail.com>>>>
>>
>>
>>
>>            Hello,
>>
>>            my first post here, so bare with me please - newbie on board.
>>
>>            I am trying to deploy my first camel route to Karaf and this
>>        route
>>            must be configurable (html address) and must persist some
>>        data with
>>            jpa component. This route is happily persisting in my test
>>        (outside
>>            osgi container).
>>
>>            Now I am reading
>>        https://github.com/cschneider/**__Karaf-Tutorial/blob/master/**
>> db/__datasource/datasource-**mysql.__xml<https://github.com/cschneider/__Karaf-Tutorial/blob/master/db/__datasource/datasource-mysql.__xml>
>>
>>        <https://github.com/**cschneider/Karaf-Tutorial/**
>> blob/master/db/datasource/**datasource-mysql.xml<https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-mysql.xml>
>> >
>>        where
>>            it says I should copy the file to Karaf's deploy folder.
>>
>>            And the question: What is the practice of deploying data
>>        sources?
>>            Should I create a features project which includes a
>>        blueprint for my
>>            route's data source?
>>
>>            Let's say my route needs connection to mysql database, so the
>>            feature project would include features.xml
>>
>>        <?xml version="1.0" encoding="UTF-8"?>
>>        <features xmlns="http://karaf.apache.__**org/xmlns/features/v1.0.0
>>        <http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> >"
>>            xmlns:xsi="http://www.w3.org/_**_2001/XMLSchema-instance<http://www.w3.org/__2001/XMLSchema-instance>
>>        <http://www.w3.org/2001/**XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>> >"
>>
>>          xsi:schemaLocation="http://__k**araf.apache.org/xmlns/__**
>> features/v1.0.0 <http://karaf.apache.org/xmlns/__features/v1.0.0> <
>> http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> >
>>        http://karaf.apache.org/xmlns/**__features/v1.0.0<http://karaf.apache.org/xmlns/__features/v1.0.0>
>>
>>        <http://karaf.apache.org/**xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> >">
>>
>>        <feature name="weather" version="${pom.version}">
>>        <bundle>mvn:mvn:org.apache.__**servicemix.specs/org.apache.__**
>> servicemix.specs.stax-api-1.0/**__1.9.0</bundle>
>>        <bundle>mvn:mvn:mysql/mysql-__**connector-java/5.1.18</bundle>
>>        <bundle>mvn:my.company/route-_**_weather-current/${pom.**
>> version}__</bundle>
>>
>>            *<bundle>my datasource blueprint</bundle>*
>>
>>        <configfile
>>
>>          finalname="/etc/weather.cfg">_**_mvn:my.company/features-__**
>> weather/${pom.version}/cfg</__**configfile>
>>
>>        </feature>
>>        </features>
>>
>>            I guess then the only command to install my Camel route to
>> Karaf
>>            would then be feature:install and all the dependencies
>> including
>>            datasource and configuration would be installed before. And
>>        how to
>>            package the "my datasource blueprint"?
>>
>>            Or is there some other practice?
>>
>>            Thanks,
>>            borut
>>
>>
>>
>>    --
>>    Jean-Baptiste Onofré
>>    jbonofre@apache.org <ma...@apache.org>
>>
>>    http://blog.nanthrax.net
>>    Talend - http://www.talend.com
>>
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Re: Deploying data sources

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
The way that you did work too ;)

I would prefer a better separation (the Camel route should use a service 
reference to the datasource).

Regards
JB

On 04/16/2012 03:17 PM, Borut Bolčina wrote:
> OK, to make a first step which doesn't involve creating a separate
> bundle for datasource, but instead adding a datasource configuration
> directly to my Camel route bundle's blueprint.xml:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
> xsi:schemaLocation="
> ... ">
> <cm:property-placeholder persistent-id="WeatherCurrent"
> update-strategy="reload">
> <cm:default-properties>
> <cm:property name="sourceUrl"
> value="http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml"
> />
> <cm:property name="weatherDbConnectionUrl"
> value="jdbc:mysql://my.company.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8
> <http://my.company.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8>"
> />
> <cm:property name="weatherDbUser" value="testUser" />
> <cm:property name="weatherDbPassword" value="testPass" />
> </cm:default-properties>
> </cm:property-placeholder>
> <bean id="dataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
> <property name="url" value="${weatherDbConnectionUrl}"/>
> <property name="user" value="${weatherDbUser}"/>
> <property name="password" value="${weatherDbPassword}"/>
> </bean>
> <service interface="javax.sql.DataSource" ref="dataSource">
> <service-properties>
> <entry key="osgi.jndi.service.name <http://osgi.jndi.service.name>"
> value="jdbc/mysqlds"/>
> </service-properties>
> </service>
>
> <bean id="weatherCurrentRouteBuilder"
> class="com.mycompany.route.weather.WeatherCurrentRouteBuilder"
> init-method="refresh">
> <property name="sourceUrl" value="${sourceUrl}"></property>
> </bean>
>
> <camelContext id="weather-forecast"
> xmlns="http://camel.apache.org/schema/blueprint">
> <routeBuilder ref="weatherCurrentRouteBuilder" />
> </camelContext>
>
> </blueprint>
>
>
> and the configuration file weather.cfg
>
> sourceUrl=http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml
> weatherDbConnectionUrl=jdbc:mysql://my.comapny.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8
> <http://my.comapny.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8>
> weatherDbUser=testUser
> weatherDbPassword=testPass
>
> and the persistence.xml
>
> <persistence xmlns="http://java.sun.com/xml/ns/persistence"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> version="1.0">
>
> <persistence-unit name="weather" transaction-type="JTA">
> <provider>org.hibernate.ejb.HibernatePersistence</provider>
> <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name
> <http://osgi.jndi.service.name>=jdbc/mysqlds)</jta-data-source>
> <class>my.company.model.entities.weather.WeatherCurrent</class>
> <exclude-unlisted-classes>true</exclude-unlisted-classes>
> <properties>
> <property name="hibernate.show_sql" value="true"/>
> <property name="hibernate.format_sql" value="true"/>
> </properties>
> </persistence-unit>
> </persistence>
>
> and features bundle which installs configuration and drivers besides my
> camel route:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0
> http://karaf.apache.org/xmlns/features/v1.0.0">
>
> <feature name="weather" version="${pom.version}">
> <bundle>mvn:mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.stax-api-1.0/1.9.0</bundle>
> <bundle>mvn:mvn:mysql/mysql-connector-java/5.1.18</bundle>
> <bundle>mvn:my.company/route-weather-current/${pom.version}</bundle>
> <configfile
> finalname="/etc/weather.cfg">mvn:my.company/features-weather/${pom.version}/cfg</configfile>
> </feature>
>
> </features>
>
>
> Am I heading the right way or am I on the Titanic's route?
>
> Cheers,
> borut
>
>
> Dne 16. april 2012 14:51 je Jean-Baptiste Onofré <jb@nanthrax.net
> <ma...@nanthrax.net>> napisal/-a:
>
>     Username/password/URL could be in <cm:properties/> and so handle in
>     the "application" config oriented file in etc.
>
>     Regards
>     JB
>
>
>     On 04/16/2012 02:47 PM, Christian Schneider wrote:
>
>         I would simply deploy the blueprint xml by hand. Just treat it
>         like a
>         config file you would have to add.
>         This is of course not everyone´s favorite style.
>
>         The problem with adding the blueprint to the feature is that it
>         would
>         have to be in the maven repo. As the username and password are
>         in this
>         file this is not recommended.
>
>         So another way to achieve what I did is separate the things that
>         should
>         be configured per server or stage from the things that keep the
>         same like
>         driver class name. You could use the config admin service in the
>         blueprint file to move the username / password to a separate
>         config file.
>         This would make the whole thing a bit more complex though but
>         you could
>         then safely put the blueprint file into a feature.
>
>         Christian
>
>
>         2012/4/16 Borut Bolčina <borut.bolcina@gmail.com
>         <ma...@gmail.com>
>         <mailto:borut.bolcina@gmail.__com <ma...@gmail.com>>>
>
>
>             Hello,
>
>             my first post here, so bare with me please - newbie on board.
>
>             I am trying to deploy my first camel route to Karaf and this
>         route
>             must be configurable (html address) and must persist some
>         data with
>             jpa component. This route is happily persisting in my test
>         (outside
>             osgi container).
>
>             Now I am reading
>         https://github.com/cschneider/__Karaf-Tutorial/blob/master/db/__datasource/datasource-mysql.__xml
>         <https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-mysql.xml>
>         where
>             it says I should copy the file to Karaf's deploy folder.
>
>             And the question: What is the practice of deploying data
>         sources?
>             Should I create a features project which includes a
>         blueprint for my
>             route's data source?
>
>             Let's say my route needs connection to mysql database, so the
>             feature project would include features.xml
>
>         <?xml version="1.0" encoding="UTF-8"?>
>         <features xmlns="http://karaf.apache.__org/xmlns/features/v1.0.0
>         <http://karaf.apache.org/xmlns/features/v1.0.0>"
>             xmlns:xsi="http://www.w3.org/__2001/XMLSchema-instance
>         <http://www.w3.org/2001/XMLSchema-instance>"
>
>           xsi:schemaLocation="http://__karaf.apache.org/xmlns/__features/v1.0.0 <http://karaf.apache.org/xmlns/features/v1.0.0>
>         http://karaf.apache.org/xmlns/__features/v1.0.0
>         <http://karaf.apache.org/xmlns/features/v1.0.0>">
>
>         <feature name="weather" version="${pom.version}">
>         <bundle>mvn:mvn:org.apache.__servicemix.specs/org.apache.__servicemix.specs.stax-api-1.0/__1.9.0</bundle>
>         <bundle>mvn:mvn:mysql/mysql-__connector-java/5.1.18</bundle>
>         <bundle>mvn:my.company/route-__weather-current/${pom.version}__</bundle>
>             *<bundle>my datasource blueprint</bundle>*
>
>         <configfile
>
>           finalname="/etc/weather.cfg">__mvn:my.company/features-__weather/${pom.version}/cfg</__configfile>
>         </feature>
>         </features>
>
>             I guess then the only command to install my Camel route to Karaf
>             would then be feature:install and all the dependencies including
>             datasource and configuration would be installed before. And
>         how to
>             package the "my datasource blueprint"?
>
>             Or is there some other practice?
>
>             Thanks,
>             borut
>
>
>
>     --
>     Jean-Baptiste Onofré
>     jbonofre@apache.org <ma...@apache.org>
>     http://blog.nanthrax.net
>     Talend - http://www.talend.com
>
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Deploying data sources

Posted by Borut Bolčina <bo...@gmail.com>.
OK, to make a first step which doesn't involve creating a separate bundle
for datasource, but instead adding a datasource configuration directly to
my Camel route bundle's blueprint.xml:

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
 xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
 xsi:schemaLocation="
...  ">

  <cm:property-placeholder persistent-id="WeatherCurrent"
update-strategy="reload">
 <cm:default-properties>
<cm:property name="sourceUrl" value="
http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml"
/>
 <cm:property name="weatherDbConnectionUrl" value="jdbc:mysql://
my.company.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8" />
 <cm:property name="weatherDbUser" value="testUser" />
<cm:property name="weatherDbPassword" value="testPass" />
 </cm:default-properties>
</cm:property-placeholder>

 <bean id="dataSource"
class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
    <property name="url" value="${weatherDbConnectionUrl}"/>
    <property name="user" value="${weatherDbUser}"/>
    <property name="password" value="${weatherDbPassword}"/>
 </bean>
 <service interface="javax.sql.DataSource" ref="dataSource">
 <service-properties>
<entry key="osgi.jndi.service.name" value="jdbc/mysqlds"/>
 </service-properties>
</service>

<bean id="weatherCurrentRouteBuilder"
class="com.mycompany.route.weather.WeatherCurrentRouteBuilder"
init-method="refresh">
 <property name="sourceUrl" value="${sourceUrl}"></property>
</bean>

<camelContext id="weather-forecast" xmlns="
http://camel.apache.org/schema/blueprint">
 <routeBuilder ref="weatherCurrentRouteBuilder" />
</camelContext>

</blueprint>


and the configuration file weather.cfg

sourceUrl=
http://meteo.arso.gov.si/uploads/probase/www/observ/surface/text/sl/observation_si_latest.xml
weatherDbConnectionUrl=jdbc:mysql://
my.comapny.com:3306/weather?useUnicode=yes&amp;characterEncoding=UTF-8
weatherDbUser=testUser
weatherDbPassword=testPass

and the persistence.xml

<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
 version="1.0">

<persistence-unit name="weather" transaction-type="JTA">
 <provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name
=jdbc/mysqlds)</jta-data-source>
 <class>my.company.model.entities.weather.WeatherCurrent</class>
 <exclude-unlisted-classes>true</exclude-unlisted-classes>
 <properties>
 <property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
               </properties>

</persistence-unit>
</persistence>

and features bundle which installs configuration and drivers besides my
camel route:

<?xml version="1.0" encoding="UTF-8"?>
<features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0
http://karaf.apache.org/xmlns/features/v1.0.0">

<feature name="weather" version="${pom.version}">
<bundle>mvn:mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.stax-api-1.0/1.9.0</bundle>
 <bundle>mvn:mvn:mysql/mysql-connector-java/5.1.18</bundle>
<bundle>mvn:my.company/route-weather-current/${pom.version}</bundle>
 <configfile
finalname="/etc/weather.cfg">mvn:my.company/features-weather/${pom.version}/cfg</configfile>
</feature>

</features>


Am I heading the right way or am I on the Titanic's route?

Cheers,
borut


Dne 16. april 2012 14:51 je Jean-Baptiste Onofré <jb...@nanthrax.net>napisal/-a:

> Username/password/URL could be in <cm:properties/> and so handle in the
> "application" config oriented file in etc.
>
> Regards
> JB
>
>
> On 04/16/2012 02:47 PM, Christian Schneider wrote:
>
>> I would simply deploy the blueprint xml by hand. Just treat it like a
>> config file you would have to add.
>> This is of course not everyone´s favorite style.
>>
>> The problem with adding the blueprint to the feature is that it would
>> have to be in the maven repo. As the username and password are in this
>> file this is not recommended.
>>
>> So another way to achieve what I did is separate the things that should
>> be configured per server or stage from the things that keep the same like
>> driver class name. You could use the config admin service in the
>> blueprint file to move the username / password to a separate config file.
>> This would make the whole thing a bit more complex though but you could
>> then safely put the blueprint file into a feature.
>>
>> Christian
>>
>>
>> 2012/4/16 Borut Bolčina <borut.bolcina@gmail.com
>> <mailto:borut.bolcina@gmail.**com <bo...@gmail.com>>>
>>
>>
>>    Hello,
>>
>>    my first post here, so bare with me please - newbie on board.
>>
>>    I am trying to deploy my first camel route to Karaf and this route
>>    must be configurable (html address) and must persist some data with
>>    jpa component. This route is happily persisting in my test (outside
>>    osgi container).
>>
>>    Now I am reading
>>    https://github.com/cschneider/**Karaf-Tutorial/blob/master/db/**
>> datasource/datasource-mysql.**xml<https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-mysql.xml>where
>>    it says I should copy the file to Karaf's deploy folder.
>>
>>    And the question: What is the practice of deploying data sources?
>>    Should I create a features project which includes a blueprint for my
>>    route's data source?
>>
>>    Let's say my route needs connection to mysql database, so the
>>    feature project would include features.xml
>>
>>    <?xml version="1.0" encoding="UTF-8"?>
>>    <features xmlns="http://karaf.apache.**org/xmlns/features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> "
>>    xmlns:xsi="http://www.w3.org/**2001/XMLSchema-instance<http://www.w3.org/2001/XMLSchema-instance>
>> "
>>    xsi:schemaLocation="http://**karaf.apache.org/xmlns/**features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>>    http://karaf.apache.org/xmlns/**features/v1.0.0<http://karaf.apache.org/xmlns/features/v1.0.0>
>> ">
>>
>>    <feature name="weather" version="${pom.version}">
>>    <bundle>mvn:mvn:org.apache.**servicemix.specs/org.apache.**
>> servicemix.specs.stax-api-1.0/**1.9.0</bundle>
>>    <bundle>mvn:mvn:mysql/mysql-**connector-java/5.1.18</bundle>
>>    <bundle>mvn:my.company/route-**weather-current/${pom.version}**
>> </bundle>
>>    *<bundle>my datasource blueprint</bundle>*
>>
>>    <configfile
>>    finalname="/etc/weather.cfg">**mvn:my.company/features-**
>> weather/${pom.version}/cfg</**configfile>
>>    </feature>
>>    </features>
>>
>>    I guess then the only command to install my Camel route to Karaf
>>    would then be feature:install and all the dependencies including
>>    datasource and configuration would be installed before. And how to
>>    package the "my datasource blueprint"?
>>
>>    Or is there some other practice?
>>
>>    Thanks,
>>    borut
>>
>>
>>
> --
> Jean-Baptiste Onofré
> jbonofre@apache.org
> http://blog.nanthrax.net
> Talend - http://www.talend.com
>

Re: Deploying data sources

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Username/password/URL could be in <cm:properties/> and so handle in the 
"application" config oriented file in etc.

Regards
JB

On 04/16/2012 02:47 PM, Christian Schneider wrote:
> I would simply deploy the blueprint xml by hand. Just treat it like a
> config file you would have to add.
> This is of course not everyone´s favorite style.
>
> The problem with adding the blueprint to the feature is that it would
> have to be in the maven repo. As the username and password are in this
> file this is not recommended.
>
> So another way to achieve what I did is separate the things that should
> be configured per server or stage from the things that keep the same like
> driver class name. You could use the config admin service in the
> blueprint file to move the username / password to a separate config file.
> This would make the whole thing a bit more complex though but you could
> then safely put the blueprint file into a feature.
>
> Christian
>
>
> 2012/4/16 Borut Bolčina <borut.bolcina@gmail.com
> <ma...@gmail.com>>
>
>     Hello,
>
>     my first post here, so bare with me please - newbie on board.
>
>     I am trying to deploy my first camel route to Karaf and this route
>     must be configurable (html address) and must persist some data with
>     jpa component. This route is happily persisting in my test (outside
>     osgi container).
>
>     Now I am reading
>     https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-mysql.xml where
>     it says I should copy the file to Karaf's deploy folder.
>
>     And the question: What is the practice of deploying data sources?
>     Should I create a features project which includes a blueprint for my
>     route's data source?
>
>     Let's say my route needs connection to mysql database, so the
>     feature project would include features.xml
>
>     <?xml version="1.0" encoding="UTF-8"?>
>     <features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0"
>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0
>     http://karaf.apache.org/xmlns/features/v1.0.0">
>
>     <feature name="weather" version="${pom.version}">
>     <bundle>mvn:mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.stax-api-1.0/1.9.0</bundle>
>     <bundle>mvn:mvn:mysql/mysql-connector-java/5.1.18</bundle>
>     <bundle>mvn:my.company/route-weather-current/${pom.version}</bundle>
>     *<bundle>my datasource blueprint</bundle>*
>     <configfile
>     finalname="/etc/weather.cfg">mvn:my.company/features-weather/${pom.version}/cfg</configfile>
>     </feature>
>     </features>
>
>     I guess then the only command to install my Camel route to Karaf
>     would then be feature:install and all the dependencies including
>     datasource and configuration would be installed before. And how to
>     package the "my datasource blueprint"?
>
>     Or is there some other practice?
>
>     Thanks,
>     borut
>
>

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Deploying data sources

Posted by Christian Schneider <ch...@die-schneider.net>.
I would simply deploy the blueprint xml by hand. Just treat it like a
config file you would have to add.
This is of course not everyone´s favorite style.

The problem with adding the blueprint to the feature is that it would have
to be in the maven repo. As the username and password are in this file this
is not recommended.

So another way to achieve what I did is separate the things that should be
configured per server or stage from the things that keep the same like
driver class name. You could use the config admin service in the blueprint
file to move the username / password to a separate config file.
This would make the whole thing a bit more complex though but you could
then safely put the blueprint file into a feature.

Christian


2012/4/16 Borut Bolčina <bo...@gmail.com>

> Hello,
>
> my first post here, so bare with me please - newbie on board.
>
> I am trying to deploy my first camel route to Karaf and this route must be
> configurable (html address) and must persist some data with jpa component.
> This route is happily persisting in my test (outside osgi container).
>
> Now I am reading
> https://github.com/cschneider/Karaf-Tutorial/blob/master/db/datasource/datasource-mysql.xml where
> it says I should copy the file to Karaf's deploy folder.
>
> And the question: What is the practice of deploying data sources? Should I
> create a features project which includes a blueprint for my route's data
> source?
>
> Let's say my route needs connection to mysql database, so the feature
> project would include features.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <features xmlns="http://karaf.apache.org/xmlns/features/v1.0.0"
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.0.0
> http://karaf.apache.org/xmlns/features/v1.0.0">
>
> <feature name="weather" version="${pom.version}">
>
> <bundle>mvn:mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.stax-api-1.0/1.9.0</bundle>
>  <bundle>mvn:mvn:mysql/mysql-connector-java/5.1.18</bundle>
> <bundle>mvn:my.company/route-weather-current/${pom.version}</bundle>
>  *<bundle>my datasource blueprint</bundle>*
> <configfile
> finalname="/etc/weather.cfg">mvn:my.company/features-weather/${pom.version}/cfg</configfile>
>  </feature>
> </features>
>
> I guess then the only command to install my Camel route to Karaf would
> then be feature:install and all the dependencies including datasource and
> configuration would be installed before. And how to package the "my
> datasource blueprint"?
>
> Or is there some other practice?
>
> Thanks,
> borut
>