Guide for upgrading from karaf 4.1.x to 4.2.x

2019-03-28 Thread Lukasz Lech
Hello,

Do you have some guide for upgrading from karaf 4.1.x line to 4.2.x line?

I have a legacy app that wasn't possible to upgrade because of some critical 
bugs introduced with library updates (PostgreSQL support issues), now I've 
tried to install our app from 4.1.3 to 4.2.4 and I'm getting errors that are 
totally puzzling me:

org.osgi.service.blueprint.container.ComponentDefinitionException: Unsupported 
node namespace: http://aries.apache.org/xmlns/transactions/v2.0.0

java.lang.LinkageError: loader constraint violation in interface itable 
initialization: when resolving method 
"org.apache.aries.jpa.container.impl.AriesEntityManagerFactoryBuilder.createEntityManagerFactory(Ljava/util/Map;)Ljavax/persistence/EntityManagerFactory;"
 the class loader (instance of 
org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) of the current 
class, org/apache/aries/jpa/container/impl/AriesEntityManagerFactoryBuilder, 
and the class loader (instance of 
org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) for interface 
org/osgi/service/jpa/EntityManagerFactoryBuilder have different Class objects 
for the type javax/persistence/EntityManagerFactory used in the signature

Our app installs Aries JPA 2.7.0 
(mvn:org.apache.aries.jpa/jpa-features/2.7.0/xml/features).
Is there anything that need to be upgraded etc.?

Thank you for any hints.

Best regards,
Lukasz Lech



AW: AW: AW: AW: AW: ComponentFactory

2019-03-28 Thread Matthias Leinweber
Hello again,


i dont use Component Factories i am now using Managed Service Factories...

i am now using this way to discover available factories:


ServiceComponentRuntime scr;

[...]

scr.getComponentDescriptionDTOs(null)
.stream()
.map(componentDescriptionDTO -> String.join(" ", 
componentDescriptionDTO.configurationPid))
.filter(s -> s.startsWith("my.pre.fix"))...


best regards,
Matthias


Von: David Jencks 
Gesendet: Dienstag, 26. März 2019 17:01:13
An: user@karaf.apache.org
Betreff: Re: AW: AW: AW: AW: ComponentFactory

I don’t understand what you are trying to do. I don’t see any way that factory 
components would be relevant in any way to anything you mention.
Suppose you have two normal components implementing MyInterface, and supply 
factory configurations for them to create instances as needed, and have a 
multivalued reference of type MyInterface. What do you need that this doesn’t 
provide?

Thanks
David Jencks

Sent from my iPhone

On Mar 26, 2019, at 1:21 AM, Matthias Leinweber 
mailto:matthias.leinwe...@ida-analytics.de>>
 wrote:


Hi JB,

yes but until i created one there is nothing to iterate/find.
However, i think did not explain my problem very well so i try to explain  what 
i want to do.
Maybe i took the wrong approach to solve my problem. So lets consider the 
following classes:

@Component(
service = MyInterface.class,
configurationPid = "my.factory.prefix.A"
configurationPolicy=ConfigurationPolicy.REQUIRE,
property = {
"prop1=A",
"prop2=foo"})
public class MyComponentA implements MyInterface {

@Modified
public void modified(ComponentContext componentContext){
  //change something in this component
}
public void dostuff(){}
}

@Component(
service = MyInterface.class,
configurationPid = "my.factory.prefix.B"
configurationPolicy=ConfigurationPolicy.REQUIRE,
property = {
"prop1=B",
"prop2=bar"})
public class MyComponentB implements MyInterface {

@Modified
public void modified(ComponentContext componentContext){
  //change something in this component
}
public void dostuff(){}
}

public class MyFancyManager implements MyFancyInterface {

public List listAvailableComponentFactories(){
// how do i "iterate" over all factories without that i
// have already created one? I don't  know which
// factories are present in advance or bundles
// dynamically add new components factories
}

public void  changeConfig(String filter, Map config){
// 
configManager.listConfig(filter).stream().filter().any().update(config)
}

public void  createSomething(String type, Map config){
  Configuration cfg = 
configurationAdmin.createFactoryConfiguration("my.factory.prefix."+type, null);
  Hashtable prop = new Hashtable<>();
  prop.put("prop3", "foobar");
  cfg.update(testProp);
}
}

And now i like to create some services from type A, some from type B and then i 
like to change configurations of existing services.

best regards,
Matthias


Von: Jean-Baptiste Onofré mailto:j...@nanthrax.net>>
Gesendet: Dienstag, 26. März 2019 06:15:26
An: user@karaf.apache.org
Betreff: Re: AW: AW: AW: ComponentFactory

Hi Mathias,

The factoryPid doesn't change: it's com.foo.bar.
The configurationPid is based on the factory PID: com.foo.bar. (in
config:list).

So you can find "your" configurations based on your factoryPid. You can
list all configuration for a given factoryPid:

config:list "(factoryPid=com.foo.bar)"

Regards
JB

On 25/03/2019 20:01, Matthias Leinweber wrote:
> ... i can iterate over "my" servicefactories.
>
> 
> *From:* Matthias Leinweber
> *Sent:* Monday, March 25, 2019 8:00:25 PM
> *To:* user@karaf.apache.org
> *Subject:* Re: AW: AW: AW: ComponentFactory
>
> Mhm OK.
>
> I will try to explain what i want to achieve.
>
> My Plan was to create several ManagedserviceFactories all with different
> factorypids but all with the same prefix. So that i
> 
> *From:* Jean-Baptiste Onofré mailto:j...@nanthrax.net>>
> *Sent:* Monday, March 25, 2019 7:33:52 PM
> *To:* user@karaf.apache.org
> *Subject:* Re: AW: AW: AW: ComponentFactory
>
> Not sure I follow you.
>
> What's the issue ?
>
> You have the factory and the configurations for the factory.
>
> Regards
> JB
>
> On 25/03/2019 18:54, Matthias Leinweber wrote:
>> Yes,
>>
>>
>> but i see "this"
>>
>> Pid:com.ida.moira.operator.factory.Input.Kafka
>> Collector.8e589bdc-0e72-49dd-b7c5-78234be1b8ba
>> FactoryPid: com.ida.moira.operator.factory.Input.Kafka Collector
>> BundleLocation: null
>> Properties:
>>com.ida.moira.operator.name = foo
>>com.ida.moira.ope

