Thanks a lot for this!!

I think that my problem is with config files

Best regards!

On Thu, Mar 22, 2012 at 5:39 PM, Christian Schneider <
[email protected]> wrote:

> As this may be interesting for others too I have created an example on how
> to instantiate a DataSource and publish it as a service.
> I also used the config admin service so you can define the properties
> outside of the bundle.
>
> See
> https://github.com/cschneider/**Karaf-Tutorial/tree/master/db/**
> datasource-mysql<https://github.com/cschneider/Karaf-Tutorial/tree/master/db/datasource-mysql>
>
> As you see I did not have to define much for the maven bundle plugin.
>
> Christian
>
>
> Am 22.03.2012 15:56, schrieb elMateo:
>
>> ManifestLocation is for indicate exactly where is the manisfest file.
>>  Removeheader is used for one of the test to try the application, it isn't
>> important.
>>
>> On Thu, Mar 22, 2012 at 1:29 PM, Christian Schneider<
>> [email protected]>  wrote:
>>
>>  Some questions /remarks:
>>>
>>> Why do you use<manifestLocation>  and<_removeheaders>? I never used those
>>> till now.
>>> I think you do not have to export any packages as you just provide a
>>> service.
>>>
>>>  Ok, I'm going to test this.
>>
>>  Do you initialize the DataSource in java code? If yes then you probably
>>> do
>>> not need any dynamic imports and you typically do not need to define
>>> Import-Package as the plugin normally does the correct thing.
>>>
>>>  Yes, I do this: DataSource dataSource = new
>> com.mysql.jdbc.jdbc2.optional.**MysqlDataSource();
>>
>>  Can you upload your whole project somewhere?
>>>
>>>  Sorry, I don't have any server to upload my project. But my Activator
>> class
>> only do this:
>>
>>                   DataSource dataSource = new
>> com.mysql.jdbc.jdbc2.optional.**MysqlDataSource();
>>                   registration =
>> bc.registerService(DataSource.**class.getName(), dataSource, null);
>>
>> And when I start the bundle, Apache Felix show me exceptions write above.
>>
>> Thanks a lot for yours answers :) !
>>
>>  Christian
>>>
>>>
>>>
>>>
>>>
>>> Am 22.03.2012 11:50, schrieb elMateo:
>>>
>>>  This is an extract of my pom file:
>>>>
>>>>            <plugin>
>>>> <groupId>org.apache.felix</****groupId>
>>>> <artifactId>maven-bundle-****plugin</artifactId>
>>>> <extensions>true</extensions>
>>>> <configuration>
>>>> <manifestLocation>META-INF</****manifestLocation>
>>>> <instructions>
>>>> <_removeheaders>Ignore-****Package</_removeheaders>
>>>> <Bundle-SymbolicName>****bundleDBConnector</Bundle-****SymbolicName>
>>>> <Bundle-Name>****bundleDBConnector</Bundle-****Name>
>>>> <Bundle-Activator>com.****database.bundle.Activator</****
>>>> Bundle-Activator>
>>>> <Export-Package>com.database.****bundle;-split-package:=merge-****
>>>> last</Export-Package>
>>>> <Import-Package>org.osgi.****framework</Import-Package>
>>>> <DynamicImport-Package>javax.****sql.*,com.mysql.jdbc.jdbc2.**
>>>> optional.*</DynamicImport-****Package>
>>>>
>>>> </instructions>
>>>> </configuration>
>>>> </plugin>
>>>>
>>>> Is it correct?? Uff, still it appears the same exception :(
>>>>
>>>> On Thu, Mar 22, 2012 at 10:23 AM, elMateo<[email protected]>
>>>> wrote:
>>>>
>>>>  Yes, I'm developing my application with Maven. I'm going to read this
>>>>
>>>>> tutorial. Maybe I'm doing something wrong
>>>>>
>>>>>
>>>>> On Wed, Mar 21, 2012 at 7:43 PM, Christian Schneider<
>>>>> [email protected]>   wrote:
>>>>>
>>>>>  In the bundle that creates the DataSource you have to have an
>>>>>
>>>>>> Import-Package statement in the Manifest for each package you use.
>>>>>> So at least com.mysql.jdbc.optional and javax.sql.DataSource. It is
>>>>>> quite
>>>>>> hard to do that by hand. If you use maven to build your bundle then
>>>>>> you should use the maven bundle plugin which analyzes your java code
>>>>>> and
>>>>>> creates the necessary statements for the Manifest.
>>>>>>
>>>>>> In this tutorial I describe how to do it:
>>>>>> http://www.liquid-reality.de/******display/liquid/2011/02/15/****<http://www.liquid-reality.de/****display/liquid/2011/02/15/**>
>>>>>> <http://www.liquid-reality.**de/**display/liquid/2011/02/**15/**<http://www.liquid-reality.de/**display/liquid/2011/02/15/**>
>>>>>> >
>>>>>> Karaf+Tutorial+Part+1+-+******Installation+and+First+******
>>>>>> application<
>>>>>> http://www.liquid-**reality.**de/display/liquid/**<http://reality.de/display/liquid/**>
>>>>>> 2011/02/15/Karaf+Tutorial+****Part+1+-+Installation+and+**
>>>>>> First+application<http://www.**liquid-reality.de/display/**
>>>>>> liquid/2011/02/15/Karaf+**Tutorial+Part+1+-+**Installation+and+First+
>>>>>> **application<http://www.liquid-reality.de/display/liquid/2011/02/15/Karaf+Tutorial+Part+1+-+Installation+and+First+application>
>>>>>> >
>>>>>>
>>>>>>
>>>>>> The tutorial is about karaf but the bundle creation is the same if you
>>>>>> use pure felix. Only the deployment may be different.
>>>>>>
>>>>>> Christian
>>>>>>
>>>>>>
>>>>>> Am 21.03.2012 18:35, schrieb elMateo:
>>>>>>
>>>>>>  I'm struggling with this exception of
>>>>>>
>>>>>>> Apache java.lang.******NoClassDefFoundError:
>>>>>>> com/mysql/jdbc/jdbc2/optional/******MysqlDataSource. Because I have
>>>>>>> the
>>>>>>>
>>>>>>>
>>>>>>> MySQL
>>>>>>> Connect/J bundle running in Apache Felix. Sometimes I have another
>>>>>>> exception, java.lang.******NoClassDefFoundError:
>>>>>>> javax/sql/DataSource,
>>>>>>>
>>>>>>> and I
>>>>>>>
>>>>>>> don't know why :(
>>>>>>>
>>>>>>> On Wed, Mar 21, 2012 at 5:20 PM, Christian Schneider<
>>>>>>> [email protected]>    wrote:
>>>>>>>
>>>>>>>  The solution described by Neil should allow that and should be easy
>>>>>>> to
>>>>>>>
>>>>>>>  implement. Using the service to connect your other bundles to the
>>>>>>>> datasource even makes them
>>>>>>>> very indepentent of the implementation of the "bridge bundle". A
>>>>>>>> user
>>>>>>>> bundle could import the DataSource from my solution with blueprint
>>>>>>>> or
>>>>>>>> the
>>>>>>>> handwritten java bridge bundle
>>>>>>>> and would not have to be changed in any way.
>>>>>>>>
>>>>>>>> What exactly are you struggling with?
>>>>>>>>
>>>>>>>> Christian
>>>>>>>>
>>>>>>>> Am 21.03.2012 15:43, schrieb elMateo:
>>>>>>>>
>>>>>>>>  What I want it's only a bundle that work as a bridge to  whatever
>>>>>>>>
>>>>>>>>  database.
>>>>>>>>
>>>>>>>>> The other bundles access to this one to retrieve any information
>>>>>>>>> from
>>>>>>>>> external databases. But I don't get this :(
>>>>>>>>>
>>>>>>>>> On Wed, Mar 21, 2012 at 2:38 PM, Donald Whytock<[email protected]
>>>>>>>>> >
>>>>>>>>>  wrote:
>>>>>>>>>
>>>>>>>>>  What you probably want in the long run is a datasource-generating
>>>>>>>>>
>>>>>>>>>  service, to which you pass the database URI.  You can put things
>>>>>>>>> in
>>>>>>>>>
>>>>>>>>>> the properties of the service to indicate whether it's Oracle,
>>>>>>>>>> mySQL,
>>>>>>>>>> MSSQL, etc., so that you can have multiple generating services at
>>>>>>>>>> the
>>>>>>>>>> same time.
>>>>>>>>>>
>>>>>>>>>> Don
>>>>>>>>>>
>>>>>>>>>> ------------------------------********------------------------**
>>>>>>>>>> --**
>>>>>>>>>> --**--**
>>>>>>>>>> ---------
>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.******apac**
>>>>>>>>>> he.org<
>>>>>>>>>> http://apache.org**>
>>>>>>>>>> <users-unsubscribe@**felix.**a**pache.org <http://apache.org><
>>>>>>>>>> http://felix.apache.**org <http://felix.apache.org>><
>>>>>>>>>>
>>>>>>>>>> users-unsubscribe@**felix.**apache.org <http://felix.apache.org><
>>>>>>>>>> users-unsubscribe@**felix.apache.org<[email protected]>
>>>>>>>>>> >
>>>>>>>>>> For additional commands, e-mail: [email protected]
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  --
>>>>>>>>>>
>>>>>>>>>>  Christian Schneider
>>>>>>>>>
>>>>>>>> http://www.liquid-reality.de
>>>>>>>>
>>>>>>>> Open Source Architect
>>>>>>>> Talend Application Integration Division http://www.talend.com
>>>>>>>>
>>>>>>>>
>>>>>>>> ------------------------------********------------------------**
>>>>>>>> --**--**
>>>>>>>> --**---------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.******apac**he.org<
>>>>>>>> http://apache.org**>
>>>>>>>> <users-unsubscribe@**felix.**a**pache.org <http://apache.org><
>>>>>>>> http://felix.apache.**org <http://felix.apache.org>><
>>>>>>>>
>>>>>>>> users-unsubscribe@**felix.**apache.org <http://felix.apache.org><
>>>>>>>> users-unsubscribe@**felix.apache.org<[email protected]>
>>>>>>>> >
>>>>>>>> For additional commands, e-mail: [email protected]
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>  --
>>>>>>>>
>>>>>>> Christian Schneider
>>>>>> http://www.liquid-reality.de
>>>>>>
>>>>>> Open Source Architect
>>>>>> Talend Application Integration Division http://www.talend.com
>>>>>>
>>>>>>
>>>>>> ------------------------------******--------------------------**--**
>>>>>> --**---------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@felix.****apac**he.org<
>>>>>> http://apache.org**>
>>>>>> <users-unsubscribe@**felix.**apache.org <http://felix.apache.org><
>>>>>> users-unsubscribe@**felix.apache.org<[email protected]>
>>>>>> >
>>>>>> For additional commands, e-mail: [email protected]
>>>>>>
>>>>>>
>>>>>>
>>>>>>  --
>>> Christian Schneider
>>> http://www.liquid-reality.de
>>>
>>> Open Source Architect
>>> Talend Application Integration Division http://www.talend.com
>>>
>>>
>>> ------------------------------****----------------------------**
>>> --**---------
>>> To unsubscribe, e-mail: 
>>> users-unsubscribe@felix.**apac**he.org<http://apache.org>
>>> <users-unsubscribe@**felix.apache.org<[email protected]>
>>> >
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>>
>
> --
> Christian Schneider
> http://www.liquid-reality.de
>
> Open Source Architect
> Talend Application Integration Division http://www.talend.com
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> users-unsubscribe@felix.**apache.org<[email protected]>
> For additional commands, e-mail: [email protected]
>
>

Reply via email to