Re: Problems setting up Karaf with ActiveMQ and Blueprint

2022-05-06 Thread Jean-Baptiste Onofré
By the way, you have a JMS example in Karaf:

https://github.com/apache/karaf/tree/main/examples/karaf-jms-example

I can add JMS endpoint in Camel example if it would help:
https://github.com/apache/karaf/tree/main/examples/karaf-camel-example

Regards
JB

On Fri, May 6, 2022 at 8:22 AM Karsten Blume  wrote:
>
> Hello Heribert,
>
> You need to configure the server AND the client (camel).
>
> It is not sufficient to configure the server only.
>
>
>
> Here: 
> apache-karaf-4.4.0\examples\karaf-jms-example\karaf-jms-example-command\src\main\java\org\apache\karaf\examples\jms\command\SendCommand.java
>
> Is an example on how to use a AMQ connection factory by hand. The connection 
> factory is created by some karaf magic/features and cfg files:
> apache-karaf-4.4.0\examples\karaf-jms-example\karaf-jms-example-features\src\main\feature\feature.xml
>
> This creates you the conn factory, you could use/reference it in your camel 
> context.
>
>
>
> camel-examples\examples\jms-file\src\main\java\org\apache\camel\example\jmstofile\CamelJmsToFileExample.java
>
> Shows how to connect to a JMS server, first by initializing the Camel 
> Jms-Component, then the usage in the route.
>
> In blueprint it could be a reference to the connection factory (which was 
> created by the feature.xml and cfg file) and with that an initialization of 
> the JMS component bean in your blueprint. Then your route is using the 
> component (with whatever name you choose).
>
> Bye
>
> Karsten
>
>
>
>
>
> Von: Steuer Heribert 
> Gesendet: Donnerstag, 5. Mai 2022 15:13
> An: user@karaf.apache.org
> Betreff: AW: Problems setting up Karaf with ActiveMQ and Blueprint
>
>
>
> Hello Karsten,
>
>
>
> thanks for you reply. The default rollout already provides the file 
> ${KARAF_BASE}/etc/org.apache.activemq.server-default.cfg which is also 
> mentioned
>
> in the documentation at https://activemq.apache.org/osgi-integration.html.  
> Also, the activemq.xml file is present in the etc directory and looks okay 
> for me (compared to the one in Servicemix).
>
> Both files are default and I did not touch them.
>
>
>
> Walking through e.g. http://liquid-reality.de/Karaf-Tutorial/05/ leads to the 
> same issue.
>
>
>
> Would be great if you could point me to the right direction ...
>
>
>
>
>
> Cheers,
>
> Heri
>
>
>
>
>
>
>
> 
>
> Von: Karsten Blume 
> Gesendet: Donnerstag, 5. Mai 2022 12:18
> An: user@karaf.apache.org 
> Betreff: AW: Problems setting up Karaf with ActiveMQ and Blueprint
>
>
>
> Hello Heribert,
>
> You need to use the endpoint or the component parameters to define the broker 
> (URL, user, pwd,…).
>
>
>
> You could configure the AMQ component as bean including the above parameters, 
> then all “activemq” endpoints in your context use this.
>
> Or you define all the parameters in the endpoint URL.
>
> The camel and karaf examples for AMQ should give a direction.
>
> BR
>
> Karsten
>
>
>
> Von: Steuer Heribert 
> Gesendet: Donnerstag, 5. Mai 2022 11:41
> An: user@karaf.apache.org
> Betreff: AW: Problems setting up Karaf with ActiveMQ and Blueprint
>
>
>
> Hello Erne,
>
>
>
> thanks for your answer. I tried that already which leads to the same 
> exception (see below), just the endpoint looks a little bit different now.
>
>
>
>
>
> 11:38:38.860 ERROR [Blueprint Event Dispatcher: 1] Error occurred during 
> starting CamelContext: camel-6
>
> org.apache.camel.FailedToCreateRouteException: Failed to create route test: 
> Route(test)[From[activemq:queue:in] -> [Log[PROCESSED MESSAG... because of 
> Failed to resolve endpoint: activemq://queue:in due to: 
> java.lang.IllegalArgumentException: wrong number of arguments
>
>
>
>
>
> Any other ideas?
>
>
>
> Cheers,
>
> Heri
>
>
>
> 
>
> Von: Tasi, Erne 
> Gesendet: Donnerstag, 5. Mai 2022 11:09
> An: user@karaf.apache.org 
> Betreff: AW: Problems setting up Karaf with ActiveMQ and Blueprint
>
>
>
> Sorry, the correct URL to the Documentation would be ActiveMQ :: Apache Camel.
>
> At first I could not send the previous mail and afterwards something went 
> wrong as I copy-pasted my original answer.
>
>
>
> Cheers,
>
> Erne
>
>
>
> Von: Tasi, Erne
> Gesendet: Donnerstag, 5. Mai 2022 10:42
> An: user@karaf.apache.org
> Betreff: AW: Problems setting up Karaf with ActiveMQ and Blueprint
>
>
>
> Hi Heri,
>
>
>
> As the Exception states you did not provide all the needed arguments in you=  
> from and to statements.
>
> According to the documentation ActiveMQ :: Apache Camel e.org/components/3.16.x/activemq-component.html> your Route would have to 
> look something like this:
>
>
>
>   
>
> 
>
> 
>
> 
>
>   
>
>
>
> Best Regards,
>
> Erne
>
>
>
>
>
> Von: Steuer Heribert [mailto:ste...@patronas.com]
> Gesendet: Donnerstag, 5. Mai 2022 09:57
> An: user@karaf.apache.org
> Betreff: Problems setting up Karaf with ActiveMQ and Blueprint
>
>
>
> Hello,
>
>
>
> we are currently trying to upgrade

AW: Exporting an instance of a 3rd party library as service

2022-05-06 Thread Karsten Blume
Hello Geoffrey, Arthur
Thank you for your support regarding this topic. I would like to sum up my 
experience here.

Objective
Is to let client bundles (C) use a preconfigured service of another bundle (S), 
which is implemented by a third bundle or library (I).

In my case this was blueprint bundles
I: the jasypt library as OSGI library, S: my base bundle, C: several camel 
bundles
Service was the org.jasypt.encryption.StringEncryptor interface

Check Manifest files for
S: 
Import-Package: "org.jasypt.encryption" and all implementation packages needed 
to 
Export-Service:  org.jasypt.encryption.StringEncryptor
C: 
Import-Package "org.jasypt.encryption" and 
Import-Service "org.jasypt.encryption.StringEncryptor"
I: 
export all the used packages from above, should be done by implementor or look 
for a servicemix bundle project variant

implementation
all bundles:
maven
use maven-bundle-plugin with *

blueprint
S: 

and instantiate the beans behind the interface (PBE config,...)
C:

and those namespace configuraions you find in the karaf docs

Testing
My default blueprint test context initiates by default a bean, which is 
implementing the StringEncryptor interface. So all references are satisfied.

AND
What happened to me:
Karaf and Camel come with different versions of the jasypt library, ensure that 
you use only one of them for your C bundles. Or in general ensure your I bundle 
is used by S and C at the same time.
Check with the karaf commands 
You have only one version of bundle I (bundle:list or la)
The command "capabilities" shows that your C bundles are connected to the 
correct S bundle.
I achieved that by using the overrides.properties file: 
mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jasypt/1.9.2_1;range="[1,2)"
Perhaps you can control this also by the ; parameter in the 
import-package.

Thanks all and I hope the above helps somebody else
Karsten


-Ursprüngliche Nachricht-
Von: Geoffrey Seanor  
Gesendet: Montag, 4. April 2022 18:18
An: user@karaf.apache.org
Betreff: RE: Exporting an instance of a 3rd party library as service

Hi Karsten,

My encryptor service provider 'bundle' is just a blueprint file installed in 
the deploy folder whose singular purpose is to export the service/interface as 
per the various examples online.

The consumer bundle manifest does Import-Package "org.jasypt.encryption" and 
Import-Service "org.jasypt.encryption.StringEncryptor".
It's also ok to use multiple blueprint files in a single bundle.

The error message you provided shows that you don't have a service providing 
the org.jasypt.encryption.StringEncryptor interface.  Can your 'base' bundle 
provide this?

Regards,

Geoff

-Original Message-
From: Karsten Blume  
Sent: 04 April 2022 14:48
To: user@karaf.apache.org
Subject: AW: Exporting an instance of a 3rd party library as service

Hello Geoffrey,
Yes, I mean there are some examples in the WWW on how to use the encryption.

In my "consumer" bundle I have the service reference and the property 
placeholder in different blueprint files, but this should work, at least it 
works for everything else.

Does your base bundle export the jasypt packages or just the service in the 
Meta-Inf file?
And does your consumer bundle import service and package?
BR
Karsten

-Ursprüngliche Nachricht-
Von: Geoffrey Seanor  
Gesendet: Montag, 4. April 2022 13:59
An: user@karaf.apache.org
Betreff: RE: Exporting an instance of a 3rd party library as service

Hi Karsten,

You base bundle looks ok.

My importing blueprint bundle does the following:

1) References this namespace

xmlns:enc="https://apc01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fkaraf.apache.org%2Fxmlns%2Fjasypt%2Fv1.0.0&data=04%7C01%7Ckarsten.blume%40ottoint.com%7C2c73b1673c6f448baba508da1656b19b%7Cf73d6f0048944b4eba0071d6df45717d%7C0%7C0%7C637846858899141384%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=bh0oeSilmrdJuyAQLRAlbBBnKKzbPE1MeOkRzxWXqeo%3D&reserved=0";

2) Configures the string encryptor service reference



3) To decrypt values like this