Re: Guide for upgrading from karaf 4.1.x to 4.2.x

2019-03-28 Thread Jean-Baptiste Onofré
Hi Lukasz,

We don't have such guide for now, but it makes sense as there's some
changes.

About your question, I would recommend to use the features provided by
Karaf as the examples are based on this.
In your case, did you check you don't have different JPA versions ?
(like 2.0/2.1) ?

Regards
JB

On 28/03/2019 08:59, Lukasz Lech wrote:
> Hello,
> 
>  
> 
> Do you have some guide for upgrading from karaf 4.1.x line to 4.2.x line?
> 
>  
> 
> I have a legacy app that wasn’t possible to upgrade because of some
> critical bugs introduced with library updates (PostgreSQL support
> issues), now I’ve tried to install our app from 4.1.3 to 4.2.4 and I’m
> getting errors that are totally puzzling me:
> 
>  
> 
> org.osgi.service.blueprint.container.ComponentDefinitionException:
> Unsupported node namespace:
> http://aries.apache.org/xmlns/transactions/v2.0.0
> 
>  
> 
> java.lang.LinkageError: loader constraint violation in interface itable
> initialization: when resolving method
> "org.apache.aries.jpa.container.impl.AriesEntityManagerFactoryBuilder.createEntityManagerFactory(Ljava/util/Map;)Ljavax/persistence/EntityManagerFactory;"
> the class loader (instance of
> org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) of the
> current class,
> org/apache/aries/jpa/container/impl/AriesEntityManagerFactoryBuilder,
> and the class loader (instance of
> org/apache/felix/framework/BundleWiringImpl$BundleClassLoader) for
> interface org/osgi/service/jpa/EntityManagerFactoryBuilder have
> different Class objects for the type
> javax/persistence/EntityManagerFactory used in the signature
> 
>  
> 
> Our app installs Aries JPA 2.7.0
> (mvn:org.apache.aries.jpa/jpa-features/2.7.0/xml/features).
> 
> Is there anything that need to be upgraded etc.?
> 
>  
> 
> Thank you for any hints.
> 
>  
> 
> Best regards,
> 
> Lukasz Lech
> 
>  
> 

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


Conditional Features startup in karaf

2019-03-28 Thread imranrazakhan
We have karaf in Openshift and sharing central configuration through
configmap. We have to start/stop or make available features/bundles on base
of central configuration.

So if central configuration tag one bundle as enable we will start it or if
central configuration tag feature as disable we should stop that bundle.

Do karaf support some API to control bundle lifecyle on base of external
configuration.




--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html


Karaf SSH error

2019-03-28 Thread Alex Soto
For my integration tests, I launch two separate Karaf instances.
When I try to connect from one instance to the other using the ssh:ssh  
command, I always get the error:

org.apache.sshd.common.SshException: Server key did not validate
at 
org.apache.sshd.client.session.AbstractClientSession.checkKeys(AbstractClientSession.java:495)

I suppose that, because both instances are running in the same host, there may 
be a conflict with the ~/.sshkaraf directory, but I don’t know how to solve 
this issue.
The server key of now instance is overriding/conflicting the server key of the 
other instance?

(I am using Karaf   4.2.0)
Any help will be greatly appreciated.


Best regards,
Alex soto






Re: Conditional Features startup in karaf

2019-03-28 Thread Jean-Baptiste Onofré
Hi,

Karaf doesn't have such mechanism out of the box.

However, you can implement your own "controller" for that. It's a bundle
that control others based on configuration.

Regards
JB

On 28/03/2019 20:56, imranrazakhan wrote:
> We have karaf in Openshift and sharing central configuration through
> configmap. We have to start/stop or make available features/bundles on base
> of central configuration.
> 
> So if central configuration tag one bundle as enable we will start it or if
> central configuration tag feature as disable we should stop that bundle.
> 
> Do karaf support some API to control bundle lifecyle on base of external
> configuration.
> 
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
> 

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


Re: Karaf SSH error

2019-03-28 Thread Jean-Baptiste Onofré
Hi Alex,

you are right, if the two instances and clients run with the same user.

The workaround is to remove the $HOME/.sshkaraf folder before each
ssh:ssh. ssh:ssh will recreate it with the target instance key.

I can add an option to ssh:ssh and client to "ignore" server key check.

Regards
JB

On 28/03/2019 21:00, Alex Soto wrote:
> For my integration tests, I launch two separate Karaf instances.
> When I try to connect from one instance to the other using the
> /ssh:ssh/  command, I always get the error:
> 
> org.apache.sshd.common.SshException: Server key did not validate
> at
> org.apache.sshd.client.session.AbstractClientSession.checkKeys(AbstractClientSession.java:495)
> 
> I suppose that, because both instances are running in the same host,
> there may be a conflict with the /~/.sshkaraf /directory, but I don’t
> know how to solve this issue.
> The server key of now instance is overriding/conflicting the server key
> of the other instance?
> 
> (I am using Karaf   4.2.0)
> Any help will be greatly appreciated.
> 
> 
> Best regards,
> Alex soto
> 
> 
> 
> 

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