The above works with Karaf 4.2.4 and 4.3.6 running on Linux or Win 7, other 
combinations I'm not sure.
(Note that the service id is local to the blueprint container)

Geoff

-Original Message-
From: Karsten Blume  
Sent: 04 April 2022 11:00
To: user@karaf.apache.org
Subject: AW: Exporting an instance of a 3rd party library as service

Hello Jean-Baptiste, Geoffrey
Here are some more details:

runtime err msg
Unable to start blueprint container for bundle order/22.14.0.98-SNAPSHOT due to 
unresolved dependencies [(objectClass=org.jasypt.encryption.StringEncryptor)]
java.util.concurrent.TimeoutException: null ...
this standard exception stacktrace, when a service was not found

I use the maven bundle plugin without import instruction, so it uses * as 
default.
The Meta-Inf shows the service/interface listed in

AW: Problems setting up Karaf with ActiveMQ and Blueprint

2022-05-06 Thread Steuer Heribert
Thanks Karsten,

I will walk through that stuff and hopefully I get things up and running with 
that. As I come from the good old Servicemix days, I was wondering as I do not 
have to configure any kind of
connection factory in the blueprint world (I mainly use blueprint routes, 
rarely in Java). I just use the entpoint as "activemq://queuename" and things 
work.

Nevertheless, I will work through the stuff you provided.

Thanks alot,
Heri


Von: Karsten Blume 
Gesendet: Freitag, 6. Mai 2022 08:22
An: user@karaf.apache.org 
Betreff: AW: Problems setting up Karaf with ActiveMQ and Blueprint


Hello Heribert,

You need to configure the server AND the client (camel).

It is not sufficient to configure the server only.



Here: 
apache-karaf-4.4.0\examples\karaf-jms-example\karaf-jms-example-command\src\main\java\org\apache\karaf\examples\jms\command\SendCommand.java

Is an example on how to use a AMQ connection factory by hand. The connection 
factory is created by some karaf magic/features and cfg files:
apache-karaf-4.4.0\examples\karaf-jms-example\karaf-jms-example-features\src\main\feature\feature.xml

This creates you the conn factory, you could use/reference it in your camel 
context.



camel-examples\examples\jms-file\src\main\java\org\apache\camel\example\jmstofile\CamelJmsToFileExample.java

Shows how to connect to a JMS server, first by initializing the Camel 
Jms-Component, then the usage in the route.

In blueprint it could be a reference to the connection factory (which was 
created by the feature.xml and cfg file) and with that an initialization of the 
JMS component bean in your blueprint. Then your route is using the component 
(with whatever name you choose).

Bye

Karsten





Von: Steuer Heribert 
Gesendet: Donnerstag, 5. Mai 2022 15:13
An: user@karaf.apache.org
Betreff: AW: Problems setting up Karaf with ActiveMQ and Blueprint



Hello Karsten,



thanks for you reply. The default rollout already provides the file 
${KARAF_BASE}/etc/org.apache.activemq.server-default.cfg which is also mentioned

in the documentation at 
https://activemq.apache.org/osgi-integration.html.
  Also, the activemq.xml file is present in the etc directory and looks okay 
for me (compared to the one in Servicemix).

Both files are default and I did not touch them.



Walking through e.g. 
http://liquid-reality.de/Karaf-Tutorial/05/
 leads to the same issue.



Would be great if you could point me to the right direction ...





Cheers,

Heri









Von: Karsten Blume mailto:karsten.bl...@ottoint.com>>
Gesendet: Donnerstag, 5. Mai 2022 12:18
An: user@karaf.apache.org 
mailto:user@karaf.apache.org>>
Betreff: AW: Problems setting up Karaf with ActiveMQ and Blueprint



Hello Heribert,

You need to use the endpoint or the component parameters to define the broker 
(URL, user, pwd,…).



You could configure the AMQ component as bean including the above parameters, 
then all “activemq” endpoints in your context use this.

Or you define all the parameters in the endpoint URL.

The camel and karaf examples for AMQ should give a direction.

BR

Karsten



Von: Steuer Heribert mailto:ste...@patronas.com>>
Gesendet: Donnerstag, 5. Mai 2022 11:41
An: user@karaf.apache.org
Betreff: AW: Problems setting up Karaf with ActiveMQ and Blueprint



Hello Erne,



thanks for your answer. I tried that already which leads to the same exception 
(see below), just the endpoint looks a little bit different now.





11:38:38.860 ERROR [Blueprint Event Dispatcher: 1] Error occurred during 
starting CamelContext: camel-6

org.apache.camel.FailedToCreateRouteException: Failed to create route test: 
Route(test)[From[activemq:queue:in] -> [Log[PROCESSED MESSAG... because of 
Failed to resolve endpoint: activemq://queue:in due to: 
java.lang.IllegalArgumentException: wrong number of arguments





Any other ideas?



Cheers,

Heri





Von: Tasi, Erne mailto:e.t...@cenit.com>>
Gesendet: Donnerstag, 5. Mai 2022 11:09
An: user@karaf.apache.org