Re: Classloading issue with Berkley DB

2024-03-18 Thread Paul Spencer
Will,
This is the intend reply.

I use both Ingres and PostgreSQL databases in my applications and use the JDBC 
api to interact with the database.  To do this, I created in 
IngresDataSourceFactory that implements 
org.osgi.service.jdbc.DataSourceFactory.DataSourceFactory bundle so my 
application bundles just @Reference Datasource.  I also loaded the Ingres JDBC 
driver as a wrapped jar, `bundle:install wrap:mvn:` Karaf/OSGi and 
configuration take care of the rest after the datasource is in Karaf is 
created.  

See the following.
  
https://karaf.apache.org/manual/latest/#_creating_bundles_for_non_osgi_third_party_dependencies
  https://karaf.apache.org/manual/latest/#_datasources_jdbc

Paul Spencer



Classloading issue with Berkley DB

2024-03-18 Thread Paul Spencer
We're using BerkelyDB within our application.

I did not look too hard for an OSGI module for it, it wasn't readily apparent, 
so I just hamfisted one by taking their jar and using bnd to create a bundle 
from it.

But there's a curious issue.

We have code like this:

final DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(false);
dbConfig.setAllowCreate(allowCreate);
dbConfig.setReadOnly(readOnly);
dbConfig.setDeferredWrite(true);
dbConfig.setBtreeComparator(new KeyComparator());

But when I call this:

this.queueDatabase = dbEnv.openDatabase(null, queueName, dbConfig);

I get a Class Not Found exception. It can not find the KeyComparator class 
(which is a local class to this class that's starting the DB).

Well, it seems from a glance at the stack trace, that the BDB is serializing 
the comparator, and trying to read it back.

Caused by: com.sleepycat.je.EnvironmentFailureException: (JE 18.3.12) Exception 
while trying to load BtreeComparator UNEXPECTED_EXCEPTION: Unexpected internal 
Exception, may have side effects.
at 
com.sleepycat.je.EnvironmentFailureException.unexpectedException(EnvironmentFailureException.java:384)
at com.sleepycat.je.dbi.DatabaseImpl.bytesToObject(DatabaseImpl.java:1957)
at 
com.sleepycat.je.dbi.DatabaseImpl$ComparatorReader.(DatabaseImpl.java:2002)
at com.sleepycat.je.dbi.DatabaseImpl.initWithEnvironment(DatabaseImpl.java:390)
at com.sleepycat.je.dbi.DatabaseImpl.(DatabaseImpl.java:247)
at com.sleepycat.je.dbi.DbTree.doCreateDb(DbTree.java:593)
at com.sleepycat.je.dbi.DbTree.createDb(DbTree.java:486)
at com.sleepycat.je.Database.initNew(Database.java:174)
at com.sleepycat.je.Environment.setupDatabase(Environment.java:864)
at com.sleepycat.je.Environment.openDatabase(Environment.java:668)
at com.qpoint.caterwaul.connect.queue.BDBQueue.(BDBQueue.java:88)
at com.qpoint.caterwaul.connect.queue.BDBQueue.(BDBQueue.java:52)
at com.qpoint.caterwaul.connect.queue.RichBDBQueue.(RichBDBQueue.java:49)
at 
com.qpoint.caterwaul.connect.queue.TickEventOrchestrator.start(TickEventOrchestrator.java:87)
at com.qpoint.caterwaul.connect.core.CWCore.initialize(CWCore.java:168)
... 9 more
Caused by: java.lang.ClassNotFoundException: 
com.qpoint.caterwaul.connect.queue.KeyComparator
at 
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at 
java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:488)
at java.base/java.lang.Class.forName(Class.java:467)
at com.sleepycat.util.ClassResolver$Stream.resolveClass(ClassResolver.java:74)
at 
java.base/java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:2058)
at 
java.base/java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1922)
at 
java.base/java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:2248)
at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1757)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:538)
at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:496)
at com.sleepycat.je.dbi.DatabaseImpl.bytesToObject(DatabaseImpl.java:1954)
... 22 more

We see that it's calling the ObjectInputStream readObject. Which means it 
serialized the KeyComparator instance somewhere.

Now, I can't fathom why this is happening, seems an odd decision, but it's 
clear to me that it's trying to do this from within the BDB bundle, and ITS 
classloader, rather than the bundle classloader where it's being initialized. 
That would explain why it can't find the class.

So, do I need to somehow tweak the BDB bundle to import the KeyComparator 
class? Won't this be a circular dependency (my module depends on BDB which 
depends on my module), unless, of course, I break out my KeyComparator class 
into -- I don't know what I would break it into, seems a bit much to make it 
its own bundle.

While the solution would be appreciated, how are problems like this approached? 
I imagine there's rules of thumb or a top 5 "do this kind of thing" that is 
used to approach classpath issues with OSGI and Karaf.

Thanks so much.

Regards,

Will Hartung



[Studio] ApacheDS 2.0.0 LDAP Server starts and shutdowns immediately with 2.0.0-SNAPSHOT.

2024-02-24 Thread Paul Spencer
Directory Studio 2.0.0-SNAPSHOT from the master branch cloned February 24, 2024
Apple MacBook Air M2
macOS Sonoma 14.2.1

I have build and run the Directory Studio from the source in accordance with 
the instructions in README.md. 

After starting the application, I created an ApacheDS 2.0.0 LDAP Server 
accepting all of the defaults.  The server starts then immediately shuts down.

I have reviewed the log files, but no errors were reported.   

Should I expect this SNAPSHOT version to startup? 

If so, where should I look to determine why the server is shutting down? 


***
* From apachds.log.
***
13:28:43] INFO [org.apache.directory.server.UberjarMain] - Starting the service.
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.DefaultAttribute] - 
ERR_13207_VALUE_ALREADY_EXISTS The value '1.3.6.1.4.1.42.2.27.8.5.1' already 
exists in the attribute (supportedControl)
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.DefaultAttribute] - 
ERR_13207_VALUE_ALREADY_EXISTS The value '1.2.840.113556.1.4.841' already 
exists in the attribute (supportedControl)
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.DefaultAttribute] - 
ERR_13207_VALUE_ALREADY_EXISTS The value '1.3.6.1.4.1.4203.1.9.1.2' already 
exists in the attribute (supportedControl)
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.DefaultAttribute] - 
ERR_13207_VALUE_ALREADY_EXISTS The value '1.2.840.113556.1.4.319' already 
exists in the attribute (supportedControl)
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.DefaultAttribute] - 
ERR_13207_VALUE_ALREADY_EXISTS The value '1.2.840.113556.1.4.528' already 
exists in the attribute (supportedControl)
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.Value] - 
MSG_13202_AT_IS_NULL ()
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.Value] - 
MSG_13202_AT_IS_NULL ()
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.Value] - 
MSG_13202_AT_IS_NULL ()
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.Value] - 
MSG_13202_AT_IS_NULL ()
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.Value] - 
MSG_13202_AT_IS_NULL ()
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.Value] - 
MSG_13202_AT_IS_NULL ()
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.Value] - 
MSG_13202_AT_IS_NULL ()
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.Value] - 
MSG_13202_AT_IS_NULL ()
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.Value] - 
MSG_13202_AT_IS_NULL ()
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.Value] - 
MSG_13202_AT_IS_NULL ()
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.Value] - 
MSG_13202_AT_IS_NULL ()
[13:28:44] WARN [org.apache.directory.api.ldap.model.entry.Value] - 
MSG_13202_AT_IS_NULL ()
[13:28:44] WARN [org.apache.directory.server.core.DefaultDirectoryService] - 
You didn't change the admin password of directory service instance 'default'.  
Please update the admin password as soon as possible to prevent a possible 
security breach.

***
* Excepts from apachds.log with DEBUG logging enabled.
***
[13:00:33] WARN [org.apache.directory.server.core.DefaultDirectoryService] - 
You didn't change the admin password of directory service instance 'default'.  
Please update the admin password as soon as possible to prevent a possible 
security breach.
[13:00:33] INFO [org.apache.directory.server.ApacheDsService] - 
DirectoryService initialized in 2448 milliseconds
[13:00:33] DEBUG [org.apache.directory.server.core.DefaultDirectoryService] - 
+++ DirectoryService Shutdown required

Paul Spencer



Documentation to enable password encryption for the PropertiesLoginModule does not result in encrypted passwords

2024-02-02 Thread Paul Spencer
Karaf 4.4.5

The documentation to enable password encryption for the PropertiesLoginModule 
does not result in encryption passwords in the properties files.  The 
encryption prefix and suffix configuration properties must be set in the 
jaas:module blueprint descriptor.

https://karaf.apache.org/manual/latest/#_encryption_service

Is the requirement to define encryption.prefix and encryption.suffix in 
jaas:module missing from the documentation?
Are the encryption.prefix and encryption.suffix not correctly defaulted?


The following encrypts passwords user passwords
***
* deploy/foo_realm.xml
***

http://www.osgi.org/xmlns/blueprint/v1.0.0;
   xmlns:jaas="http://karaf.apache.org/xmlns/jaas/v1.0.0;
   
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0;>






users = $[karaf.base]/etc/foo.users.properties
encryption.enabled = true
encryption.prefix = ENC(
encryption.suffix = )
encryption.algorithm = MD5
encryption.encoding = hexadecimal






***
* etc/foo.users.properties
***
foo = ENC(37B51D194A7513E45B56F6524F2D51F2)

Paul Spencer

Re: Realm created via jaas:realm-add go away after karaf restart

2024-02-01 Thread Paul Spencer
Ciprian,
Thank you. I found the following supporting documentation and was able to 
create a new realms.
  https://karaf.apache.org/manual/latest/#_available_realm_and_login_modules

Paul Spencer

 
On 2024/01/31 15:15:32 Ciprian Ciubotariu wrote:
> I had solved this by deploying a blueprint bundle on the lines of:
> 
> http://www.osgi.org/xmlns/blueprint/v1.0.0; 
>xmlns:jaas="http://karaf.apache.org/xmlns/jaas/v1.0.0;>
> 
>  className="org.apache.karaf.jaas.modules.properties.PropertiesLoginModule"
>  flags="required" />
> 
> 
> 
> (I had my own custom JAAS class, but for this snippet I put the 
> PropertiesLoginModule instead.
> 
> Ciprian
> 
> On Tuesday, 30 January 2024 22:21:52 EET Paul Spencer wrote:
> > Karaf 4.4.5
> > JVM  OpenJDK 64-Bit Server VM version 11.0.2+9
> > 
> > A realm created via jaas:realm-add is not listed after karaf restart.  This 
> > may be related to KARAF-7602.
> > 
> > - Create the realm using the following commands:
> > 
> > jaas:realm-add myrealm 
> > org.apache.karaf.jaas.modules.properties.PropertiesLoginModule users 
> > "etc/bugdataRestUser.properties"
> > jaas:realm-manage --realm myrealm --module 
> > org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
> > jaas:update
> > 
> > -  The command jaas:realm-list will include the realm myrealm
> > 
> > karaf@root()> jaas:realm-list
> > Index │ Realm Name │ Login Module Class Name
> > ──┼┼───
> > 1 │ karaf  │ 
> > org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
> > 2 │ karaf  │ 
> > org.apache.karaf.jaas.modules.publickey.PublickeyLoginModule
> > 3 │ karaf  │ 
> > org.apache.karaf.jaas.modules.audit.FileAuditLoginModule
> > 4 │ karaf  │ org.apache.karaf.jaas.modules.audit.LogAuditLoginModule
> > 5 │ karaf  │ 
> > org.apache.karaf.jaas.modules.audit.EventAdminAuditLoginModule
> > 6 │ myrealm│ 
> > org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
> > 
> > - Restart the karaf instance
> > The new realm is not listed by the command jaas:realm-list
> > 
> > karaf@root()> jaas:realm-list
> > Index │ Realm Name │ Login Module Class Name
> > ──┼┼───
> > 1 │ karaf  │ 
> > org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
> > 2 │ karaf  │ 
> > org.apache.karaf.jaas.modules.publickey.PublickeyLoginModule
> > 3 │ karaf  │ 
> > org.apache.karaf.jaas.modules.audit.FileAuditLoginModule
> > 4 │ karaf  │ org.apache.karaf.jaas.modules.audit.LogAuditLoginModule
> > 5 │ karaf  │ 
> > org.apache.karaf.jaas.modules.audit.EventAdminAuditLoginModule
> > karaf@root()>   
> > 
> > Is this bug?
> > 
> > Paul Spencer
> > 
> > 
> >  
> > 
> 
> 


Realm created via jaas:realm-add go away after karaf restart

2024-01-30 Thread Paul Spencer
Karaf 4.4.5
JVM  OpenJDK 64-Bit Server VM version 11.0.2+9

A realm created via jaas:realm-add is not listed after karaf restart.  This may 
be related to KARAF-7602.

- Create the realm using the following commands:

jaas:realm-add myrealm 
org.apache.karaf.jaas.modules.properties.PropertiesLoginModule users 
"etc/bugdataRestUser.properties"
jaas:realm-manage --realm myrealm --module 
org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
jaas:update

-  The command jaas:realm-list will include the realm myrealm

karaf@root()> jaas:realm-list
Index │ Realm Name │ Login Module Class Name
──┼┼───
1 │ karaf  │ 
org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
2 │ karaf  │ 
org.apache.karaf.jaas.modules.publickey.PublickeyLoginModule
3 │ karaf  │ org.apache.karaf.jaas.modules.audit.FileAuditLoginModule
4 │ karaf  │ org.apache.karaf.jaas.modules.audit.LogAuditLoginModule
5 │ karaf  │ 
org.apache.karaf.jaas.modules.audit.EventAdminAuditLoginModule
6 │ myrealm│ 
org.apache.karaf.jaas.modules.properties.PropertiesLoginModule

- Restart the karaf instance
The new realm is not listed by the command jaas:realm-list

karaf@root()> jaas:realm-list
Index │ Realm Name │ Login Module Class Name
──┼┼───
1 │ karaf  │ 
org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
2 │ karaf  │ 
org.apache.karaf.jaas.modules.publickey.PublickeyLoginModule
3 │ karaf  │ org.apache.karaf.jaas.modules.audit.FileAuditLoginModule
4 │ karaf  │ org.apache.karaf.jaas.modules.audit.LogAuditLoginModule
5 │ karaf  │ 
org.apache.karaf.jaas.modules.audit.EventAdminAuditLoginModule
karaf@root()>   

Is this bug?

Paul Spencer


 

[jira] [Commented] (KARAF-7602) jaas:module-add fails to load org.apache.karaf.jaas.modules.properties.PropertiesLoginModule class

2024-01-30 Thread Paul Spencer (Jira)


[ 
https://issues.apache.org/jira/browse/KARAF-7602?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17812455#comment-17812455
 ] 

Paul Spencer commented on KARAF-7602:
-

I am also seeing this error in Karaf 4.4.5.

JVM
  Java Virtual Machine        OpenJDK 64-Bit Server VM version 11.0.2+9
  Version                     11.0.2
  Vendor                      Oracle Corporation

Operating system
  Name                        Mac OS X version 10.16
  Architecture                x86_64

> jaas:module-add fails to load 
> org.apache.karaf.jaas.modules.properties.PropertiesLoginModule class
> --
>
> Key: KARAF-7602
> URL: https://issues.apache.org/jira/browse/KARAF-7602
> Project: Karaf
>  Issue Type: Bug
>Reporter: Rajan
>Assignee: Jean-Baptiste Onofré
>Priority: Major
>
> jaas:module-add fails to load 
> org.apache.karaf.jaas.modules.properties.PropertiesLoginModule class
>  
> {code:java}
> karaf@root()> jaas:realm-list
> Index │ Realm Name │ Login Module Class Name
> ──┼┼───
> 1 │ karaf  │ 
> org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
> 2 │ karaf  │ 
> org.apache.karaf.jaas.modules.publickey.PublickeyLoginModule
> 3 │ karaf  │ org.apache.karaf.jaas.modules.audit.FileAuditLoginModule
> 4 │ karaf  │ org.apache.karaf.jaas.modules.audit.LogAuditLoginModule
> 5 │ karaf  │ 
> org.apache.karaf.jaas.modules.audit.EventAdminAuditLoginModule
> 6 │ myrealm    │ 
> org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
> 7 │ myrealm1   │ 
> org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
>  
> karaf@root()> jaas:realm-manage --index 6
> {code}
>  
> {code:java}
> karaf@root()> jaas:module-add 
> org.apache.karaf.jaas.modules.properties.PropertiesLoginModule users 
> "/tmp/users"
> Module class 'org.apache.karaf.jaas.modules.properties.PropertiesLoginModule' 
> is unknown!
> Error executing command: Module class 
> 'org.apache.karaf.jaas.modules.properties.PropertiesLoginModule' is unknown!
>  
> root@mylab:~/apache-karaf-4.4.1# tail -n 100 ./data/log/karaf.log
> ...
> 2022-10-29T14:35:17,185 | ERROR | Karaf ssh console user karaf | ShellUtil
>     | 44 - org.apache.karaf.shell.core - 4.4.1 | Exception 
> caught while executing command
> java.lang.IllegalArgumentException: Module class 
> 'org.apache.karaf.jaas.modules.properties.PropertiesLoginModule' is unknown!
>     at 
> org.apache.karaf.jaas.command.ModuleAddCommand.execute(ModuleAddCommand.java:68)
>  ~[?:?]
>     at 
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>  ~[?:?]
>     at 
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>  ~[?:?]
>     at 
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>  ~[?:?]
>     at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599) 
> ~[?:?]
>     at 
> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526) 
> ~[?:?]
>     at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415) 
> ~[?:?]
>     at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416) ~[?:?]
>     at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) ~[?:?]
>     at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) ~[?:?]
>     at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
> ~[?:1.8.0_342]
>     at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>  ~[?:1.8.0_342]
>     at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>  ~[?:1.8.0_342]
>     at java.lang.Thread.run(Thread.java:750) ~[?:1.8.0_342]
> {code}
>  
>  
> The class is available in 
> ./system/org/apache/karaf/jaas/org.apache.karaf.jaas.modules/4.4.1/org.apache.karaf.jaas.modules-4.4.1.jar
>  
> {code:java}
> root@mylab:~/apache-karaf-4.4.1# jar -tvf 
> ./system/org/apache/karaf/jaas/org.apache.karaf.jaas.modules/4.4.1/org.apache.karaf.jaas.modules-4.4.1.jar
>  | grep PropertiesLoginModule
>   5788 Fri Feb 01 00:00:00 UTC 1980 
> org/apache/karaf/jaas/modules/properties/PropertiesLoginModule.class
>  
> {code}
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


Re: How do I protect a OSGi JAX-RS whiteboard REST service using Basic Authentication?

2024-01-30 Thread Paul Spencer
Steinar,
Apologies for misspelling your name.

I have not opened an issue related to the dependencies.

Paul Spencer
 

> On Jan 30, 2024, at 11:19 AM, Steinar Bang  wrote:
> 
>>>>>> Paul Spencer :
> 
>> Steiner,
> 
> (ps last "e" is an "a", "Steinar", approximate pronounciation
> "Stay-nahr" (with the "r" rolling as in Scots or Spanish or Italian)) ;-)
> 
>> I installed the feature shiro-core and had to add had to install the 
>> following bundles.
>>   mvn:commons-collections/commons-collections/3.2.2
>>   mvn:commons-beanutils/commons-beanutils/1.9.4
>>   mvn:org.apache.shiro/shiro-config-core/1.13.0
> 
> Thanks! 
> 
> Looks like I have added two of them to an authservice feature that is
> loaded directly or indirectly by all the users of authservice, which
> mean they are always present for other users:
> https://github.com/steinarb/authservice/blob/master/authservice/authservice.web.security/src/main/feature/feature.xml#L7
> 
> (Maybe I should make that dependency more explicit in the other
> applications, but they won't work unless authservice is present anyway,
> so...? )
> 
> I do not AFAICT load shiro-config-core.
> 
> Have you opened an issue with Shiro about these bundles missing from the
> feature?
> 
> If not, I could do so.
> 
> Thanks!
> 
> 
> - Steinar
> 



Re: How do I protect a OSGi JAX-RS whiteboard REST service using Basic Authentication?

2024-01-30 Thread Paul Spencer
Steiner,

I installed the feature shiro-core and had to add had to install the following 
bundles.
   mvn:commons-collections/commons-collections/3.2.2
   mvn:commons-beanutils/commons-beanutils/1.9.4
   mvn:org.apache.shiro/shiro-config-core/1.13.0


Paul Spencer

> On Jan 30, 2024, at 8:48 AM, Steinar Bang  wrote:
> 
>>>>>> Paul Spencer :
> 
>> Steiner,
>> Just a followup:
> 
>> - The Shiro 1.13.0 feature is missing required Shiro and Apache commons 
>> bundles, which may be resolved in 2.0 alpha, as well as the config package 
>> is split across multiple bundles, described in SHIRO-654 and also resolved 
>> in 2.0 alpha. So despite your examples, I was not able to get version 1.13.0 
>> working.
> 
> Hi,
> 
> Do you have a list of the missing dependencies in the shiro 1.13.0 feature?
> 
> Ie, groupId/artifactId/version for the missing dependencies?
> 
> (I wonder why I haven't run into that? Or if I have: how I've fixed it (and 
> forgot about it...)?)
> 



Re: How do I protect a OSGi JAX-RS whiteboard REST service using Basic Authentication?

2024-01-29 Thread Paul Spencer
Ciprian,
This has gotten me closer, as my REST implementation is now able to see the 
Principal in requestContext.getSecurityContext().getUserPrincipal() in filters. 
 

The Principal in REST API remains null. An example REST API is 
listCustomer(@Context HttpServletRequest servletRequest) and 
servletRequest.getUserPrincipal() return null.

I created an authorization filter that:
- validates the user credentials and creates customUserPrincipal with the 
username and roles
- Creates a customerSecurityContext passing in the customUserPrincipal, or null 
if no authorization header existed.
- Set the security context of the requestContext to the newly created 
customerSecurityContext.

I also created an authentication filter that uses the security context from the 
requestContext and verifier the roles, as declared via 
javax.annotation.security, using the same logic as described in "Jersey REST 
API Security Example".

Paul Spencer

> On Jan 29, 2024, at 12:00 PM, Ciprian Ciubotariu  wrote:
> 
> The way I have done it in the past is to set the security context with a 
> custom implementation on the authentication success path, such as:
> 
>requestContext.setSecurityContext(new 
> CustomSecurityContext(username));
> 
> and have a class implementing the security context, and another the user 
> principal.
> 
> public class CustomSecurityContext implements SecurityContext {
> 
>private CustomUserPrincipal principal;
> 
>CustomSecurityContext(String username) {
>   this.principal = new CustomUserPrincipal(username);
>}
> 
>@Override
>public Principal getUserPrincipal() {
>return principal;
>}
> 
> 
> }
> 
> This could be extended with more data for authorization (roles etc), or 
> perhaps you can find a stock library that already suits your needs.
> 
> Ciprian
> 
> 
> On Monday, 29 January 2024 18:43:40 EET Paul Spencer wrote:
>> Steiner,
>> Just a followup:
>> 
>> - The Shiro 1.13.0 feature is missing required Shiro and Apache commons 
>> bundles, which may be resolved in 2.0 alpha, as well as the config package 
>> is split across multiple bundles, described in SHIRO-654 and also resolved 
>> in 2.0 alpha. So despite your examples, I was not able to get version 1.13.0 
>> working.
>> 
>> - aries-jax-rs-whiteboard-shiro v2.0.2 feature installs, but I could not get 
>> the realm configuration working, as I was unable to find examples.
>> 
>> - Jersey REST API Security Example, 
>> https://howtodoinjava.com/jersey/jersey-rest-security/, provided a way to 
>> utilize the javax.annotation.security annotations and 
>> authentication/authorization stored in a database.  This implementation is 
>> simply a filter that does the authentication/authorization and updates the 
>> response with the appropiate success or fail code. It does not set the user 
>> principle in the session.
>> 
>> 
>> At this point I am utilizing the "Jersey REST API Security Example" because:
>> - JAXRS Service is utilizing standard security annotations.
>> - My implementation is for internal use only and protected behind firewalls.
>> - I am out of time.
>> 
>> 
>> I will continue to look for a solution that leverage the OSGi JAX-RS 
>> whiteboard REST service and the security services within Karaf as time 
>> becomes available.
>> 
>> Paul Spencer
>> 
>> 
>> 
>>> On Jan 24, 2024, at 5:08 PM, Paul Spencer  wrote:
>>> 
>>> Steinar,
>>> This helps!
>>> 
>>> Paul Spencer
>>> 
>>> On 2024/01/24 12:38:27 Steinar Bang wrote:
>>>>>>>>> Paul Spencer :
>>>> 
>>>>> Karaf 4.4.5
>>>>> How do I protect a OSGi JAX-RS whiteboard REST service using Basic 
>>>>> Authentication?
>>>> 
>>>> Apache Shiro can do basic auth (among other things).
>>>> https://shiro.apache.org
>>>> 
>>>> This project is a shiro realm with a simple JDBC database and a react.js
>>>> frontend to to user management:
>>>> https://github.com/steinarb/authservice
>>>> 
>>>> You can install it directly in karaf by installing it's karaf feature
>>>> (the feature and all bundles are released to maven central, and is
>>>> released under APLv2).
>>>> 
>>>> Some web whiteboard projects using authservice for users and roles and
>>>> stuff:
>>>> https://github.com/steinarb/oldalbum/blob/master/oldalbum.web.security/src/main/resources/shiro.ini
>>>> https://github.com/steinarb/ukel

Re: How do I protect a OSGi JAX-RS whiteboard REST service using Basic Authentication?

2024-01-29 Thread Paul Spencer
Steiner,
Just a followup:

- The Shiro 1.13.0 feature is missing required Shiro and Apache commons 
bundles, which may be resolved in 2.0 alpha, as well as the config package is 
split across multiple bundles, described in SHIRO-654 and also resolved in 2.0 
alpha. So despite your examples, I was not able to get version 1.13.0 working.

- aries-jax-rs-whiteboard-shiro v2.0.2 feature installs, but I could not get 
the realm configuration working, as I was unable to find examples.

- Jersey REST API Security Example, 
https://howtodoinjava.com/jersey/jersey-rest-security/, provided a way to 
utilize the javax.annotation.security annotations and 
authentication/authorization stored in a database.  This implementation is 
simply a filter that does the authentication/authorization and updates the 
response with the appropiate success or fail code. It does not set the user 
principle in the session.


At this point I am utilizing the "Jersey REST API Security Example" because:
- JAXRS Service is utilizing standard security annotations.
- My implementation is for internal use only and protected behind firewalls.
- I am out of time.


I will continue to look for a solution that leverage the OSGi JAX-RS whiteboard 
REST service and the security services within Karaf as time becomes available.

Paul Spencer



> On Jan 24, 2024, at 5:08 PM, Paul Spencer  wrote:
> 
> Steinar,
> This helps!
> 
> Paul Spencer
> 
> On 2024/01/24 12:38:27 Steinar Bang wrote:
>>>>>>> Paul Spencer :
>> 
>>> Karaf 4.4.5
>>> How do I protect a OSGi JAX-RS whiteboard REST service using Basic 
>>> Authentication?
>> 
>> Apache Shiro can do basic auth (among other things).
>> https://shiro.apache.org
>> 
>> This project is a shiro realm with a simple JDBC database and a react.js
>> frontend to to user management:
>> https://github.com/steinarb/authservice
>> 
>> You can install it directly in karaf by installing it's karaf feature
>> (the feature and all bundles are released to maven central, and is
>> released under APLv2).
>> 
>> Some web whiteboard projects using authservice for users and roles and
>> stuff:
>> https://github.com/steinarb/oldalbum/blob/master/oldalbum.web.security/src/main/resources/shiro.ini
>> https://github.com/steinarb/ukelonn/blob/master/ukelonn.web.security/src/main/resources/shiro.ini
>> https://github.com/steinarb/handlelapp/blob/master/handlelapp.web.security/src/main/resources/shiro.ini
>> https://github.com/steinarb/sampleapp/blob/master/sampleapp.web.security/src/main/resources/shiro.ini
>> 
>> None of them use basic auth, but that should basically (pun not
>> intended) just be to replace "authc" with "authcBasic".
>> 
>> Later specific definitions in the [url] sections, will override earlier
>> more generic definitions.  So you can block the API requiring a loging
>> of a user with a certain role, and then open up for e.g. login or login
>> state check endpoints.
>> 
>> (The reason for anon access of many rest endpoints is to avoid 302
>> redirects on REST API calls I need to do before logging in, because web
>> browsers don't handle 302 redirects on REST API calls real well)
>> 
>> 



Re: How do I protect a OSGi JAX-RS whiteboard REST service using Basic Authentication?

2024-01-24 Thread Paul Spencer
Steinar,
This helps!

Paul Spencer

On 2024/01/24 12:38:27 Steinar Bang wrote:
> >>>>> Paul Spencer :
> 
> > Karaf 4.4.5
> > How do I protect a OSGi JAX-RS whiteboard REST service using Basic 
> > Authentication?
> 
> Apache Shiro can do basic auth (among other things).
>  https://shiro.apache.org
> 
> This project is a shiro realm with a simple JDBC database and a react.js
> frontend to to user management:
>  https://github.com/steinarb/authservice
> 
> You can install it directly in karaf by installing it's karaf feature
> (the feature and all bundles are released to maven central, and is
> released under APLv2).
> 
> Some web whiteboard projects using authservice for users and roles and
> stuff:
>  
> https://github.com/steinarb/oldalbum/blob/master/oldalbum.web.security/src/main/resources/shiro.ini
>  
> https://github.com/steinarb/ukelonn/blob/master/ukelonn.web.security/src/main/resources/shiro.ini
>  
> https://github.com/steinarb/handlelapp/blob/master/handlelapp.web.security/src/main/resources/shiro.ini
>  
> https://github.com/steinarb/sampleapp/blob/master/sampleapp.web.security/src/main/resources/shiro.ini
> 
> None of them use basic auth, but that should basically (pun not
> intended) just be to replace "authc" with "authcBasic".
> 
> Later specific definitions in the [url] sections, will override earlier
> more generic definitions.  So you can block the API requiring a loging
> of a user with a certain role, and then open up for e.g. login or login
> state check endpoints.
> 
> (The reason for anon access of many rest endpoints is to avoid 302
> redirects on REST API calls I need to do before logging in, because web
> browsers don't handle 302 redirects on REST API calls real well)
> 
> 


How do I protect a OSGi JAX-RS whiteboard REST service using Basic Authentication?

2024-01-23 Thread Paul Spencer
Karaf 4.4.5

How do I protect a OSGi JAX-RS whiteboard REST service using Basic 
Authentication?

Using the default "karaf" realm, this should fail with a HTTP Response code 401 
- Unauthorized
  curl --user foo:bar http://localhost:8080/myRestApi/messageLog/

Using the default "karaf" realm, this should succeed with a HTTP Response code 
200 - OK
  curl --user karaf:karaf http://localhost:8080/myRestApi/messageLog/


***
* Example Protected REST api call /messageLog/
***
@DeclareRoles("ADMIN")
@DenyAll
@Path("/messageLog")
@Component(service = MessageLog.class)
@JaxrsResource
@JaxrsApplicationSelect("(osgi.jaxrs.name=myRestApi)")
public class MessageLog {

@RolesAllowed("ADMIN")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/")
public Response getMessageLog() {
// Only users with the Role "ADMIN" can execute method.
...
}
}

Paul Spencer




Re: Karaf 4.4.5 - What is the feature or bundle to resolve javax.annotation.security version>=1.3.0 ?

2024-01-22 Thread Paul Spencer
Bundle 0 does export javax.annotation;version=1.3.0 but is missing 
javax.annotation.security.  

Adding  javax.annotation.security;version="1.3" to  etc/jre.properties appears 
to resolve this issue.

***
* Current etc/jre.properties
***
jre-9= \
...
 javax.annotation;version="1.3", \
 javax.annotation.processing;version="1.0", \
...

***
* Patached etc/jre.properties
***
jre-9= \
...
 javax.annotation;version="1.3", \
 javax.annotation.security;version="1.3", \ 
 javax.annotation.processing;version="1.0", \
...


I have reported this as KARAF-7802

Paul Spencer

> On Jan 22, 2024, at 7:59 AM, Łukasz Dywicki  wrote:
> 
> Hello Paul,
> I believe you might face issues with jakarta vs javax namespaces. There is a 
> ongoing move from javax to jakarta and some of well known annotations might 
> be missing at runtime.
> Please double check if your runtime consist of javax.annotation.security 
> package.
> 
> Best,
> Łukasz
> 
> On 19.01.2024 20:41, Paul Spencer wrote:
>> Karaf 4.4.5
>> I am looking to implement security on a REST endpoint
>> @DeclareRoles("message-view")
>> @RolesAllowed("message-view")
>> @Path("/messageLog")
>> @Component(service = MessageLog.class)
>> @JaxrsResource
>> @JaxrsApplicationSelect("(osgi.jaxrs.name=myApi)")
>> public class MessageLog {
>> private static final Logger LOGGER = 
>> LoggerFactory.getLogger(MessageLog.class);
>> @GET
>> @Produces(MediaType.APPLICATION_JSON)
>> @Path("/")
>> public Response getMessageLog() {
>> ...
>> }
>> When I added @DeclareRoles("message-view") @RolesAllowed("message-view") 
>> installing the bundle results in
>> Error executing command: Unable to resolve com.foo.msg-rest [162](R 162.1): 
>> missing requirement [foo.bar.msg-rest [162](R 162.1)] osgi.wiring.package; 
>> (&(osgi.wiring.package=javax.annotation.security)(version>=1.3.0)(!(version>=2.0.0)))
>>  Unresolved requirements: [[foo.bar.msg-rest [162](R 162.1)] 
>> osgi.wiring.package; 
>> (&(osgi.wiring.package=javax.annotation.security)(version>=1.3.0)(!(version>=2.0.0)))]
>> I suspect this because I have not installed a required feature or bundle.  
>> What is the the required feature or bundle?
>> Paul Spencer



[jira] [Created] (KARAF-7802) javax.annotation.security is missing from etc/jre.properties

2024-01-22 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7802:
---

 Summary: javax.annotation.security is missing from 
etc/jre.properties
 Key: KARAF-7802
 URL: https://issues.apache.org/jira/browse/KARAF-7802
 Project: Karaf
  Issue Type: Bug
  Components: karaf
Affects Versions: 4.4.5
Reporter: Paul Spencer


The packages javax.annotation.security is missing from etc/jre.properties for 
jre-9.  The implementation is currently provided by 
lib/jdk9plus/javax.annotation-api-1.3.2.jar

KARAF-7735 deals with moving java.annotation out of etc/jre.properties, so its 
resolution should include javax.annotation.security



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


Karaf 4.4.5 - What is the feature or bundle to resolve javax.annotation.security version>=1.3.0 ?

2024-01-19 Thread Paul Spencer
Karaf 4.4.5 
I am looking to implement security on a REST endpoint

@DeclareRoles("message-view")
@RolesAllowed("message-view")
@Path("/messageLog")
@Component(service = MessageLog.class)
@JaxrsResource
@JaxrsApplicationSelect("(osgi.jaxrs.name=myApi)")
public class MessageLog {
private static final Logger LOGGER = 
LoggerFactory.getLogger(MessageLog.class);

@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/")
public Response getMessageLog() {
...
}

When I added @DeclareRoles("message-view") @RolesAllowed("message-view") 
installing the bundle results in 

Error executing command: Unable to resolve com.foo.msg-rest [162](R 162.1): 
missing requirement [foo.bar.msg-rest [162](R 162.1)] osgi.wiring.package; 
(&(osgi.wiring.package=javax.annotation.security)(version>=1.3.0)(!(version>=2.0.0)))
 Unresolved requirements: [[foo.bar.msg-rest [162](R 162.1)] 
osgi.wiring.package; 
(&(osgi.wiring.package=javax.annotation.security)(version>=1.3.0)(!(version>=2.0.0)))]

I suspect this because I have not installed a required feature or bundle.  What 
is the the required feature or bundle?

Paul Spencer 

[jira] [Created] (KARAF-7798) Documentation to add headers to the wrap deployer missing escape character

2024-01-12 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7798:
---

 Summary: Documentation to add headers to the wrap deployer missing 
escape character
 Key: KARAF-7798
 URL: https://issues.apache.org/jira/browse/KARAF-7798
 Project: Karaf
  Issue Type: Improvement
  Components: karaf
Affects Versions: 4.4.5, 4.4.4
 Environment: Karaf 4.4.4
MacOS 12.7
Reporter: Paul Spencer


The documentation to add headers to the wrap deployer is missing the escape 
character required by some OS.

[https://karaf.apache.org/manual/latest/#_wrap_deployer]

The example:

{{bundle:install -s 
'wrap:mvn:jboss/jbossall-client/4.2.3.GA/$Bundle-SymbolicName=jbossall-client=4.2.3.GA=org.jboss.remoting;version="4.2.3.GA",!*'}}

should be:

{{bundle:install -s 
'wrap:mvn:jboss/jbossall-client/4.2.3.GA\$Bundle-SymbolicName=jbossall-client\=4.2.3.GA=org.jboss.remoting;version="4.2.3.GA",!*'}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


Re: TomeEE official maven repo

2024-01-10 Thread Paul Spencer
The Tomee 9.1.2 distribution and jars exist in 
https://repo.maven.apache.org/maven2/org/apache/tomee/apache-tomee/
The Tomee 9.1.2 jar is located at 
https://repo.maven.apache.org/maven2/org/apache/tomee/apache-tomee/9.1.2/apache-tomee-9.1.2.jar
a

I can not answer the "official TomEE maven repos" question.

Paul Spencer

On 2024/01/08 12:53:17 COURTAULT Francois wrote:
> THALES GROUP LIMITED DISTRIBUTION to email recipients
> 
> Hello everyone,
> 
> Could someone confirm or not to me that the official TomEE maven repos is 
> https://repo.maven.apache.org/maven2/org/apache/tomee/apache-tomee/
> If the answer is no then what is the official TomEE maven repo ?
> If the answer is no then  9.1.2 entry is missing, right ?
> 
> Best Regards.
> 
> 
> 
> 


Only the first LdapIdentityStoreDefinition appears to be working. Why?

2024-01-10 Thread Paul Spencer
I have defined two classes implementing @LdapIdentityStoreDefinition, but only 
the groups from the validating store is used. What am I missing?

Based on the configuration below and the Jakarta Tutorial, I expect the groups 
"USER" and "ROLE_1" for my authenticated user.  Only group "USER" is listed.

***
* Jakarta Tutorial
***
https://jakartaee.github.io/jakartaee-documentation/jakartaee-tutorial/9.1/security/security-api/security-api.html#_overview_of_the_identity_store_interfaces

There is a built-in IdentityStoreHandler that implements a standard algorithm 
defined by Jakarta Security. The Jakarta Security specification provides a full 
description of the algorithm, but it can be roughly summarized as follows:
• Iterate over the available validating IdentityStores, in priority 
order, until the provided Credential is validated or there are no more 
IdentityStores.
• If the Credential was validated, iterate over the available 
group-providing IdentityStores, in priority order, aggregating the groups 
returned by each store.
• Return the validated caller and group information.

***
* LDAP Configuation
***
ou=groups,dc=example,dc=com contains
 cn=USERS
uniqueMember= uid=myuser,ou=people,dc=example,dc=com

ou=roles,dc=example,dc=com contains
 cn=ROLE_1
uniqueMember= uid=myuser,ou=people,dc=example,dc=com

***
* 1st LdapIdentityStoreDefinition
***
@LdapIdentityStoreDefinition(url = "ldap://localhost:10389;, //
   bindDn = "uid=admin,ou=system", //
   bindDnPassword = "secret", //
   callerBaseDn = "ou=people, dc=example,dc=com", //
   callerNameAttribute = "uid", //
   groupSearchBase = "ou=groups,dc=example,dc=com", //
   groupMemberAttribute = "uniqueMember"
@ApplicationScoped
public class LdapIdentity {

}

***
* 1st LdapIdentityStoreDefinition
***
@LdapIdentityStoreDefinition(url = "ldap://localhost:10389;, //
   bindDn = "uid=admin,ou=system", //
   bindDnPassword = "secret", //
   groupSearchBase = "ou=roles,dc=example,dc=com", //
   groupMemberAttribute = "uniqueMember",
   useFor = (ValidationType.PROVIDE_GROUPS),
   priority = 100)
@ApplicationScoped
public class RolesIdentity {

}

Paul Spencer



Re: Moving to Attic

2023-11-21 Thread Paul Spencer
Terence,
As one who has been using Archiva for years, primarily because it just works 
without requiring much maintenance, having a list of migration options from 
those with more subject area knowledge would be very helpful.

Paul Spencer

> On Nov 19, 2023, at 9:47 PM, Terence Kent  wrote:
> 
> That’s the move, IMO.
> 
> That said, there are a fair amount of legacy deployments still kicking
> around. For reference, every time a security patch is released somebody
> pings our docker repo within a few days. So folks are using it and watching
> for releases.
> 
> Providing the community with some examples of how to migrate to other
> options (say Reposilite) would be responsible. I’ve been meaning to do that
> myself for a few months and just haven’t found the time.
> 
> On Sun, Nov 19, 2023 at 6:26 PM Olivier Lamy  wrote:
> 
>> Hi,
>> I can only see a little (almost none) activity with the project now.
>> So, it's time to call for an Attic move.
>> 
>> Please let me know me what do you think about this?
>> Is there any volunteers who would like to help?
>> Please note there is still possibility to continue the project out of
>> Apache (some github forks) but this cannot be called anymore Apache
>> Archva.
>> 
>> Cheers,
>> Olivier
>> 



Re: Show reverse depends of a bundle on console

2023-08-23 Thread Paul Spencer
Antony,
Does the package:imports command not provide the needed information?

karaf@internal()> package:imports -p javax.xml.xpath
Package │ Version │ Optional │ ID  │ Bundle Name
┼─┼──┼─┼───
javax.xml.xpath │ │  │ 147 │ org.apache.commons.commons-text
javax.xml.xpath │ │  │ 51  │ org.ops4j.pax.url.wrap
javax.xml.xpath │ │  │ 74  │ org.apache.cxf.cxf-core
javax.xml.xpath │ │  │ 75  │ 
org.apache.cxf.cxf-rt-frontend-jaxrs
javax.xml.xpath │ │  │ 94  │ 
org.apache.servicemix.bundles.jaxb-runtime
javax.xml.xpath │ │  │ 95  │ 
org.apache.servicemix.bundles.jaxb-xjc
karaf@internal()> package:exports -p javax.xml.xpath
Package Name│ Version │ ID │ Bundle Name
┼─┼┼───
javax.xml.xpath │ 0.0.0   │ 0  │ org.apache.felix.framework
karaf@internal()> package --help
SUBSHELL
package

COMMANDS
package:exports Lists exported packages and the bundles that export them
package:imports Lists imported packages and the bundles that import them
karaf@internal()>   
    


Paul Spencer

> On Aug 22, 2023, at 1:00 AM, Jean-Baptiste Onofré  wrote:
> 
> Hi,
> 
> It sounds like a change in exports command between Karaf 2 & 3.
> 
> Can you please create a ticket ? I will re-add the option on the shell
> command (and probably corresponding MBean).
> 
> Thanks !
> Regards
> JB
> 
> On Tue, Aug 15, 2023 at 9:44 PM Anthony Wood  wrote:
>> 
>> Hi Paul,
>> 
>> I am looking for a way to find which bundles are importing packages from a 
>> *given* bundle.
>> 
>> In karaf 2.x, if I have a bundle dependency network in which both bundles 1 
>> and 2 import a package exported from bundle 3, this command shows me exactly 
>> which bundles depend on 3 (i.e., 1 and 2):
>> 
>> karaf> exports -i 3
>> ID Packages   Imported by
>> 3  org.foo.bar; version=1.0   Bundle One (1)
>> 3  org.foo.baz; version=1.0   Bundle Two (2)
>> 
>> In karaf 4.x, so far I cannot duplicate this.  The best I have found is to 
>> use “tree-show” on every bundle and search/grep for the bundle 3 that I care 
>> about.  The “imports” command only shows me the packages, not the bundles 
>> satisfying them.  I am open to suggestions for recovering the functionality 
>> loss.
>> 
>> Thanks,
>> Anthony
>> 



Re: Show reverse depends of a bundle on console

2023-08-11 Thread Paul Spencer
Anthony
"imports -i" may be what you are looking for.


karaf@root()> imports --help
DESCRIPTION
package:imports

Lists imported packages and the bundles that import them

SYNTAX
package:imports [options]

OPTIONS
--help
Display this help message
-b
Only show imports of the given bundle id
--show-name-only
Show only package name
--filter
Only show package instead of full filter
-p
Only show package starting with given name
--no-format
Disable table rendered output

karaf@root()>    

Paul Spencer


  

> On Aug 11, 2023, at 12:23 PM, Anthony Wood  wrote:
> 
> In karaf 2.x, I would often use ‘exports -i $id’ to show the “reverse 
> dependencies” of the bundle, i.e., what other bundles are wired to it by 
> imports.
> 
> I cannot find the equivalent in karat 4.4. Has this functionality been lost?
> 
> Thanks,
> Anthony



[jira] [Created] (KARAF-7708) Test and example of JSON configuration

2023-07-10 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7708:
---

 Summary: Test and example of JSON configuration
 Key: KARAF-7708
 URL: https://issues.apache.org/jira/browse/KARAF-7708
 Project: Karaf
  Issue Type: Improvement
  Components: karaf
Affects Versions: 4.4.3
Reporter: Paul Spencer


The examples and itests are missing and need a JSON configuration use case.  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


Re: How to use Jakarta Restful WebService(OSGi 8.1) ?

2023-04-12 Thread Paul Spencer
Jeongpil An,
For what it is worth, below is a simplified and sanitized version of my REST 
environment under Karaf 4.4.3. Note the REST endpoint and the API 
implementation are in different bundles, as I used the same REST application 
for many bundles.

Although thus is not a Jararta implementation, I hope it helps.

***
* REST Application
***
package com.foo.restapp;

import javax.ws.rs.core.Application;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsApplicationBase;
import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsName;

@Component(service=Application.class)
@JaxrsName("fooApi")
@JaxrsApplicationBase("/foo/api")
public class RestApplication extends Application{

}

***
* Example REST API
***
package com.foo.messenger.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsApplicationSelect;
import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsResource;


@Path("/archiveMessage")
@Component(service = ArchiveMessage.class)
@JaxrsResource
@JaxrsApplicationSelect("(osgi.jaxrs.name=fooApi)")
public class ArchiveMessage {
@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/{messageId}")
public Response archiveMessage(@PathParam("messageId") final Integer 
messageId,
@QueryParam("account") ) {
...
ResponseBuilder builder;
...
if (success) {
   builder = Response.ok(String.format("Success - Archiving Message 
ID:%d", messageId));
} else {
builder = Response.noContent();
}
return builder.build();
}

}


***
* Feature
***
   
cxf-jaxrs
jackson-jaxrs
pax-web-http-whiteboard
pax-web-karaf
aries-jax-rs-whiteboard
aries-jax-rs-whiteboard-jackson
mvn:com.foo.rest/foo-restapp/${restapp.version}



foo-restapp
    mvn:com.foo.rest/foo-msg-rest/${bugdata.msg.rest.version}




Paul Spencer



> On Apr 12, 2023, at 2:58 AM, 안정필  wrote:
> 
> Thanks for your good comments, Grzegorz Grzybek.
> 
> Using your comments, I'll try again and post the result.
> 
> Regards
> Jeongpil An (call ajp)
> 
> 2023년 4월 12일 (수) 오후 3:01, Grzegorz Grzybek 님이 작성:
> Hello
> 
> Karaf 4.4.3 uses Pax Web 8 and Pax Web, while not containing any Karaf 
> features related to JaxRS, provides integration tests using aries-jaxrs (OSGi 
> CMPN specification implementation).
> 
> The Jetty-based test: 
> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.19/pax-web-itest/pax-web-itest-container/pax-web-itest-jetty/src/test/java/org/ops4j/pax/web/itest/jetty/whiteboard/WhiteboardR7JaxRsIntegrationTest.java
> 
> Abstract definition of the test: 
> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.19/pax-web-itest/pax-web-itest-container/pax-web-itest-container-common/src/main/java/org/ops4j/pax/web/itest/container/whiteboard/AbstractWhiteboardR7JaxRsIntegrationTest.java
> 
> And what's most important - the list of bundles you need (so you can create 
> your own feature): 
> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.19/pax-web-itest/pax-web-itest-common/src/main/java/org/ops4j/pax/web/itest/AbstractControlledTestBase.java#L667-L725
> 
> I know this is rtfs approach to answer your question, but that's how it is ;)
> 
> kind regards
> Grzegorz Grzybek
> 
> śr., 12 kwi 2023 o 07:46 안정필  napisał(a):
> Hi, Karaf Users and Developers.
> I'm a user who likes karaf and osgi.
> 
> Can I use Jakarta Restful WebService(OSGi 8.1) on Karaf ?
> I'm using Karaf 4.4.3.
> 
> It seems like that karaf default cxf-jaxrs feature 3.5.5 supports 
> javax.ws.rs, not jakarta.ws.rs.
> cxf 4.0 changed to jakarta but  temporarily removed osgi module 
> till osgi supports jakarta, as they say.
> I tried several things but the result was not good. (eclipse Jersey 3.1, 
> resteasy 6.2.3.Final, etc.)
> 
> Any Idea?
> 
> Thanks in advance for any comments.
> 
> Regards
> Jeongpil An (call, ajp)



Web and CDI setup failed to start bundled due to two bundles exporting the same version of javax.annotation

2023-04-02 Thread Paul Spencer
ion.security  │ 1.3.0   │ 97  │ 
org.apache.servicemix.specs.annotation-api-1.3
javax.annotation.sql   │ 1.3.0   │ 97  │ 
org.apache.servicemix.specs.annotation-api-1.3
javax.annotation   │ 1.3.0   │ 0   │ 
org.apache.felix.framework
javax.annotation   │ 1.3.0   │ 97  │ 
org.apache.servicemix.specs.annotation-api-1.3
 97 │ Active   │  80 │ 1.3.0.3   │ 
org.apache.servicemix.specs.annotation-api-1.3

Apache ServiceMix :: Specs :: Annotation API 1.3 (97)
-
Bnd-LastModified = 1584974695696
Build-Jdk = 1.8.0_172
Built-By = jbonofre
Created-By = Apache Maven Bundle Plugin
Implementation-Title = Apache ServiceMix
Implementation-Version = 1.3_3
Manifest-Version = 1.0
Tool = Bnd-3.4.0.201707252008

Bundle-Description = This pom provides project information that is common to 
all ServiceMix branches.
Bundle-DocURL = http://www.apache.org/
Bundle-License = http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion = 2
Bundle-Name = Apache ServiceMix :: Specs :: Annotation API 1.3
Bundle-SymbolicName = org.apache.servicemix.specs.annotation-api-1.3
Bundle-Vendor = The Apache Software Foundation
Bundle-Version = 1.3.0.3

Provide-Capability =  osgi.contract;
uses:="javax.annotation.sql,
javax.annotation,
javax.annotation.security";
osgi.contract=JavaAnnotation;
version:List="1.3,1.2,1.1,1"
Require-Capability =  osgi.ee;filter:=(&(osgi.ee=JavaSE)(version=1.8))

Export-Package =  javax.annotation;version=1.3,
javax.annotation.security;version=1.3,
javax.annotation.sql;version=1.3


Bundle ID: 108
Bundle ID: 109
Error executing command: Error installing bundles:
Unable to start bundle 
mvn:org.apache.aries.cdi/org.apache.aries.cdi.extension.servlet.owb/1.1.5: 
org.osgi.framework.BundleException: Uses constraint violation. Unable to 
resolve resource org.apache.aries.cdi.extension.servlet.owb 
[org.apache.aries.cdi.extension.servlet.owb [109](R 109.0)] because it is 
exposed to package 'javax.annotation' from resources 
org.apache.servicemix.specs.annotation-api-1.3 
[org.apache.servicemix.specs.annotation-api-1.3 [97](R 97.0)] and 
org.apache.felix.framework [org.apache.felix.framework [0](R 0)] via two 
dependency chains.

Chain 1:
  org.apache.aries.cdi.extension.servlet.owb 
[org.apache.aries.cdi.extension.servlet.owb [109](R 109.0)]
import: (osgi.wiring.package=javax.annotation)
 |
export: osgi.wiring.package: javax.annotation
  org.apache.servicemix.specs.annotation-api-1.3 
[org.apache.servicemix.specs.annotation-api-1.3 [97](R 97.0)]

Chain 2:
  org.apache.aries.cdi.extension.servlet.owb 
[org.apache.aries.cdi.extension.servlet.owb [109](R 109.0)]
import: 
(&(osgi.wiring.package=org.apache.webbeans.config)(version>=2.0.0)(!(version>=3.0.0)))
 |
export: osgi.wiring.package=org.apache.webbeans.config; 
uses:=javax.annotation
  openwebbeans-impl [openwebbeans-impl [86](R 86.0)]
import: 
(&(osgi.wiring.package=javax.annotation)(version>=1.2.0)(!(version>=2.0.0)))
 |
export: osgi.wiring.package: javax.annotation
  org.apache.felix.framework [org.apache.felix.framework [0](R 0)] Unresolved 
requirements: [[org.apache.aries.cdi.extension.servlet.owb [109](R 109.0)] 
osgi.wiring.package; 
(&(osgi.wiring.package=org.apache.webbeans.config)(version>=2.0.0)(!(version>=3.0.0)))]
karaf@root()>  


Paul Spencer
   

Re: Using Decanter log appender/collector and mail alerting fails with "javax.activation.UnsupportedDataTypeException: text/plain"

2023-03-22 Thread Paul Spencer
JB,
I have been able to install the email alerter from Decanter v2.10 without using 
the feature.  In short I used a different version of Java Mail and the 
activation api then defined in the decanter-alerting-email-core feature. 

***
* Karaf 4.4.3 command to install Decanter Alerting Email outside of the feature
***
feature:install scr
bundle:install mvn:com.sun.activation/jakarta.activation/1.2.1
bundle:install mvn:com.sun.mail/jakarta.mail/1.6.7
bundle:install --start 
mvn:org.apache.karaf.decanter.alerting/org.apache.karaf.decanter.alerting.email/2.10.0


Paul Spencer

> On Mar 22, 2023, at 9:04 AM, Speckels, Bert  wrote:
> 
> Thanx alot
> 
> Currently there is no hurry yet for email support but later planned (May 
> 2023).
> But I'll will give Decanter 2.9.0 a try. 
> 
> For testing we are currently using "smtp4dev" docker image.
> Greenmail seems to be a very good alternative!
> 
> Mit freundlichen Grüßen
> 
> i.A. Bert Speckels
> BU Software Factory
> Smart Software Solutions
> 
> BTC Business Technology Consulting AG
> Escherweg 3
> 26121 Oldenburg
> Tel:  +49 441 3612-2294
> Mobil:   +49 174 3436354
> Fax: +49 441 3612-3999
> E-Mail:  bert.speck...@btc-ag.com
> Web: www.btc-ag.com
> 
> Rechtliche Hinweise:
> www.btc-ag.com/impressum.htm
> Handelsregister: Amtsgericht Oldenburg HRB 4717
> Aufsichtsratsvorsitzender: Wolfgang Mücher
> Vorstand: Dr. Jörg Ritter (Vorstandsvorsitzender), Percy Hamer
> 
> 
> Von: Paul Spencer 
> Gesendet: Dienstag, 21. März 2023 18:28
> An: user@karaf.apache.org 
> Betreff: Re: Using Decanter log appender/collector and mail alerting fails 
> with "javax.activation.UnsupportedDataTypeException: text/plain"
>  
> Bert,
> You can test alerts with Decanter 2.9.0 on Karaf 4.3.x in the interim.
> 
> Since it is very easy to create an email storm, I suggest using a tool like 
> Greenmail, 
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgreenmail-mail-test.github.io%2Fgreenmail%2F%23deploy_standalone=05%7C01%7CBert.Speckels%40btc-ag.com%7C9dbfa29aa5a6482767f308db2a31af85%7Cc064efb078954eebb406a40bc377bc7d%7C0%7C0%7C638150165105714954%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=suFF%2BPkAnkzoS5hd65hqBlwiPenpVQgwixM65%2FivccA%3D=0,
>  as an email server for testing.
> 
> 
> Paul Spencer
> 
> 
> > On Mar 21, 2023, at 1:21 PM, Speckels, Bert  
> > wrote:
> > 
> > Perfect Paul!
> > 
> > Thanx alot for your work to reproduce my problem here.
> > 
> > @Jean-Baptiste: I didn't use a mail template yet. As far as I understood 
> > that's optional: I wanted to make one step after another 
> > 
> > So currently there is no easy solution for decanter alerts using email?
> > 
> > Von: Paul Spencer 
> > Gesendet: Dienstag, 21. März 2023 15:57
> > An: user@karaf.apache.org 
> > Betreff: Re: Using Decanter log appender/collector and mail alerting fails 
> > with "javax.activation.UnsupportedDataTypeException: text/plain"
> >  
> > JB,
> > I am using JavaMail 1.6.7 in karaf 4.3.x and used this question to test 
> > email in Karaf 4.4.3.  As a result I have reproduced this issue. In attempt 
> > to upgrade EmailAlerter to Jakarta Mail 2.1.1 with an Eclipse Angus 
> > implementation, I found a bundled dependency issue and filed the following 
> > issue 
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feclipse-ee4j%2Fangus-mail%2Fissues%2F87=05%7C01%7CBert.Speckels%40btc-ag.com%7C9dbfa29aa5a6482767f308db2a31af85%7Cc064efb078954eebb406a40bc377bc7d%7C0%7C0%7C638150165105714954%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=OAKste8%2Bt4Ljbu%2B9TftnF8hDHSu7c3kxejCH0jUj%2FlU%3D=0
> > 
> > # Start karaf
> > bin/karaf clean
> > 
> > # Add decanter repo and install email alerting feature
> > feature:repo-add decanter
> > feature:install decanter-alerting-email
> > 
> > # Edit etc/org.apache.karaf.decanter.alerting.email.cfg
> > 
> > # Send an event the alerter
> > event:send decanter/alert/ERROR “foo=bar”
> > 
> > # Display the karaf.log 
> > log:display
> > 
> > 10:52:25.772 INFO [features-3-thread-1] Registering commands for bundle 
> > org.apache.karaf.decanter.alerting.service/2.10.0
> > 10:52:25.772 INFO [features-3-thread-1]   com.sun.mail.javax.mail/1.6.2
> > 10:52:25.773 INFO [features-3-thread-1]   
> > org.apache.karaf.decanter.marshaller.raw/2.10.0
> > 10:52:25.775 INFO [features-3-thread-1]   
> > o

Re: Using Decanter log appender/collector and mail alerting fails with "javax.activation.UnsupportedDataTypeException: text/plain"

2023-03-21 Thread Paul Spencer
Bert,
You can test alerts with Decanter 2.9.0 on Karaf 4.3.x in the interim.

Since it is very easy to create an email storm, I suggest using a tool like 
Greenmail, https://greenmail-mail-test.github.io/greenmail/#deploy_standalone, 
as an email server for testing.


Paul Spencer


> On Mar 21, 2023, at 1:21 PM, Speckels, Bert  wrote:
> 
> Perfect Paul!
> 
> Thanx alot for your work to reproduce my problem here.
> 
> @Jean-Baptiste: I didn't use a mail template yet. As far as I understood 
> that's optional: I wanted to make one step after another 
> 
> So currently there is no easy solution for decanter alerts using email?
> 
> Von: Paul Spencer 
> Gesendet: Dienstag, 21. März 2023 15:57
> An: user@karaf.apache.org 
> Betreff: Re: Using Decanter log appender/collector and mail alerting fails 
> with "javax.activation.UnsupportedDataTypeException: text/plain"
>  
> JB,
> I am using JavaMail 1.6.7 in karaf 4.3.x and used this question to test email 
> in Karaf 4.4.3.  As a result I have reproduced this issue. In attempt to 
> upgrade EmailAlerter to Jakarta Mail 2.1.1 with an Eclipse Angus 
> implementation, I found a bundled dependency issue and filed the following 
> issue 
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Feclipse-ee4j%2Fangus-mail%2Fissues%2F87=05%7C01%7CBert.Speckels%40btc-ag.com%7Cb9254dbaf8534596f5db08db2a1ca655%7Cc064efb078954eebb406a40bc377bc7d%7C0%7C0%7C638150074770709219%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=CgEsWPuxgkvLjB2MTlYEQKRxnBZ2NZOV0CIxrSeahwY%3D=0
> 
> # Start karaf
> bin/karaf clean
> 
> # Add decanter repo and install email alerting feature
> feature:repo-add decanter
> feature:install decanter-alerting-email
> 
> # Edit etc/org.apache.karaf.decanter.alerting.email.cfg
> 
> # Send an event the alerter
> event:send decanter/alert/ERROR “foo=bar”
> 
> # Display the karaf.log 
> log:display
> 
> 10:52:25.772 INFO [features-3-thread-1] Registering commands for bundle 
> org.apache.karaf.decanter.alerting.service/2.10.0
> 10:52:25.772 INFO [features-3-thread-1]   com.sun.mail.javax.mail/1.6.2
> 10:52:25.773 INFO [features-3-thread-1]   
> org.apache.karaf.decanter.marshaller.raw/2.10.0
> 10:52:25.775 INFO [features-3-thread-1]   
> org.apache.karaf.decanter.alerting.email/2.10.0
> 10:52:25.777 INFO [features-3-thread-1] Done.
> 10:52:48.142 ERROR [pipe-event:send decanter/alert/ERROR "foo=bar"] Can't 
> send the alert e-mail
> javax.mail.MessagingException: IOException while sending message
> at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1365) ~[?:?]
> at javax.mail.Transport.send0(Transport.java:255) ~[?:?]
> at javax.mail.Transport.send(Transport.java:174) ~[?:?]
> at 
> org.apache.karaf.decanter.alerting.email.EmailAlerter.handleEvent(EmailAlerter.java:140)
>  ~[?:?]
> at 
> org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:432)
>  ~[?:?]
> at 
> org.apache.felix.eventadmin.impl.tasks.HandlerTask.runWithoutDenylistTiming(HandlerTask.java:82)
>  ~[?:?]
> at 
> org.apache.felix.eventadmin.impl.tasks.SyncDeliverTasks.execute(SyncDeliverTasks.java:107)
>  ~[?:?]
> at 
> org.apache.felix.eventadmin.impl.handler.EventAdminImpl.sendEvent(EventAdminImpl.java:196)
>  ~[?:?]
> at 
> org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator.sendEvent(EventAdminSecurityDecorator.java:96)
>  ~[?:?]
> at 
> org.apache.karaf.event.command.EventSendCommand.execute(EventSendCommand.java:49)
>  ~[?:?]
> at 
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>  ~[?:?]
> at 
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>  ~[?:?]
> at 
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>  ~[?:?]
> at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599) ~[?:?]
> at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526) 
> ~[?:?]
> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415) ~[?:?]
> at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416) ~[?:?]
> at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) ~[?:?]
> at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) ~[?:?]
> at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
> at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
>  ~[?:?]
> at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
>  ~[?:?]
> at java.lang.Thread.run(Thread.java:833) ~[?:?]
> Caused by: javax.activati

Re: Using Decanter log appender/collector and mail alerting fails with "javax.activation.UnsupportedDataTypeException: text/plain"

2023-03-21 Thread Paul Spencer
JB,
I am using JavaMail 1.6.7 in karaf 4.3.x and used this question to test email 
in Karaf 4.4.3.  As a result I have reproduced this issue. In attempt to 
upgrade EmailAlerter to Jakarta Mail 2.1.1 with an Eclipse Angus 
implementation, I found a bundled dependency issue and filed the following 
issue https://github.com/eclipse-ee4j/angus-mail/issues/87

# Start karaf
bin/karaf clean

# Add decanter repo and install email alerting feature
feature:repo-add decanter
feature:install decanter-alerting-email

# Edit etc/org.apache.karaf.decanter.alerting.email.cfg

# Send an event the alerter
event:send decanter/alert/ERROR “foo=bar”

# Display the karaf.log 
log:display

10:52:25.772 INFO [features-3-thread-1] Registering commands for bundle 
org.apache.karaf.decanter.alerting.service/2.10.0
10:52:25.772 INFO [features-3-thread-1]   com.sun.mail.javax.mail/1.6.2
10:52:25.773 INFO [features-3-thread-1]   
org.apache.karaf.decanter.marshaller.raw/2.10.0
10:52:25.775 INFO [features-3-thread-1]   
org.apache.karaf.decanter.alerting.email/2.10.0
10:52:25.777 INFO [features-3-thread-1] Done.
10:52:48.142 ERROR [pipe-event:send decanter/alert/ERROR "foo=bar"] Can't send 
the alert e-mail
javax.mail.MessagingException: IOException while sending message
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1365) ~[?:?]
at javax.mail.Transport.send0(Transport.java:255) ~[?:?]
at javax.mail.Transport.send(Transport.java:174) ~[?:?]
at 
org.apache.karaf.decanter.alerting.email.EmailAlerter.handleEvent(EmailAlerter.java:140)
 ~[?:?]
at 
org.apache.felix.eventadmin.impl.handler.EventHandlerProxy.sendEvent(EventHandlerProxy.java:432)
 ~[?:?]
at 
org.apache.felix.eventadmin.impl.tasks.HandlerTask.runWithoutDenylistTiming(HandlerTask.java:82)
 ~[?:?]
at 
org.apache.felix.eventadmin.impl.tasks.SyncDeliverTasks.execute(SyncDeliverTasks.java:107)
 ~[?:?]
at 
org.apache.felix.eventadmin.impl.handler.EventAdminImpl.sendEvent(EventAdminImpl.java:196)
 ~[?:?]
at 
org.apache.felix.eventadmin.impl.security.EventAdminSecurityDecorator.sendEvent(EventAdminSecurityDecorator.java:96)
 ~[?:?]
at 
org.apache.karaf.event.command.EventSendCommand.execute(EventSendCommand.java:49)
 ~[?:?]
at 
org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
 ~[?:?]
at 
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
 ~[?:?]
at 
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
 ~[?:?]
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599) ~[?:?]
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526) 
~[?:?]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415) ~[?:?]
at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416) ~[?:?]
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) ~[?:?]
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) 
~[?:?]
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 
~[?:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: javax.activation.UnsupportedDataTypeException: text/plain
at javax.activation.DataHandler.writeTo(DataHandler.java:75) 
~[org.apache.servicemix.specs.activation-api-1.2.1-1.2.1_3.jar:1.2.1_3]
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1694) ~[?:?]
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1913) ~[?:?]
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1315) ~[?:?]
... 22 more

karaf@root()>  



> On Mar 21, 2023, at 6:01 AM, Jean-Baptiste Onofré  wrote:
> 
> Hi Bert
> 
> Let me try to reproduce. Do you use a mail template ?
> 
> Regards
> JB
> 
> On Sat, Mar 18, 2023 at 11:27 AM Speckels, Bert
>  wrote:
>> 
>> Hello everyone
>> 
>> Maybe you have a hint for me where to look for a solution.
>> I started to use "decanter" to send emails for error logging.
>> 
>> I started to use the following features:
>>   decanter-collector-log
>>   decanter-appender-log
>>   decanter-alerting-email
>> 
>> ... configured a simple rule in 
>> "org.apache.karaf.decanter.alerting.service.cfg"
>>   rule.error="{'condition':'message:*','level':'ERROR'}"
>> 
>> ... and configured my email server in 
>> "org.apache.karaf.decanter.alerting.email.cfg"
>> 
>> But when decanter tries to send an email the following error is logged:
>> 
>> Caused by: javax.activation.UnsupportedDataTypeException: text/plain
>> at javax.activation.DataHandler.writeTo(DataHandler.java:75) 
>> ~[org.apache.servicemix.specs.activation-api-1.2.1-1.2.1_3.jar:1.2.1_3]
>> at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1694) ~[?:?]
>> at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1913) ~[?:?]
>> at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1315) 
>> ~[?:?]
>> 
>> 

[jira] [Updated] (KARAF-7680) "system:property --unset" is not removing the property.

2023-03-13 Thread Paul Spencer (Jira)


 [ 
https://issues.apache.org/jira/browse/KARAF-7680?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul Spencer updated KARAF-7680:

Description: 
The command "system:property --unset" is not removing the property. 

{{karaf@root()> system:property | grep foo}}
{{karaf@root()> system:property foo bar}}
{{karaf@root()> system:property | grep foo}}
{{foo=bar}}
{{karaf@root()> system:property --unset foo}}
{{bar}}
{{karaf@root()> system:property | grep foo}}
{{foo=bar}}
{{karaf@root()>}}

  was:
The command "system:property --unset" is not removing the property. 

karaf@root()> system:property | grep foo
karaf@root()> system:property foo bar
karaf@root()> system:property | grep foo
foo=bar
karaf@root()> system:property --unset foo
bar
karaf@root()> system:property | grep foo    

   foo=bar
karaf@root()>


> "system:property --unset" is not removing the property.
> ---
>
> Key: KARAF-7680
> URL: https://issues.apache.org/jira/browse/KARAF-7680
> Project: Karaf
>  Issue Type: Bug
>  Components: karaf
>Affects Versions: 4.4.3
> Environment: Karaf 4.4.3
> OpenJDK 64-Bit Server VM version 17.0.2+8-86
>Reporter: Paul Spencer
>Priority: Major
>
> The command "system:property --unset" is not removing the property. 
> {{karaf@root()> system:property | grep foo}}
> {{karaf@root()> system:property foo bar}}
> {{karaf@root()> system:property | grep foo}}
> {{foo=bar}}
> {{karaf@root()> system:property --unset foo}}
> {{bar}}
> {{karaf@root()> system:property | grep foo}}
> {{foo=bar}}
> {{karaf@root()>}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (KARAF-7680) "system:property --unset" is not removing the property.

2023-03-13 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7680:
---

 Summary: "system:property --unset" is not removing the property.
 Key: KARAF-7680
 URL: https://issues.apache.org/jira/browse/KARAF-7680
 Project: Karaf
  Issue Type: Bug
  Components: karaf
Affects Versions: 4.4.3
 Environment: Karaf 4.4.3
OpenJDK 64-Bit Server VM version 17.0.2+8-86
Reporter: Paul Spencer


The command "system:property --unset" is not removing the property. 

karaf@root()> system:property | grep foo
karaf@root()> system:property foo bar
karaf@root()> system:property | grep foo
foo=bar
karaf@root()> system:property --unset foo
bar
karaf@root()> system:property | grep foo    

   foo=bar
karaf@root()>



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


"system:property --unset" is not removing the property.

2023-03-09 Thread Paul Spencer
Karaf 4.4.3
OpenJDK 64-Bit Server VM version 17.0.2+8-86

The command "system:property --unset" is not removing the property. Should I 
open a JIRA?

karaf@root()> system:property | grep foo
karaf@root()> system:property foo bar
karaf@root()> system:property | grep foo
foo=bar
karaf@root()> system:property --unset foo
bar
karaf@root()> system:property | grep foo

   foo=bar
karaf@root()> 


Paul Spencer



[jira] [Created] (KARAF-7673) Location of the "minimal distribution" files is not documented

2023-03-01 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7673:
---

 Summary: Location of the "minimal distribution" files is not 
documented
 Key: KARAF-7673
 URL: https://issues.apache.org/jira/browse/KARAF-7673
 Project: Karaf
  Issue Type: Documentation
  Components: karaf
Affects Versions: 4.4.3
Reporter: Paul Spencer


The documentation describes "minimal distribution"[1], but neither the 
referenced download page[2] nor the archive page[3] makes no mention of minimal 
distributions. I was able to find the distribution via the "Main Distribution 
Directory"[4] listed on the "Verify the integrity of the files" section of the 
download page[2].  

I do not have a suggestion on how to document the location of the "minimal 
distribution" files, but it is needed.  


[1] 
[https://karaf.apache.org/manual/latest/#_using_apache_karaf_binary_distributions]
[2] [https://karaf.apache.org/download.html]
[3] [https://karaf.apache.org/archives.html]
[4] [https://downloads.apache.org/karaf/]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


Existence of a "Minimal Distribution" is documented, but its location is not.

2023-02-27 Thread Paul Spencer
The documentation describes "minimal distribution"[1], but neither the 
referenced download page[2] nor the archive page[3] makes no mention of minimal 
distributions. I was able to find the distribution via the "Main Distribution 
Directory"[4] listed on the "Verify the integrity of the files" section of the 
download page[2].  

I do not have a suggestion on how to document the location of the "minimal 
distribution" files, but it is needed.  

Should I open a JIRA?

Paul Spencer

[1] 
https://karaf.apache.org/manual/latest/#_using_apache_karaf_binary_distributions
[2] https://karaf.apache.org/download.html
[3] https://karaf.apache.org/archives.html
[4] https://downloads.apache.org/karaf/

Should standard-n.n.n-feature.xml reference the minimum version of pax-web?

2023-02-25 Thread Paul Spencer
Should standard-n.n.n-feature.xml reference the minimum version of pax-web 
instead of the exact version?

I ask this because the current implementation prevent upgrading pax-web without 
manually editing the distribution or creating a custom distribution.

Paul Spencer


Re: How to use Pax Web 8.0.16 in karaf 4.4.3?

2023-02-25 Thread Paul Spencer
andard-4.4.3 
  │ Provide a JMX MBeanServer and a set of MBeans in
eventadmin │ 4.4.3│ x│ Started │ standard-4.4.3 
  │ OSGi Event Admin service specification for event-
pax-url-wrap   │ 2.6.12   │  │ Started │ standard-4.4.3 
  │ Wrap URL handler
wrap   │ 2.6.12   │ x│ Started │ standard-4.4.3 
  │ Transition feature to pax-url-wrap
karaf@root()>   

       


Paul Spencer
> On Feb 25, 2023, at 12:23 AM, Jean-Baptiste Onofré  wrote:
> 
> If possible, wait Karaf 4.4.4 that will include it :)
> 
> Else the cleanest way is probably to create custom build or to replace
> at runtime.
> 
> Regards
> JB
> 
> On Fri, Feb 24, 2023 at 8:48 PM Paul Spencer  
> wrote:
>> 
>> I see that Pax Web version 8.0.16 has been released.  How do I utilize the 
>> version 8.0.16 in Karaf 4.4.3?
>> 
>> Paul Spencer



Re: How to use Pax Web 8.0.16 in karaf 4.4.3?

2023-02-25 Thread Paul Spencer
g.ops4j.pax.web.pax-web-compatibility-servlet31/8.0.15]]
at 
org.apache.felix.resolver.Candidates$MissingRequirementError.toException(Candidates.java:1341)
... 12 more
Caused by: org.apache.felix.resolver.reason.ReasonException: Unable to resolve 
pax-web-jetty/9.4.50.v20221201: missing requirement 
[pax-web-jetty/9.4.50.v20221201] osgi.identity; 
osgi.identity=org.ops4j.pax.web.pax-web-compatibility-servlet31; 
type=osgi.fragment; version="[8.0.15,8.0.15]"; resolution:=mandatory [caused 
by: Fragment was not selected for attachment: 
org.ops4j.pax.web.pax-web-compatibility-servlet31/8.0.15]
at 
org.apache.felix.resolver.Candidates$MissingRequirementError.toException(Candidates.java:1341)
... 13 more
Caused by: org.apache.felix.resolver.reason.ReasonException: Fragment was not 
selected for attachment: 
org.ops4j.pax.web.pax-web-compatibility-servlet31/8.0.15
at 
org.apache.felix.resolver.Candidates$FragmentNotSelectedError.toException(Candidates.java:1305)
... 14 more
Error executing command: Unable to resolve root: missing requirement [root] 
osgi.identity; osgi.identity=pax-web-http-jetty; type=karaf.feature; 
version="[8.0.16,8.0.16]"; 
filter:="(&(osgi.identity=pax-web-http-jetty)(type=karaf.feature)(version>=8.0.16)(version<=8.0.16))"
 [caused by: Unable to resolve pax-web-http-jetty/8.0.16: missing requirement 
[pax-web-http-jetty/8.0.16] osgi.identity; osgi.identity=pax-web-jetty; 
type=karaf.feature [caused by: Unable to resolve 
pax-web-jetty/9.4.50.v20221201: missing requirement 
[pax-web-jetty/9.4.50.v20221201] osgi.identity; 
osgi.identity=org.ops4j.pax.web.pax-web-compatibility-servlet31; 
type=osgi.fragment; version="[8.0.15,8.0.15]"; resolution:=mandatory [caused 
by: Fragment was not selected for attachment: 
org.ops4j.pax.web.pax-web-compatibility-servlet31/8.0.15]]]
karaf@root()>


Paul Spencer


   
> On Feb 25, 2023, at 2:00 AM, Grzegorz Grzybek  wrote:
> 
> Hello
> 
> Worked for me ;) Or at least after I added 8.0.16 feature repo, when you 
> install pax-web feature the newer version will be used.
> 
> regards
> Grzegorz Grzybek
> 
> sob., 25 lut 2023 o 06:25 Jean-Baptiste Onofré  napisał(a):
> Do you have pax-web features installed ? You can "force" the removal
> (feature:repo-remove -u).
> 
> Regards
> JB
> 
> On Sat, Feb 25, 2023 at 2:18 AM Paul Spencer  
> wrote:
> >
> > Grzegoz,
> >
> > Removing the pax-web 8.0.15 repo does not remove the repository.  Below is 
> > from a fresh install of karaf.
> >
> > Karaf 4.4.3
> > Java 1.8.0_172
> > Mac OS X 10.16 x86_64
> >
> >
> > karaf@root()> feature:repo-remove 
> > mvn:org.ops4j.pax.web/pax-web-features/8.0.15/xml/features
> > Removing features repository: 
> > mvn:org.ops4j.pax.web/pax-web-features/8.0.15/xml/features
> > karaf@root()> feature:repo-list
> > Repository│ URL
> > ──┼─
> > org.ops4j.pax.jdbc-1.5.5  │ 
> > mvn:org.ops4j.pax.jdbc/pax-jdbc-features/1.5.5/xml/features
> > org.ops4j.pax.web-8.0.15  │ 
> > mvn:org.ops4j.pax.web/pax-web-features/8.0.15/xml/features
> > openjpa-3.2.2 │ 
> > mvn:org.apache.openjpa/openjpa-features/3.2.2/xml/features
> > aries-jpa-2.7.3   │ 
> > mvn:org.apache.aries.jpa/jpa-features/2.7.3/xml/features
> > framework-4.4.3   │ 
> > mvn:org.apache.karaf.features/framework/4.4.3/xml/features
> > hibernate-validator-osgi-features │ 
> > mvn:org.hibernate.validator/hibernate-validator-osgi-karaf-features/7.0.2.Final/xml/features
> > standard-4.4.3│ 
> > mvn:org.apache.karaf.features/standard/4.4.3/xml/features
> > spring-4.4.3  │ 
> > mvn:org.apache.karaf.features/spring/4.4.3/xml/features
> > specs-4.4.3   │ 
> > mvn:org.apache.karaf.features/specs/4.4.3/xml/features
> > pax-transx-0.5.3  │ 
> > mvn:org.ops4j.pax.transx/pax-transx-features/0.5.3/xml/features
> > enterprise-4.4.3  │ 
> > mvn:org.apache.karaf.features/enterprise/4.4.3/xml/features
> > org.ops4j.pax.cdi-1.1.4   │ 
> > mvn:org.ops4j.pax.cdi/pax-cdi-features/1.1.4/xml/features
> > pax-jms-1.1.2 │ 
> > mvn:org.ops4j.pax.jms/pax-jms-features/1.1.2/xml/features
> > karaf@root()>
&g

Re: How to use Pax Web 8.0.16 in karaf 4.4.3?

2023-02-24 Thread Paul Spencer
Grzegoz,

Removing the pax-web 8.0.15 repo does not remove the repository.  Below is from 
a fresh install of karaf.

Karaf 4.4.3
Java 1.8.0_172
Mac OS X 10.16 x86_64


karaf@root()> feature:repo-remove 
mvn:org.ops4j.pax.web/pax-web-features/8.0.15/xml/features  

  
Removing features repository: 
mvn:org.ops4j.pax.web/pax-web-features/8.0.15/xml/features
karaf@root()> feature:repo-list
Repository│ URL
──┼─
org.ops4j.pax.jdbc-1.5.5  │ 
mvn:org.ops4j.pax.jdbc/pax-jdbc-features/1.5.5/xml/features
org.ops4j.pax.web-8.0.15  │ 
mvn:org.ops4j.pax.web/pax-web-features/8.0.15/xml/features
openjpa-3.2.2 │ 
mvn:org.apache.openjpa/openjpa-features/3.2.2/xml/features
aries-jpa-2.7.3   │ 
mvn:org.apache.aries.jpa/jpa-features/2.7.3/xml/features
framework-4.4.3   │ 
mvn:org.apache.karaf.features/framework/4.4.3/xml/features
hibernate-validator-osgi-features │ 
mvn:org.hibernate.validator/hibernate-validator-osgi-karaf-features/7.0.2.Final/xml/features
standard-4.4.3│ 
mvn:org.apache.karaf.features/standard/4.4.3/xml/features
spring-4.4.3  │ 
mvn:org.apache.karaf.features/spring/4.4.3/xml/features
specs-4.4.3   │ 
mvn:org.apache.karaf.features/specs/4.4.3/xml/features
pax-transx-0.5.3  │ 
mvn:org.ops4j.pax.transx/pax-transx-features/0.5.3/xml/features
enterprise-4.4.3  │ 
mvn:org.apache.karaf.features/enterprise/4.4.3/xml/features
org.ops4j.pax.cdi-1.1.4   │ 
mvn:org.ops4j.pax.cdi/pax-cdi-features/1.1.4/xml/features
pax-jms-1.1.2 │ 
mvn:org.ops4j.pax.jms/pax-jms-features/1.1.2/xml/features
karaf@root()>   

 

> On Feb 24, 2023, at 2:50 PM, Grzegorz Grzybek  wrote:
> 
> Hello
> 
> Just replace them ;)
> 
> karaf@root()> feature:repo-remove 
> mvn:org.ops4j.pax.web/pax-web-features/8.0.15/xml/features
> Removing features repository: 
> mvn:org.ops4j.pax.web/pax-web-features/8.0.15/xml/features
> 
> karaf@root()> feature:repo-add 
> mvn:org.ops4j.pax.web/pax-web-features/8.0.16/xml/features
> Adding feature url mvn:org.ops4j.pax.web/pax-web-features/8.0.16/xml/features
> 
> And then the features you install will come from 8.0.16.
> 
> regards
> Grzegoz Grzybek
> 
> pt., 24 lut 2023 o 20:48 Paul Spencer  napisał(a):
> I see that Pax Web version 8.0.16 has been released.  How do I utilize the 
> version 8.0.16 in Karaf 4.4.3?
> 
> Paul Spencer



How to use Pax Web 8.0.16 in karaf 4.4.3?

2023-02-24 Thread Paul Spencer
I see that Pax Web version 8.0.16 has been released.  How do I utilize the 
version 8.0.16 in Karaf 4.4.3?

Paul Spencer

Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not with DS

2023-01-26 Thread Paul Spencer
Jaap,

RestImpl
- I do not use @JSONRequired
- I would not expect this component to be activated if personService is not 
resolved.  You can add and @Activate method to to confirm the resolution of 
personService

MyApplicationImpl
- I do not override getClasses() or getSingletons().
- My REST application relies on the following installed features:
  cxf-jaxrs
jackson-jaxrs
pax-web-http-whiteboard
pax-web-karaf
aries-jax-rs-whiteboard
aries-jax-rs-whiteboard-jackson

Also I have learned that resetting the Karaf environment with “karaf clean” and 
reinstalling bundles and features will clear up behavior that does not make 
senses.  This is especially true when there are changes to calculated the 
MANIFEST.MF file.

Additional resources:
- Example REST Whiteboard
  
https://github.com/apache/karaf/tree/karaf-4.4.3/examples/karaf-rest-example/karaf-rest-example-whiteboard
- Issue related to feature.xml for the REST Example
  https://issues.apache.org/jira/browse/KARAF-7639

Paul Spencer
   
> On Jan 26, 2023, at 5:02 AM, Jaap Gordijn  wrote:
> 
> Hi Paul,
> 
> I have put the Rest service in a separate bundle but that does not help.
> 
> I created a simplified case:
> 
> Component(service = RestImpl.class)
> @JaxrsResource
> @JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME + 
> "=MyApplication)")
> @JSONRequired
> @Produces(MediaType.APPLICATION_JSON)
> public class RestImpl {
> 
>   @Reference
>   private PersonService personService;
>   
>   @GET
>   @Path("/test")
>   public String test() {
>   System.out.println("personService == null " + (personService == 
> null));
>   return "test"; 
>   }
> }
> 
> @Component(service = Application.class, property =  
> {"servlet.init.hide-service-list-page=false"} )
> @JaxrsApplicationBase("example")
> @JaxrsName("MyApplication")
> public class MyApplicationImpl extends Application {
> 
> @Override
> public Set> getClasses() {
> HashSet> set = new HashSet>();
> set.add(JacksonJsonProvider.class);
> set.add(RestImpl.class);
> return set;
>  }
> 
>  public Set getSingletons() {
>   return Collections.singleton(RestImpl.class);
>  }
> }
> 
> - Execution of endpoint /example/test results in personService == null, so no 
> DI
> - Disabling @JSONRequired results in personService != null, so  DI work here
> - Disabling @JaxrsApplicationSelect results in personService != null, so  DI 
> work here
> 
> This drives me into the direction that there is no problem with dependencies.
> It seems that if @JaxrsApplicationSelect and @JSONRequired are used at the 
> same time, no DI happens.
> 
> Best,
> 
> -- Jaap
> 
>> -Original Message-
>> From: Paul Spencer 
>> Sent: donderdag 26 januari 2023 00:32
>> To: user@karaf.apache.org
>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not
>> with DS
>> 
>> Jaap,
>> I suggest placing the PersonService in a separate bundle.
>> 
>> Paul Spencer
>> 
>> 
>>> On Jan 25, 2023, at 3:57 PM, Jaap Gordijn  wrote:
>>> 
>>> Paul,
>>> 
>>> The Rest class and the PersonService are in the same bundle.
>>> 
>>> Do you know if there are any examples out there that show
>> @JaxrsApplicationSelect in combination with DS?
>>> It seems now that Application/@JaxrsApplicationBase ignores DS.
>>> 
>>> -- Jaap
>>> 
>>>> -Original Message-
>>>> From: Paul Spencer 
>>>> Sent: dinsdag 24 januari 2023 01:41
>>>> To: user@karaf.apache.org
>>>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect
>>>> works not with DS
>>>> 
>>>> - Does bundle:headers for the REST bundle have a required capability
>>>> to the Person Service, foo.bar.PersonService in the example below.
>>>> 
>>>> karaf@root> bundle:headers  ...
>>>> Require-Capability =
>>>> 
>>>> osgi.service;effective:=active;filter:=(objectClass=foo.bar.PersonSer
>>>> vice),
>>>> ...
>>>> 
>>>> karaf@root>
>>>> 
>>>> 
>>>> My assumption is the requirement is missing, meaning the requirement
>>>> in the REST bundle is not defined correctly.
>>>> 
>>>> Paul Spencer
>>>> 
>>>>

Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not with DS

2023-01-25 Thread Paul Spencer
Jaap,
I suggest placing the PersonService in a separate bundle.

Paul Spencer


> On Jan 25, 2023, at 3:57 PM, Jaap Gordijn  wrote:
> 
> Paul,
> 
> The Rest class and the PersonService are in the same bundle.
> 
> Do you know if there are any examples out there that show 
> @JaxrsApplicationSelect in combination with DS?
> It seems now that Application/@JaxrsApplicationBase ignores DS.
> 
> -- Jaap
> 
>> -Original Message-
>> From: Paul Spencer 
>> Sent: dinsdag 24 januari 2023 01:41
>> To: user@karaf.apache.org
>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not
>> with DS
>> 
>> - Does bundle:headers for the REST bundle have a required capability to the
>> Person Service, foo.bar.PersonService in the example below.
>> 
>> karaf@root> bundle:headers  ...
>> Require-Capability =
>>  osgi.service;effective:=active;filter:=(objectClass=foo.bar.PersonSer
>> vice),
>> ...
>> 
>> karaf@root>
>> 
>> 
>> My assumption is the requirement is missing, meaning the requirement in
>> the REST bundle is not defined correctly.
>> 
>> Paul Spencer
>> 
>> 
>>> On Jan 23, 2023, at 5:44 PM, Jaap Gordijn  wrote:
>>> 
>>> Paul,
>>> 
>>> - scr is installed and started
>>> - the person bundle started
>>> - diag does not produce any output
>>> 
>>> Best,
>>> 
>>> -- Jaap
>>> 
>>>> -Original Message-
>>>> From: Paul Spencer 
>>>> Sent: maandag 23 januari 2023 23:12
>>>> To: user@karaf.apache.org
>>>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect
>>>> works not with DS
>>>> 
>>>> Jaap,
>>>> 1) What bundle provides PersonService and what is its state, as
>>>> reported by bundle:list?
>>>> 2) What is the state, as reported by bundle:list, of your REST bundle.
>>>> 
>>>> If any of the bundles are in a state of waiting, what does
>>>> bundle:diag  of the waiting bundle report?
>>>> 
>>>> Is the feature scr installed, if not install it.
>>>> 
>>>> Paul Spencer
>>>> 
>>>> 
>>>>> On Jan 23, 2023, at 3:38 PM, Jaap Gordijn  wrote:
>>>>> 
>>>>> Paul,
>>>>> 
>>>>> I have now minimized the code that I call via REST:
>>>>> 
>>>>>   @Reference(scope=ReferenceScope.PROTOTYPE_REQUIRED)
>>>>>   private PersonService personService;
>>>>> 
>>>>>   @GET
>>>>>   @Path("/test")
>>>>>   public String test() {
>>>>>   System.out.println("personService null" + (personService ==
>>>> null));
>>>>>   return "test";
>>>>>   }
>>>>> 
>>>>> The personService remains null, so no DI.
>>>>> 
>>>>> I enabled DEBUG in the log.
>>>>> 
>>>>> I only see DEBUG messages for " org.eclipse.jetty.util".
>>>>> Not for anything else.
>>>>> 
>>>>> Nevertheless, feature:list | grep jax Results in:
>>>>> 
>>>>> aries-jax-rs-whiteboard │ 2.0.2│  │ 
>>>>> Started │ aries-
>> jax-
>>>> rs-2.0.2│
>>>>> aries-jax-rs-whiteboard-jackson │ 2.0.2│  │ 
>>>>> Started │
>> aries-
>>>> jax-rs-2.0.2│
>>>>> aries-jax-rs-whiteboard-jettison│ 2.0.2│  │ 
>>>>> Uninstalled │
>>>> aries-jax-rs-2.0.2│
>>>>> aries-jax-rs-whiteboard-openapi │ 2.0.2│  │ 
>>>>> Uninstalled │
>>>> aries-jax-rs-2.0.2│
>>>>> aries-jax-rs-whiteboard-rest-management │ 2.0.2│  │
>> Uninstalled
>>>> │ aries-jax-rs-2.0.2│
>>>>> aries-jax-rs-whiteboard-shiro   │ 2.0.2│  │ 
>>>>> Uninstalled │
>> aries-
>>>> jax-rs-2.0.2│
>>>>> jaxb    │ 2.3.2.3  │  │ 
>>>>> Uninstalled │ specs-4.4.3
>>>> │
>>>>> jaxrs   │ 2.1.0│  │ 

Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not with DS

2023-01-23 Thread Paul Spencer
- Does bundle:headers for the REST bundle have a required capability to the 
Person Service, foo.bar.PersonService in the example below.

karaf@root> bundle:headers 
...
Require-Capability = 

osgi.service;effective:=active;filter:=(objectClass=foo.bar.PersonService),
...

karaf@root> 


My assumption is the requirement is missing, meaning the requirement in the 
REST bundle is not defined correctly.

Paul Spencer
 

> On Jan 23, 2023, at 5:44 PM, Jaap Gordijn  wrote:
> 
> Paul,
> 
> - scr is installed and started
> - the person bundle started
> - diag does not produce any output
> 
> Best,
> 
> -- Jaap
> 
>> -Original Message-
>> From: Paul Spencer 
>> Sent: maandag 23 januari 2023 23:12
>> To: user@karaf.apache.org
>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not
>> with DS
>> 
>> Jaap,
>> 1) What bundle provides PersonService and what is its state, as reported by
>> bundle:list?
>> 2) What is the state, as reported by bundle:list, of your REST bundle.
>> 
>> If any of the bundles are in a state of waiting, what does bundle:diag
>>  of the waiting bundle report?
>> 
>> Is the feature scr installed, if not install it.
>> 
>> Paul Spencer
>> 
>> 
>>> On Jan 23, 2023, at 3:38 PM, Jaap Gordijn  wrote:
>>> 
>>> Paul,
>>> 
>>> I have now minimized the code that I call via REST:
>>> 
>>> @Reference(scope=ReferenceScope.PROTOTYPE_REQUIRED)
>>> private PersonService personService;
>>> 
>>> @GET
>>> @Path("/test")
>>> public String test() {
>>> System.out.println("personService null" + (personService ==
>> null));
>>> return "test";
>>> }
>>> 
>>> The personService remains null, so no DI.
>>> 
>>> I enabled DEBUG in the log.
>>> 
>>> I only see DEBUG messages for " org.eclipse.jetty.util".
>>> Not for anything else.
>>> 
>>> Nevertheless, feature:list | grep jax
>>> Results in:
>>> 
>>> aries-jax-rs-whiteboard │ 2.0.2│  │ 
>>> Started │ aries-jax-
>> rs-2.0.2│
>>> aries-jax-rs-whiteboard-jackson │ 2.0.2│  │ 
>>> Started │ aries-
>> jax-rs-2.0.2│
>>> aries-jax-rs-whiteboard-jettison│ 2.0.2│  │ 
>>> Uninstalled │
>> aries-jax-rs-2.0.2│
>>> aries-jax-rs-whiteboard-openapi │ 2.0.2│  │ 
>>> Uninstalled │
>> aries-jax-rs-2.0.2│
>>> aries-jax-rs-whiteboard-rest-management │ 2.0.2│  │ 
>>> Uninstalled
>> │ aries-jax-rs-2.0.2│
>>> aries-jax-rs-whiteboard-shiro   │ 2.0.2│  │ 
>>> Uninstalled │ aries-
>> jax-rs-2.0.2│
>>> jaxb│ 2.3.2.3  │  │ 
>>> Uninstalled │ specs-4.4.3
>> │
>>> jaxrs   │ 2.1.0│  │ 
>>> Uninstalled │ specs-4.4.3
>> │
>>> jaxws   │ 2.3.0│  │ 
>>> Uninstalled │ specs-4.4.3
>> │
>>> jackson-jaxrs   │ 2.14.1   │  │ 
>>> Uninstalled │ specs-4.4.3
>> │
>>> cxf-jaxb        │ 3.5.5│  │ 
>>> Uninstalled │ cxf-3.5.5
>> │
>>> cxf-jaxws   │ 3.5.5│  │ 
>>> Uninstalled │ cxf-3.5.5
>> │
>>> cxf-jaxrs   │ 3.5.5│  │ 
>>> Started │ cxf-3.5.5
>> │
>>> cxf-databinding-jaxb│ 3.5.5│  │ 
>>> Uninstalled │ cxf-3.5.5
>> │
>>> cxf-jaxrs-cdi   │ 3.5.5│  │ 
>>> Uninstalled │ cxf-3.5.5
>> │
>>> karaf@root()>
>>> 
>>> This gives me the impression that the whitenboard stuff is working.
>>> 
>>> -- Jaap
>>> 
>>>> -Original Message-
>>> 
>>> 
>>>> From: Paul Spencer 
>>>> Sent: maandag 23 januari 2023 21:19
>>>> To: user@karaf.apache.org
>>>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect
>>>>

Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not with DS

2023-01-23 Thread Paul Spencer
Jaap,
1) What bundle provides PersonService and what is its state, as reported by 
bundle:list?
2) What is the state, as reported by bundle:list, of your REST bundle.

If any of the bundles are in a state of waiting, what does bundle:diag 
 of the waiting bundle report?

Is the feature scr installed, if not install it.

Paul Spencer


> On Jan 23, 2023, at 3:38 PM, Jaap Gordijn  wrote:
> 
> Paul,
> 
> I have now minimized the code that I call via REST:
> 
>   @Reference(scope=ReferenceScope.PROTOTYPE_REQUIRED)
>   private PersonService personService;
> 
>   @GET
>   @Path("/test")
>   public String test() {
>   System.out.println("personService null" + (personService == 
> null));
>   return "test"; 
>   }
> 
> The personService remains null, so no DI.
> 
> I enabled DEBUG in the log.
> 
> I only see DEBUG messages for " org.eclipse.jetty.util".
> Not for anything else.
> 
> Nevertheless, feature:list | grep jax
> Results in:
> 
> aries-jax-rs-whiteboard │ 2.0.2│  │ 
> Started │ aries-jax-rs-2.0.2│
> aries-jax-rs-whiteboard-jackson │ 2.0.2│  │ 
> Started │ aries-jax-rs-2.0.2│
> aries-jax-rs-whiteboard-jettison│ 2.0.2│  │ 
> Uninstalled │ aries-jax-rs-2.0.2│
> aries-jax-rs-whiteboard-openapi │ 2.0.2│  │ 
> Uninstalled │ aries-jax-rs-2.0.2│
> aries-jax-rs-whiteboard-rest-management │ 2.0.2│  │ 
> Uninstalled │ aries-jax-rs-2.0.2│
> aries-jax-rs-whiteboard-shiro   │ 2.0.2│  │ 
> Uninstalled │ aries-jax-rs-2.0.2│
> jaxb│ 2.3.2.3  │  │ 
> Uninstalled │ specs-4.4.3   │
> jaxrs   │ 2.1.0│  │ 
> Uninstalled │ specs-4.4.3   │
> jaxws   │ 2.3.0│  │ 
> Uninstalled │ specs-4.4.3   │
> jackson-jaxrs   │ 2.14.1   │  │ 
> Uninstalled │ specs-4.4.3   │
> cxf-jaxb│ 3.5.5│  │ 
> Uninstalled │ cxf-3.5.5 │
> cxf-jaxws   │ 3.5.5│  │ 
> Uninstalled │ cxf-3.5.5 │
> cxf-jaxrs   │ 3.5.5│  │ 
> Started │ cxf-3.5.5 │
> cxf-databinding-jaxb│ 3.5.5│  │ 
> Uninstalled │ cxf-3.5.5 │
> cxf-jaxrs-cdi   │ 3.5.5│  │ 
> Uninstalled │ cxf-3.5.5 │
> karaf@root()>   
> 
> This gives me the impression that the whitenboard stuff is working.
> 
> -- Jaap
> 
>> -Original Message-
> 
> 
>> From: Paul Spencer 
>> Sent: maandag 23 januari 2023 21:19
>> To: user@karaf.apache.org
>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not
>> with DS
>> 
>> Jaap,
>> Something is missing.  The @Referenece should prevent the component
>> from becoming Active when a PeopleService does not exist.
>> Look in Karaf.log for clues.
>> 
>> Paul Spencer
>> 
>>> On Jan 23, 2023, at 3:14 PM, Jaap Gordijn  wrote:
>>> 
>>> Paul,
>>> 
>>> I tried also the @Reference annotation.
>>> This doesn't work, the variable remains null.
>>> No injection is happening.
>>> 
>>> -- Jaap
>>> 
>>>> -Original Message-
>>>> From: Paul Spencer 
>>>> Sent: maandag 23 januari 2023 21:09
>>>> To: user@karaf.apache.org
>>>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect
>>>> works not with DS
>>>> 
>>>> Jaap,
>>>> In the code I posted, there was not constructor.  I moved the
>>>> injection of personService to an @Reference annotated field.  The
>>>> @Activator annotation is for a method, which you may not need based on
>> your example.
>>>> 
>>>> Paul Spencer
>>>> 
>>>> 
>>>>> On Jan 23, 2023, at 2:30 PM, Jaap Gordijn  wrote:
>>>>> 
>>>>> Hi Paul,
>>>>> 
>>>>> That constructor is cal

Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not with DS

2023-01-23 Thread Paul Spencer
Jaap,
Something is missing.  The @Referenece should prevent the component from 
becoming Active when a PeopleService does not exist.   
Look in Karaf.log for clues.

Paul Spencer

> On Jan 23, 2023, at 3:14 PM, Jaap Gordijn  wrote:
> 
> Paul,
> 
> I tried also the @Reference annotation.
> This doesn't work, the variable remains null.
> No injection is happening.
> 
> -- Jaap
> 
>> -Original Message-
>> From: Paul Spencer 
>> Sent: maandag 23 januari 2023 21:09
>> To: user@karaf.apache.org
>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not
>> with DS
>> 
>> Jaap,
>> In the code I posted, there was not constructor.  I moved the injection of
>> personService to an @Reference annotated field.  The @Activator
>> annotation is for a method, which you may not need based on your example.
>> 
>> Paul Spencer
>> 
>> 
>>> On Jan 23, 2023, at 2:30 PM, Jaap Gordijn  wrote:
>>> 
>>> Hi Paul,
>>> 
>>> That constructor is called, but only if I disable @@JaxrsApplicationSelect.
>>> 
>>> If I enable it, only the default constructor is called (Rest() in my case.
>>> And no DS.
>>> 
>>> -- Jaap
>>> 
>>>> -Original Message-
>>>> From: Paul Spencer 
>>>> Sent: maandag 23 januari 2023 18:59
>>>> To: user@karaf.apache.org
>>>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect
>>>> works not with DS
>>>> 
>>>> Jaap,
>>>> Your @Activate annotation is incorrect.
>>>> Try the following.
>>>> 
>>>> 
>>>> …
>>>> public class Rest() {
>>>> 
>>>>   @Reference
>>>>   private PersonService personService;
>>>> 
>>>>   @Activate
>>>>   public void activate(Map  properties) {
>>>>   ...
>>>>   }
>>>> 
>>>> }
>>>> 
>>>> Paul Spencer
>>>> 
>>>> 
>>>>> On Jan 23, 2023, at 12:40 PM, Jaap Gordijn  wrote:
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> I use an Application object (with @JaxrsApplicationSelect),
>>>>> injection via DS does not work:
>>>>> 
>>>>> @Component(service = Rest.class, scope = ServiceScope.PROTOTYPE)
>>>>> @JaxrsResource @JaxrsApplicationSelect("(" +
>>>>> JaxrsWhiteboardConstants.JAX_RS_NAME +
>>>>> "=MyApplication)")
>>>>> @JSONRequired
>>>>> @Produces(MediaType.APPLICATION_JSON)
>>>>> public class Rest {
>>>>> 
>>>>> private PersonService personService;
>>>>> 
>>>>> /*
>>>>>  public Rest() {
>>>>> System.out.println("Constructing REST");
>>>>>   this.personService = new PersonServiceImpl();
>>>>>   }
>>>>> */
>>>>> 
>>>>>  @Activate
>>>>>  public Rest(final @Reference PersonService personService) {
>>>>> System.out.println("Constructing REST");
>>>>>   this.personService = personService;
>>>>>  }
>>>>> 
>>>>>  @GET
>>>>>  @Path("/person")
>>>>>  public List listPersons() {
>>>>>return personService.select();
>>>>> }
>>>>> 
>>>>> @GET
>>>>> @Path("/test")
>>>>> public String test() {
>>>>>   return "test";
>>>>> }
>>>>> }
>>>>> 
>>>>> The @Activate constructor is not called. If I enable the Rest()
>>>>> constructor that one is called.
>>>>> if I disable @JaxrsApplicationSelect, the personService is injected.
>>>>> 
>>>>> It seems that once an Application class is used (see below), DS is
>>>>> not working.
>>>>> This leads to the question what I have to set up for the Application
>> object:
>>>>> 
>>>>> @Component(service=Application.class, property =
>>>>> {"servlet.init.hide-service-list-page=true"} )
>>>>> @JaxrsApplicationBase("example")
>>>>> @JaxrsName("MyApplication")
>>>>> public class MyApplication extends Application {
>>>>> 
>>>>> public Set> getClasses() {
>>>>>HashSet> set = new HashSet>();
>>>>>set.add(Rest.class);
>>>>>return set;
>>>>> }
>>>>> 
>>>>> }
>>>>> 
>>>>> Jax-rs-whiteboard 2.02
>>>>> Karaf 4.4.3
>>>>> 
>>>>> Thanks,
>>>>> 
>>>>> -- Jaap
>>>>> 
>>>>> 
>>> 
>>> 
> 
> 



Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not with DS

2023-01-23 Thread Paul Spencer
Jaap,
In the code I posted, there was not constructor.  I moved the injection of 
personService to an @Reference annotated field.  The @Activator annotation is 
for a method, which you may not need based on your example.

Paul Spencer


> On Jan 23, 2023, at 2:30 PM, Jaap Gordijn  wrote:
> 
> Hi Paul,
> 
> That constructor is called, but only if I disable @@JaxrsApplicationSelect.
> 
> If I enable it, only the default constructor is called (Rest() in my case.
> And no DS.
> 
> -- Jaap
> 
>> -----Original Message-
>> From: Paul Spencer 
>> Sent: maandag 23 januari 2023 18:59
>> To: user@karaf.apache.org
>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not
>> with DS
>> 
>> Jaap,
>> Your @Activate annotation is incorrect.
>> Try the following.
>> 
>> 
>> …
>> public class Rest() {
>> 
>>@Reference
>>private PersonService personService;
>> 
>>@Activate
>>public void activate(Map  properties) {
>>...
>>}
>> 
>> }
>> 
>> Paul Spencer
>> 
>> 
>>> On Jan 23, 2023, at 12:40 PM, Jaap Gordijn  wrote:
>>> 
>>> Hi,
>>> 
>>> I use an Application object (with @JaxrsApplicationSelect), injection
>>> via DS does not work:
>>> 
>>> @Component(service = Rest.class, scope = ServiceScope.PROTOTYPE)
>>> @JaxrsResource @JaxrsApplicationSelect("(" +
>>> JaxrsWhiteboardConstants.JAX_RS_NAME +
>>> "=MyApplication)")
>>> @JSONRequired
>>> @Produces(MediaType.APPLICATION_JSON)
>>> public class Rest {
>>> 
>>>  private PersonService personService;
>>> 
>>>  /*
>>>   public Rest() {
>>> System.out.println("Constructing REST");
>>>this.personService = new PersonServiceImpl();
>>>}
>>>  */
>>> 
>>>   @Activate
>>>   public Rest(final @Reference PersonService personService) {
>>> System.out.println("Constructing REST");
>>>this.personService = personService;
>>>   }
>>> 
>>>   @GET
>>>   @Path("/person")
>>>   public List listPersons() {
>>> return personService.select();
>>>  }
>>> 
>>>  @GET
>>>  @Path("/test")
>>>  public String test() {
>>>return "test";
>>>  }
>>> }
>>> 
>>> The @Activate constructor is not called. If I enable the Rest()
>>> constructor that one is called.
>>> if I disable @JaxrsApplicationSelect, the personService is injected.
>>> 
>>> It seems that once an Application class is used (see below), DS is not
>>> working.
>>> This leads to the question what I have to set up for the Application object:
>>> 
>>> @Component(service=Application.class, property =
>>> {"servlet.init.hide-service-list-page=true"} )
>>> @JaxrsApplicationBase("example")
>>> @JaxrsName("MyApplication")
>>> public class MyApplication extends Application {
>>> 
>>> public Set> getClasses() {
>>> HashSet> set = new HashSet>();
>>> set.add(Rest.class);
>>> return set;
>>>  }
>>> 
>>> }
>>> 
>>> Jax-rs-whiteboard 2.02
>>> Karaf 4.4.3
>>> 
>>> Thanks,
>>> 
>>> -- Jaap
>>> 
>>> 
> 
> 



Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect works not with DS

2023-01-23 Thread Paul Spencer
Jaap,
Your @Activate annotation is incorrect.
Try the following.


…
public class Rest() {

@Reference
private PersonService personService;

@Activate
public void activate(Map  properties) {
...
}

}

Paul Spencer


> On Jan 23, 2023, at 12:40 PM, Jaap Gordijn  wrote:
> 
> Hi,
> 
> I use an Application object (with @JaxrsApplicationSelect), injection via DS
> does not work:
> 
> @Component(service = Rest.class, scope = ServiceScope.PROTOTYPE)
> @JaxrsResource
> @JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME +
> "=MyApplication)")
> @JSONRequired
> @Produces(MediaType.APPLICATION_JSON)
> public class Rest {
> 
>   private PersonService personService;
> 
>   /*
>public Rest() {
> System.out.println("Constructing REST");
> this.personService = new PersonServiceImpl();
> } 
>   */
> 
>@Activate
>public Rest(final @Reference PersonService personService) {
> System.out.println("Constructing REST");
> this.personService = personService;
>} 
> 
>@GET
>@Path("/person")
>public List listPersons() {
>  return personService.select(); 
>   }
> 
>   @GET
>   @Path("/test")
>   public String test() {
> return "test"; 
>   }
> }
> 
> The @Activate constructor is not called. If I enable the Rest() constructor
> that one is called.
> if I disable @JaxrsApplicationSelect, the personService is injected.
> 
> It seems that once an Application class is used (see below), DS is not
> working.
> This leads to the question what I have to set up for the Application object:
> 
> @Component(service=Application.class, property =
> {"servlet.init.hide-service-list-page=true"} )
> @JaxrsApplicationBase("example")
> @JaxrsName("MyApplication")
> public class MyApplication extends Application {
> 
>  public Set> getClasses() {
>  HashSet> set = new HashSet>();
>  set.add(Rest.class);
>  return set;
>   }
> 
> }
> 
> Jax-rs-whiteboard 2.02
> Karaf 4.4.3
> 
> Thanks,
> 
> -- Jaap
> 
> 



Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect and @JSONRequired result in 404

2023-01-23 Thread Paul Spencer
Jaap,
In my environment I do not use DS for the JaxrsApplication, thus my application 
class just extends Application with no additional methods for fields.  


The application snippet below accepts a web form and produces plain text from 
the URL /foo/api/webhook and demonstrates a non-default context.


karaf@root()> web:context-list
Bundle ID │ Symbolic Name │ Context Path │ 
Context Name  │ Rank │ Service ID │ Type│ Scope │ 
Registration Properties
──┼───┼──┼───┼──┼┼─┼───┼
108   │ org.apache.cxf.cxf-rt-transports-http │ /│ 
default   │ MAX  │ 0  │ HttpService │ static*   │ 
httpContext.id <http://httpcontext.id/>=default
  │   │  │  
 │  ││ │   │ 
httpContext.path=/
  │   │  │  
 │  ││ │   │ 
osgi.http.whiteboard.context.httpservice=default
  │   │  │  
 │  ││ │   │ 
osgi.http.whiteboard.context.path=/
122   │ org.ops4j.pax.web.pax-web-extender-whiteboard │ /│ 
default   │ 0│ 0  │ Whiteboard  │ static*   │ 
osgi.http.whiteboard.context.name=default
  │   │  │  
 │  ││ │   │ 
osgi.http.whiteboard.context.path=/

97│ org.apache.aries.jax.rs.whiteboard│ /foo/api │ 
context.forfooApi │ 0│ 163│ Whiteboard  │ singleton │ 
osgi.http.whiteboard.context.name=context.forfooApi
  │   │  │  
 │  ││ │   │ 
osgi.http.whiteboard.context.path=/foo/api

karaf@root()> web:servlet-list
Bundle ID │ Name   │ Class  
  │ Context Path(s) │ URLs   │ Type│ Context Filter
──┼┼──┼─┼┼─┼──
97│ cxf-servlet│ 
org.apache.aries.jax.rs.whiteboard.internal.Whiteboard$1 │ /   │ /* 
│ Whiteboard  │ (osgi.http.whiteboard.context.name=default)
97│ cxf-servlet│ 
org.apache.aries.jax.rs.whiteboard.internal.Whiteboard$1 │ /foo/api│ /* 
│ Whiteboard  │ (osgi.http.whiteboard.context.name=context.forfooApi)
108   │ cxf-osgi-transport-servlet │ 
org.apache.cxf.transport.servlet.CXFNonSpringServlet │ /   │ 
/cxf/* │ HttpService │ -
karaf@root()>
***
* Rest application defining context /foo/api
***
package com.example.foo.restapp;

import javax.ws.rs.core.Application;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsApplicationBase;
import org.osgi.service.jaxrs.whiteboard.propertytypes.JaxrsName;

@Component(service=Application.class)
@JaxrsName("fooApi")
@JaxrsApplicationBase("/foo/api")
public class FooApplication extends Application{

}

***
* Rest endpoint for /foo/api/webhook
***
...
@Path("/webhook")
@Component( scope = PROTOTYPE)
@JaxrsResource
@JaxrsApplicationSelect("(osgi.jaxrs.name=fooApi)")
public class IncommingWebHook {
...
@POST
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Path("/incommingMessage")
public Response receiveWebHook(@FormParam(MESSAGE_SID) String messageSid) {
   ...
}
...
}



> On Jan 23, 2023, at 10:05 AM, Jaap Gordijn  wrote:
> 
> Paul,
> 
> I have extended the Application class as follows:
> 
> public class MyApplication extends Application {
> 
> public Set> getClasses() {
> HashSet> set = new HashSet>();
> set.add(Rest.class);
> return set;
>  }
> 
> }
> 
> Now the endpoint resolves.
> 
> But DS dependency injection does not work.
> Is there something needed to switch this on?
> 
> -- Jaap
> 
>> -Original Message-
>> From: Paul Spencer 
>> Sent: maandag 23 januari 2023 15:16
>> To: user@karaf.apache.org
>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect and
>> @JSONRequired result in 404
>> 
>> Jaap,
>> JaxrsApplicatio

Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect and @JSONRequired result in 404

2023-01-23 Thread Paul Spencer
Jaap,
Have you created the Jaxrs application?

@Component(service=Application.class)
@JaxrsName("MyApplication")
@JaxrsApplicationBase("/example")
public class MyApp extends Application{

}

Paul Spencer

> On Jan 23, 2023, at 7:39 AM, Jaap Gordijn  wrote:
> 
> Paul,
> 
> I used the features as you suggested.
> 
> In the log, I see that the Jetty container starts.
> Also the context path is registered:
> Registering 
> OsgiServletContext{model=OsgiContextModel{WB,id=OCM-5,name='context.forMyApplication',path='/example',bundle=org.apache.aries.jax.rs.whiteboard,ref=[org.osgi.service.http.context.ServletContextHelper]}}
>  as OSGi service for "/example" context pat
> 
> But then I get this:
> org.apache.cxf.cxf-rt-transports-http - 3.5.5 | Can't find the request for 
> http://172.20.116.137:8181/example/person's Observer
> 
> Best,
> 
> -- Jaap
> 
>> -Original Message-
>> From: Paul Spencer 
>> Sent: maandag 23 januari 2023 13:13
>> To: user@karaf.apache.org
>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect and
>> @JSONRequired result in 404
>> 
>> Jaap,
>> 1) You can use the web: commands to verify the expected context exists
>> 2) Review karaf.log  to verify the the bundle startup and post relevant 
>> errors
>> 3) I use the following features:
>>  jackson
>> pax-web-http-whiteboard
>> aries-jax-rs-whiteboard
>> aries-jax-rs-whiteboard-jackson
>> 
>> Paul Spencer
>> 
>>>> On Jan 23, 2023, at 4:49 AM, Jaap Gordijn  wrote:
>>> 
>>> Hi,
>>> 
>>> I have a problem with aries-jax-rs-whiteboard and the use of
>>> @JaxrsApplicationSelect and @JSONRequired in combination.
>>> That results in an inaccessible service (404).
>>> If I disable the JSON annotations, the /test service works (via
>>> /example/text
>>> 
>>> Code:
>>> 
>>> @Component(service = Rest.class, scope = ServiceScope.PROTOTYPE)
>>> @JaxrsResource @JaxrsApplicationSelect("(" +
>>> JaxrsWhiteboardConstants.JAX_RS_NAME +
>>> "=MyApplication)")
>>> @JSONRequired
>>> @Produces(MediaType.APPLICATION_JSON)
>>> public class Rest {
>>> 
>>>   @Reference(scope=ReferenceScope.PROTOTYPE_REQUIRED)
>>>   private volatile PersonService personService;
>>> 
>>>   @GET
>>>   @Path("/person")
>>>   public List listPersons() {
>>>   return personService.select();
>>>   }
>>> 
>>>   @GET
>>>   @Path("/test")
>>>   public String test() {
>>>   return "test";
>>>   }
>>> }
>>> 
>>> @Component(service=Application.class, property =
>>> {"servlet.init.hide-service-list-page=true"} )
>>> @JaxrsApplicationBase("example")
>>> @JaxrsName("MyApplication")
>>> public class MyApplication extends Application {
>>> 
>>> }
>>> 
>>> 
>>> mvn:org.apache.cxf.karaf/apache-cxf/3.5.5/xml/features>> posito
>>> ry>
>>> 
>>> mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.featur
>>> es/2.0
>>> .2/xml>>  
>>>  hibernate
>>>  hibernate-validator
>>>  ...
>>> 
>>> I use Karaf 4.4.3
>>> 
>>> Any ideas?
>>> 
>>> Best,
>>> 
>>> -- Jaap
>>> 
> 


Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect and @JSONRequired result in 404

2023-01-23 Thread Paul Spencer
Jaap,
JaxrsApplicationBase is used with JaxrsApplicationSelect to is required to use 
a non-default context, so your results confirm the default context is working.

Paul Spencer

> On Jan 23, 2023, at 9:08 AM, Jaap Gordijn  wrote:
> 
> Paul,
> 
> I did the following to create the application.
> 
> @Component(service=Application.class, property =  
> {"servlet.init.hide-service-list-page=true"} )
> @JaxrsApplicationBase("example")
> @JaxrsName("MyApplication")
> public class MyApplication extends Application {
> 
> }
> 
> The strange thing is at that if I remove the @JaxrsApplicationSelect in the 
> Rest service class, then it works. But not with the Application class.
> 
> -- Jaap
> 
>> -Original Message-
>> From: Paul Spencer 
>> Sent: maandag 23 januari 2023 14:11
>> To: user@karaf.apache.org
>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect and
>> @JSONRequired result in 404
>> 
>> Jaap,
>> Have you created the Jaxrs application?
>> 
>> @Component(service=Application.class)
>> @JaxrsName("MyApplication")
>> @JaxrsApplicationBase("/example")
>> public class MyApp extends Application{
>> 
>> }
>> 
>> Paul Spencer
>> 
>>>> On Jan 23, 2023, at 7:39 AM, Jaap Gordijn  wrote:
>>> 
>>> Paul,
>>> 
>>> I used the features as you suggested.
>>> 
>>> In the log, I see that the Jetty container starts.
>>> Also the context path is registered:
>>> Registering
>>> OsgiServletContext{model=OsgiContextModel{WB,id=OCM-
>> 5,name='context.fo
>>> rMyApplication',path='/example',bundle=org.apache.aries.jax.rs.whitebo
>>> ard,ref=[org.osgi.service.http.context.ServletContextHelper]}} as OSGi
>>> service for "/example" context pat
>>> 
>>> But then I get this:
>>> org.apache.cxf.cxf-rt-transports-http - 3.5.5 | Can't find the request
>>> for http://172.20.116.137:8181/example/person's Observer
>>> 
>>> Best,
>>> 
>>> -- Jaap
>>> 
>>>> -Original Message-
>>>> From: Paul Spencer 
>>>> Sent: maandag 23 januari 2023 13:13
>>>> To: user@karaf.apache.org
>>>> Subject: Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect and
>>>> @JSONRequired result in 404
>>>> 
>>>> Jaap,
>>>> 1) You can use the web: commands to verify the expected context
>>>> exists
>>>> 2) Review karaf.log  to verify the the bundle startup and post
>>>> relevant errors
>>>> 3) I use the following features:
>>>> jackson
>>>> pax-web-http-whiteboard
>>>> aries-jax-rs-whiteboard
>>>> aries-jax-rs-whiteboard-jackson
>>>> 
>>>> Paul Spencer
>>>> 
>>>>>> On Jan 23, 2023, at 4:49 AM, Jaap Gordijn  wrote:
>>>>> 
>>>>> Hi,
>>>>> 
>>>>> I have a problem with aries-jax-rs-whiteboard and the use of
>>>>> @JaxrsApplicationSelect and @JSONRequired in combination.
>>>>> That results in an inaccessible service (404).
>>>>> If I disable the JSON annotations, the /test service works (via
>>>>> /example/text
>>>>> 
>>>>> Code:
>>>>> 
>>>>> @Component(service = Rest.class, scope = ServiceScope.PROTOTYPE)
>>>>> @JaxrsResource @JaxrsApplicationSelect("(" +
>>>>> JaxrsWhiteboardConstants.JAX_RS_NAME +
>>>>> "=MyApplication)")
>>>>> @JSONRequired
>>>>> @Produces(MediaType.APPLICATION_JSON)
>>>>> public class Rest {
>>>>> 
>>>>>  @Reference(scope=ReferenceScope.PROTOTYPE_REQUIRED)
>>>>>  private volatile PersonService personService;
>>>>> 
>>>>>  @GET
>>>>>  @Path("/person")
>>>>>  public List listPersons() {
>>>>>  return personService.select();
>>>>>  }
>>>>> 
>>>>>  @GET
>>>>>  @Path("/test")
>>>>>  public String test() {
>>>>>  return "test";
>>>>>  }
>>>>> }
>>>>> 
>>>>> @Component(service=Application.class, property =
>>>>> {"servlet.init.hide-service-list-page=true"} )
>>>>> @JaxrsApplicationBase("example")
>>>>> @JaxrsName("MyApplication")
>>>>> public class MyApplication extends Application {
>>>>> 
>>>>> }
>>>>> 
>>>>> 
>>>>> mvn:org.apache.cxf.karaf/apache-cxf/3.5.5/xml/features>>>> re
>>>>> posito
>>>>> ry>
>>>>> 
>>>>> mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.feat
>>>>> ur
>>>>> es/2.0
>>>>> .2/xml>>>> 
>>>>> hibernate
>>>>> hibernate-validator
>>>>> ...
>>>>> 
>>>>> I use Karaf 4.4.3
>>>>> 
>>>>> Any ideas?
>>>>> 
>>>>> Best,
>>>>> 
>>>>> -- Jaap
>>>>> 
>>> 
> 


Re: aries-jax-rs-whiteboard with @JaxrsApplicationSelect and @JSONRequired result in 404

2023-01-23 Thread Paul Spencer
 Jaap,
1) You can use the web: commands to verify the expected context exists
2) Review karaf.log  to verify the the bundle startup and post relevant errors
3) I use the following features:
  jackson
 pax-web-http-whiteboard
 aries-jax-rs-whiteboard
 aries-jax-rs-whiteboard-jackson

Paul Spencer

> On Jan 23, 2023, at 4:49 AM, Jaap Gordijn  wrote:
> 
> Hi,
> 
> I have a problem with aries-jax-rs-whiteboard and the use of
> @JaxrsApplicationSelect and @JSONRequired in combination.
> That results in an inaccessible service (404).
> If I disable the JSON annotations, the /test service works (via
> /example/text
> 
> Code:
> 
> @Component(service = Rest.class, scope = ServiceScope.PROTOTYPE)
> @JaxrsResource
> @JaxrsApplicationSelect("(" + JaxrsWhiteboardConstants.JAX_RS_NAME +
> "=MyApplication)")
> @JSONRequired
> @Produces(MediaType.APPLICATION_JSON)
> public class Rest {
>
>@Reference(scope=ReferenceScope.PROTOTYPE_REQUIRED)
>private volatile PersonService personService;
> 
>@GET
>@Path("/person")
>public List listPersons() {
>return personService.select(); 
>}
>
>@GET
>@Path("/test")
>public String test() {
>return "test"; 
>}
> }
> 
> @Component(service=Application.class, property =
> {"servlet.init.hide-service-list-page=true"} )
> @JaxrsApplicationBase("example")
> @JaxrsName("MyApplication")
> public class MyApplication extends Application {
> 
> }
> 
> 
> mvn:org.apache.cxf.karaf/apache-cxf/3.5.5/xml/features ry>
> 
> mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.features/2.0
> .2/xml   
>   hibernate
>   hibernate-validator
>   ...
> 
> I use Karaf 4.4.3
> 
> Any ideas?
> 
> Best,
> 
> -- Jaap
> 


[jira] [Commented] (KARAF-7634) Adding Aries JaxRS feature duplicates features

2023-01-22 Thread Paul Spencer (Jira)


[ 
https://issues.apache.org/jira/browse/KARAF-7634?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17679659#comment-17679659
 ] 

Paul Spencer commented on KARAF-7634:
-

This issue appears to have been resolved in 4.4.3.

> Adding Aries JaxRS feature duplicates features
> --
>
> Key: KARAF-7634
> URL: https://issues.apache.org/jira/browse/KARAF-7634
> Project: Karaf
>  Issue Type: Documentation
>  Components: karaf
>Affects Versions: 4.4.2
> Environment: {{karaf@root()> info}}
> {{Karaf}}
> {{  Karaf version               4.4.2}}
> {{  Karaf home                  /Users/paul/Downloads/apache-karaf-4.4.2}}
> {{  Karaf base                  /Users/paul/Downloads/apache-karaf-4.4.2}}
> {{  OSGi Framework              org.apache.felix.framework-7.0.5}}
> {{JVM}}
> {{  Java Virtual Machine        OpenJDK 64-Bit Server VM version 11.0.2+9}}
> {{  Version                     11.0.2}}
> {{  Vendor                      Oracle Corporation}}
> {{  Pid                         6517}}
> {{  Uptime                      21 minutes}}
> {{  Process CPU time            20.598 seconds}}
> {{  Process CPU load            0.00}}
> {{  System CPU load             0.00}}
> {{  Open file descriptors       90}}
> {{  Max file descriptors        10,240}}
> {{  Total compile time          14.524 seconds}}
> {{Threads}}
> {{  Live threads                60}}
> {{  Daemon threads              52}}
> {{  Peak                        106}}
> {{  Total started               198}}
> {{Memory}}
> {{  Current heap size           49,871 kbytes}}
> {{  Maximum heap size           16,777,216 kbytes}}
> {{  Committed heap size         1,261,568 kbytes}}
> {{  Pending objects             0}}
> {{  Garbage collector           Name = 'G1 Young Generation', Collections = 
> 5, Time = 0.035 seconds}}
> {{  Garbage collector           Name = 'G1 Old Generation', Collections = 0, 
> Time = 0.000 seconds}}
> {{Classes}}
> {{  Current classes loaded      8,578}}
> {{  Total classes loaded        8,579}}
> {{  Total classes unloaded      1}}
> {{Operating system}}
> {{  Name                        Mac OS X version 10.16}}
> {{  Architecture                x86_64}}
> {{  Processors                  16}}
> {{karaf@root()>                                                               
>                                                                               
>                                    }}
>Reporter: Paul Spencer
>Assignee: Jean-Baptiste Onofré
>Priority: Major
>
> Simply adding the org.apache.aries.jax.rs/1.0.6 feature repo duplicates 
> existing pax and other features.
>  
> To recreate:
>  # Extract Karaf from the distribution
>  # Start Karaf using
> bin/karaf
>  # List features using
> feature:list | grep  pax-web | sort
>  # Add the Aries JaxRS repo using
> feature:repo-add 
> mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.features/1.0.6/xml 
>  # List features using to see the duplicate features
> feature:list | grep  pax-web | sort
> .
> ** Example below
> {{        __ __                        }}
> {{       / //_/ __ _/ __/      }}
> {{      / ,<  / __ `/ ___/ __ `/ /_        }}
> {{     / /| |/ /_/ / /  / /_/ / __/        }}
> {{    /_/ |_|\__,_/_/   \__,_/_/         }}
> {{  Apache Karaf (4.4.2)}}
> {{Hit '' for a list of available commands}}
> {{and '[cmd] --help' for help on a specific command.}}
> {{Hit '' or type 'system:shutdown' or 'logout' to shutdown Karaf.}}
> {{karaf@root()>  feature:list | grep pax-web | sort                           
>                                                                               
>                                    }}
> {{pax-web-core                      │ 8.0.11           │          │ 
> Uninstalled │ org.ops4j.pax.web-8.0.11          │ Core Pax Web bundles}}
> {{pax-web-http                      │ 8.0.11           │          │ 
> Uninstalled │ standard-4.4.2                    │ Pax Web OSGi HTTP Service}}
> {{pax-web-http-jetty                │ 8.0.11           │          │ 
> Uninstalled │ org.ops4j.pax.web-8.0.11          │ Http Service implementation 
> using Jetty 9}}
> {{pax-web-http-tomcat               │ 8.0.11           │          │ 
> Uninstalled │ org.ops4j.pax.web-8.0.11          │ Http Service implementation 
> using Tomcat 9}}
> {{pax-web-http-undertow             │ 8.0.11           │          │ 
> Uninstalled │ org.ops4j.pax.web-8.0.11          │ Http Service implementation 
> using Undertow 2}}
> {{pax-web-http-war                  

[jira] [Created] (KARAF-7640) "schemaLocation... must have even number of URI's." in example feature.xml files

2023-01-22 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7640:
---

 Summary: "schemaLocation... must have even number of URI's." in 
example feature.xml files
 Key: KARAF-7640
 URL: https://issues.apache.org/jira/browse/KARAF-7640
 Project: Karaf
  Issue Type: Bug
  Components: karaf
Affects Versions: 4.4.3
Reporter: Paul Spencer


Getting the following errors when viewing feature.xml files in the Karaf 4.4.3 
example directories:

Multiple annotations found at this line:
- SchemaLocation: schemaLocation value = 
'[http://karaf.apache.org/xmlns/features/v1.4.0]' must have even number of 
URI's.
- cvc-elt.1.a: Cannot find the declaration of element 'features’.

Offending tag:
http://karaf.apache.org/xmlns/features/v1.4.0]; 
xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance]; 
xsi:schemaLocation="[http://karaf.apache.org/xmlns/features/v1.4.0]”>

The duplicating the URL in the xsi:schemaLocation attribute appears to resolve 
the issue error.  
Working tag:
http://karaf.apache.org/xmlns/features/v1.4.0]; 
xmlns:xsi="[http://www.w3.org/2001/XMLSchema-instance]; 
xsi:schemaLocation="[http://karaf.apache.org/xmlns/features/v1.4.0] 
[http://karaf.apache.org/xmlns/features/v1.4.0]”>



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Created] (KARAF-7639) Some REST example features fail to install

2023-01-21 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7639:
---

 Summary: Some REST example features fail to install
 Key: KARAF-7639
 URL: https://issues.apache.org/jira/browse/KARAF-7639
 Project: Karaf
  Issue Type: Bug
  Components: karaf
Affects Versions: 4.4.3
Reporter: Paul Spencer


Some of the REST Example features fail to install due to missing dependencies.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


"schemaLocation... must have even number of URI's." in example feature.xml files

2023-01-21 Thread Paul Spencer
Getting the following errors when viewing feature.xml files in the Karaf 4.4.3 
example directories:

Multiple annotations found at this line:
- SchemaLocation: schemaLocation value = 
'http://karaf.apache.org/xmlns/features/v1.4.0' must have even number of URI's.
- cvc-elt.1.a: Cannot find the declaration of element 'features’.

Offending tag:
http://karaf.apache.org/xmlns/features/v1.4.0; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.4.0”>

The duplicating the URL in the xsi:schemaLocation attribute  appears to resolve 
the issue error.  
Working tag:
http://karaf.apache.org/xmlns/features/v1.4.0; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.4.0 
http://karaf.apache.org/xmlns/features/v1.4.0”>

Shall I file a JIRA?

Paul Spencer



Re: Anyone using Multiple Karaf Instances Successfully?

2023-01-20 Thread Paul Spencer
Paul,
I know creating and starting multiple instance of Karaf via the instance 
command works in 4.4.3 and 4.3.9.  Including the "errors" in your post would be 
most helpful.

Paul Spencer

> On Jan 20, 2023, at 12:37 PM, Paul Fraser  wrote:
> 
> Hi,
> 
> In trying to add instances to a fresh karaf install (4.3.6) I am getting 
> errors in the new instance log files, both when creating instances in the 
> console and also in code using InstanceService.
> 
> Console created instances report "started" in instance:list and code created 
> instances do not get beyond reporting "starting" but they both have log 
> errors.
> 
> It would be most helpful if someone can confirm they are using multiple 
> instances without any problems.
> 
> Paul Fraser
> 
> 



Re: Maven Compile Kars

2023-01-16 Thread Paul Spencer
Paul,
Although I have not generated a KAR with an Maven recover build, I suspect you 
will need to add dependencies to the KAR pom to control the build order.

See https://maven.apache.org/guides/mini/guide-multiple-modules.html

Paul Spencer

> On Jan 15, 2023, at 4:42 PM, Paul Fraser  wrote:
> 
> Hi,
> 
> When I run maven on my project the Kars are in many cases compiled before 
> some of the contained bundles.
> 
> This results in the kar(s) not containing the latest bundles.
> 
> Is there a way to force the maven reactor to place kar(s) last on the Reactor 
> Build Order?
> 
> Paul Fraser
> 



Posts to user@karaf.apache.org are not appearing.

2023-01-16 Thread Paul Spencer
Posts to user@karaf.apache.org from an email address I have posted from for 
years are not appearing. Nor have I received a response to an email from that 
account to user-ow...@karaf.apache.org <mailto:user-h...@karaf.apache.org> on 
January 6.  As a temporary workaround I have subscribed this list using a 
different email address.

How do I get this issue resolved?

Paul Spencer

Should Karaf Decanter v2.9.0 work with Karaf 4.4.3?

2023-01-16 Thread Paul Spencer
Should Karaf Decanter v2.9.0 work with Karaf 4.4.3?

Paul Spencer


[jira] [Created] (KARAF-7634) Adding Aries JaxRS feature duplicates features

2023-01-06 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7634:
---

 Summary: Adding Aries JaxRS feature duplicates features
 Key: KARAF-7634
 URL: https://issues.apache.org/jira/browse/KARAF-7634
 Project: Karaf
  Issue Type: Documentation
  Components: karaf
Affects Versions: 4.4.2
 Environment: {{karaf@root()> info}}
{{Karaf}}
{{  Karaf version               4.4.2}}
{{  Karaf home                  /Users/paul/Downloads/apache-karaf-4.4.2}}
{{  Karaf base                  /Users/paul/Downloads/apache-karaf-4.4.2}}
{{  OSGi Framework              org.apache.felix.framework-7.0.5}}

{{JVM}}
{{  Java Virtual Machine        OpenJDK 64-Bit Server VM version 11.0.2+9}}
{{  Version                     11.0.2}}
{{  Vendor                      Oracle Corporation}}
{{  Pid                         6517}}
{{  Uptime                      21 minutes}}
{{  Process CPU time            20.598 seconds}}
{{  Process CPU load            0.00}}
{{  System CPU load             0.00}}
{{  Open file descriptors       90}}
{{  Max file descriptors        10,240}}
{{  Total compile time          14.524 seconds}}
{{Threads}}
{{  Live threads                60}}
{{  Daemon threads              52}}
{{  Peak                        106}}
{{  Total started               198}}
{{Memory}}
{{  Current heap size           49,871 kbytes}}
{{  Maximum heap size           16,777,216 kbytes}}
{{  Committed heap size         1,261,568 kbytes}}
{{  Pending objects             0}}
{{  Garbage collector           Name = 'G1 Young Generation', Collections = 5, 
Time = 0.035 seconds}}
{{  Garbage collector           Name = 'G1 Old Generation', Collections = 0, 
Time = 0.000 seconds}}
{{Classes}}
{{  Current classes loaded      8,578}}
{{  Total classes loaded        8,579}}
{{  Total classes unloaded      1}}
{{Operating system}}
{{  Name                        Mac OS X version 10.16}}
{{  Architecture                x86_64}}
{{  Processors                  16}}
{{karaf@root()>                                                                 
                                                                                
                               }}
Reporter: Paul Spencer


Simply adding the org.apache.aries.jax.rs/1.0.6 feature repo duplicates 
existing pax and other features.

 

To recreate:
 # Extract Karaf from the distribution
 # Start Karaf using
bin/karaf
 # List features using
feature:list | grep  pax-web | sort
 # Add the Aries JaxRS repo using
feature:repo-add 
mvn:org.apache.aries.jax.rs/org.apache.aries.jax.rs.features/1.0.6/xml 
 # List features using to see the duplicate features
feature:list | grep  pax-web | sort

.

** Example below

{{        __ __                        }}
{{       / //_/ __ _/ __/      }}
{{      / ,<  / __ `/ ___/ __ `/ /_        }}
{{     / /| |/ /_/ / /  / /_/ / __/        }}
{{    /_/ |_|\__,_/_/   \__,_/_/         }}

{{  Apache Karaf (4.4.2)}}

{{Hit '' for a list of available commands}}
{{and '[cmd] --help' for help on a specific command.}}
{{Hit '' or type 'system:shutdown' or 'logout' to shutdown Karaf.}}

{{karaf@root()>  feature:list | grep pax-web | sort                             
                                                                                
                               }}
{{pax-web-core                      │ 8.0.11           │          │ Uninstalled 
│ org.ops4j.pax.web-8.0.11          │ Core Pax Web bundles}}
{{pax-web-http                      │ 8.0.11           │          │ Uninstalled 
│ standard-4.4.2                    │ Pax Web OSGi HTTP Service}}
{{pax-web-http-jetty                │ 8.0.11           │          │ Uninstalled 
│ org.ops4j.pax.web-8.0.11          │ Http Service implementation using Jetty 
9}}
{{pax-web-http-tomcat               │ 8.0.11           │          │ Uninstalled 
│ org.ops4j.pax.web-8.0.11          │ Http Service implementation using Tomcat 
9}}
{{pax-web-http-undertow             │ 8.0.11           │          │ Uninstalled 
│ org.ops4j.pax.web-8.0.11          │ Http Service implementation using 
Undertow 2}}
{{pax-web-http-war                  │ 4.4.2            │          │ Uninstalled 
│ standard-4.4.2                    │ Turn Karaf as a full WebContainer}}
{{pax-web-http-whiteboard           │ 8.0.11           │          │ Uninstalled 
│ standard-4.4.2                    │ Pax Web OSGi HTTP Whiteboard support}}
{{pax-web-jetty                     │ 9.4.49.v20220914 │          │ Uninstalled 
│ org.ops4j.pax.web-8.0.11          │ Jetty 9 bundles}}
{{pax-web-jetty-extras              │ 9.4.49.v20220914 │          │ Uninstalled 
│ org.ops4j.pax.web-8.0.11          │ Jetty 9 additional bundles}}
{{pax-web-jetty-http2               │ 9.4.49.v20220914 │          │ Uninstalled 
│ org.ops4j.pax.web-8.0.11          │ Jetty 9 bundles for HTTP/2 support}}
{{pax-web-jetty-http2-jdk8          │ 9.4.

[jira] [Created] (KARAF-7633) HTTPS SSL configuration needs updating

2023-01-06 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7633:
---

 Summary: HTTPS SSL configuration needs updating
 Key: KARAF-7633
 URL: https://issues.apache.org/jira/browse/KARAF-7633
 Project: Karaf
  Issue Type: Documentation
  Components: karaf
Affects Versions: 4.4.2
 Environment: Karaf 4.2.2
Reporter: Paul Spencer


The documentation to enable an HTTP connector, 
[https://karaf.apache.org/manual/latest/#_webcontainer_jsp_servlet], needs to 
be updated.  Specifically the etc/org.ops4j.pax.web.cfg configuration has the 
following inaccuracies
- "org.osgi.service.http.secure.enabled = true" is required to enable https
- org.ops4j.pax.web.ssl.keystore.password is required
- org.ops4j.pax.web.ssl.keypassword is not used
- "org.ops4j.pax.web.ssl.keystore.type = JKS" is optional but adds clarity.

***
* Steps I took to add a enable https 
***
- Generate the self signing key files "keystore" in JKS format using the 
following command
keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore -storepass 
karaf1234 -validity 360 -keysize 2048

- Copied the generated file, keystore, to ${karaf.etc}

- Add the following to etc/org.ops4j.pax.web.cfg configuration
org.osgi.service.http.secure.enabled = true
org.osgi.service.http.port.secure = 8443
org.ops4j.pax.web.ssl.keystore = ${karaf.etc}/keystore
org.ops4j.pax.web.ssl.keystore.password = karaf1234
org.ops4j.pax.web.ssl.keystore.type = JKS



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


Karaf 4.4.1 and Karaf 4.4.2 Websocket example references the command http:list instead of web:servlet-list

2022-12-19 Thread Paul Spencer
The Websocket example README.md references the command "http:list' which has 
been replaced by "web:serverlet-list.  


***
* Documentation with the incorrect command
***
You can see the websocket registered in the HTTP service:

karaf@root()> http:list
ID │ Servlet │ Servlet-Name   │ State   │ Alias 
 │ Url
───┼─┼┼─┼┼───
92 │ WebsocketExampleServlet │ ServletModel-2 │ Deployed│ 
/example-websocket │ [/example-websocket/*]

***
* Correct command
***
karaf@root()> web:servlet-list 
Bundle ID │ Name│ Class 
  │ Context Path(s) │ URLs  
   │ Type│ Context Filter
──┼─┼─┼─┼──┼─┼───
88│ org.apache.karaf.examples.websocket.WebsocketExampleServlet │ 
org.apache.karaf.examples.websocket.WebsocketExampleServlet │ /   │ 
/example-websocket/* │ HttpService │ -
karaf@root()>

I opened the following Jira  https://issues.apache.org/jira/browse/KARAF-7626

Paul Spencer

[jira] [Created] (KARAF-7626) Websocket example references the command http:list instead of web:servlet-list

2022-12-19 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7626:
---

 Summary: Websocket example references the command http:list 
instead of web:servlet-list
 Key: KARAF-7626
 URL: https://issues.apache.org/jira/browse/KARAF-7626
 Project: Karaf
  Issue Type: Documentation
  Components: karaf
Affects Versions: 4.4.2, 4.4.1
Reporter: Paul Spencer


The Websocket example README.md references the command "http:list' which has 
been replaced by "web:serverlet-list

Below is the from the readme 
[https://github.com/apache/karaf/blob/karaf-4.4.2/examples/karaf-websocket-example/README.md]
{noformat}
You can see the websocket registered in the HTTP service:

karaf@root()> http:list
ID │ Servlet                 │ Servlet-Name   │ State       │ Alias             
 │ Url
───┼─┼┼─┼┼───
92 │ WebsocketExampleServlet │ ServletModel-2 │ Deployed    │ 
/example-websocket │ [/example-websocket/*]
{noformat}
Below is output form the web:servlet-list  command
{noformat}
karaf@root()> web:servlet-list 
Bundle ID │ Name                                                        │ Class 
                                                      │ Context Path(s) │ URLs  
               │ Type        │ Context Filter
──┼─┼─┼─┼──┼─┼───
88        │ org.apache.karaf.examples.websocket.WebsocketExampleServlet │ 
org.apache.karaf.examples.websocket.WebsocketExampleServlet │ /               │ 
/example-websocket/* │ HttpService │ -
karaf@root()>
{noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


Re: Karaf 4.4.2 bin/client -> Failed (IllegalArgumentException) to execute: Invalid UINT32 value: -1

2022-11-14 Thread Paul Spencer
Just found https://issues.apache.org/jira/browse/KARAF-7607, so this is a known 
bug.

Paul Spencer

On 2022/11/14 15:53:03 Paul Spencer wrote:
>   Karaf version   4.4.2
>   Java Virtual MachineJava HotSpot(TM) 64-Bit Server VM version 
> 25.172-b11
>   Version 1.8.0_172
>   Vendor  Oracle Corporation
> 
> bin/karaf works, but bin/client fails with the following error:
>   DefaultOpenFuture[ChannelShell[id=0, 
> recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101]]: Failed 
> (IllegalArgumentException) to execute: Invalid UINT32 value: -1
> 
> I have verified the ssh port is not in use prior to starting karaf using 
> bin/start
> sparrow:apache-karaf-4.4.2 paul$ netstat -an | grep 8101
> sparrow:apache-karaf-4.4.2 paul$ 
> 
> What am I missing?
> 
> ***
> * Below is bin/client with debug logging enabled.
> ***
> sparrow:apache-karaf-4.4.2 paul$ bin/client -v -l 3
> 165 [main] DEBUG org.apache.sshd.common.util.security.SecurityUtils - 
> register([BC, true, false]) not registered - enabled=null, supported={}
> 165 [main] DEBUG org.apache.sshd.common.util.security.SecurityUtils - 
> register([EdDSA, true, false]) not registered - enabled=null, supported={}
> Logging in as karaf
> 260 [main] INFO org.apache.sshd.common.io.DefaultIoServiceFactoryFactory - No 
> detected/configured IoServiceFactoryFactory using Nio2ServiceFactoryFactory
> 266 [main] DEBUG 
> org.apache.sshd.client.config.hosts.DefaultConfigFileHostEntryResolver - 
> reloadHostConfigEntries([karaf, localhost, 8101, null, 
> /Users/paul/.ssh/config]@null:{}/{}) check permissions of {}
> 272 [main] INFO 
> org.apache.sshd.client.config.hosts.DefaultConfigFileHostEntryResolver - 
> resolveEffectiveResolver(karaf@localhost:8101) loaded 7 entries from 
> /Users/paul/.ssh/config
> 273 [main] DEBUG 
> org.apache.sshd.client.config.hosts.DefaultConfigFileHostEntryResolver - 
> resolveEffectiveHost([karaf, localhost, 8101, null, null]@null:{}/{}) => {}
> 273 [main] DEBUG org.apache.sshd.client.SshClient - connect([karaf, 
> localhost, 8101]@null:{}) no overrides
> 277 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2Connector - Connecting to 
> localhost/127.0.0.1:8101
> 282 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2Connector - 
> setOption([SO_REUSEADDR, true, Property[socket-reuseaddr](Boolean]])[null] 
> from property={}
> 286 [sshd-SshClient[10bdf5e5]-nio2-thread-1] DEBUG 
> org.apache.sshd.common.io.nio2.Nio2Session - Creating IoSession on 
> [/127.0.0.1:64796, localhost/127.0.0.1:8101, null] from null via {}
> 298 [sshd-SshClient[10bdf5e5]-nio2-thread-1] DEBUG 
> org.apache.sshd.client.session.ClientSessionImpl - Client session created: 
> Nio2Session[local=/127.0.0.1:64796, remote=localhost/127.0.0.1:8101]
> 299 [sshd-SshClient[10bdf5e5]-nio2-thread-1] DEBUG 
> org.apache.sshd.client.session.ClientUserAuthService - 
> ClientUserAuthService(ClientSessionImpl[null@localhost/127.0.0.1:8101]) 
> client methods: [publickey, keyboard-interactive, password]
> 303 [sshd-SshClient[10bdf5e5]-nio2-thread-1] DEBUG 
> org.apache.sshd.common.session.helpers.SessionTimeoutListener - 
> sessionCreated(ClientSessionImpl[null@localhost/127.0.0.1:8101]) tracking
> 304 [sshd-SshClient[10bdf5e5]-nio2-thread-1] DEBUG 
> org.apache.sshd.client.session.ClientSessionImpl - 
> initializeProxyConnector(ClientSessionImpl[null@localhost/127.0.0.1:8101]) no 
> proxy to initialize
> 305 [sshd-SshClient[10bdf5e5]-nio2-thread-1] DEBUG 
> org.apache.sshd.client.session.ClientSessionImpl - 
> sendIdentification(ClientSessionImpl[null@localhost/127.0.0.1:8101]): 
> SSH-2.0-APACHE-SSHD-2.9.1
> 305 [sshd-SshClient[10bdf5e5]-nio2-thread-1] DEBUG 
> org.apache.sshd.common.io.nio2.Nio2Session - 
> writeBuffer(Nio2Session[local=/127.0.0.1:64796, 
> remote=localhost/127.0.0.1:8101]) writing 27 bytes
> 307 [sshd-SshClient[10bdf5e5]-nio2-thread-1] DEBUG 
> org.apache.sshd.client.session.ClientSessionImpl - 
> sendKexInit(ClientSessionImpl[null@localhost/127.0.0.1:8101]) Send 
> SSH_MSG_KEXINIT
> 313 [sshd-SshClient[10bdf5e5]-nio2-thread-1] DEBUG 
> org.apache.sshd.client.session.ClientSessionImpl - 
> encode([ClientSessionImpl[null@localhost/127.0.0.1:8101], 0, 20, 
> SSH_MSG_KEXINIT, 1171]) packet #null sending command={}[{}] len={}
> 313 [sshd-SshClient[10bdf5e5]-nio2-thread-1] DEBUG 
> org.apache.sshd.common.io.nio2.Nio2Session - 
> writeBuffer(Nio2Session[local=/127.0.0.1:64796, 
> remote=localhost/127.0.0.1:8101]) writing 1184 bytes
> 314 [sshd-SshClient[10bdf5e5]-nio2-thread-1] DEBUG 
> org.apache.sshd.client.SshClient - 
> setupDefaultSessionIdentities(ClientSessionImpl[karaf@localhost/127.0.0.1:8101])
>  key identity provider override in sess

Karaf 4.4.2 bin/client -> Failed (IllegalArgumentException) to execute: Invalid UINT32 value: -1

2022-11-14 Thread Paul Spencer
BUG org.apache.sshd.common.io.nio2.Nio2ServiceFactory - Shutdown 
group
594 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2ServiceFactory - Group 
successfully shut down
594 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2ServiceFactory - Shutdown 
executor
595 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2ServiceFactory - Shutdown 
complete
595 [main] DEBUG org.apache.sshd.common.io.nio2.Nio2ServiceFactory - 
close(org.apache.sshd.common.io.nio2.Nio2ServiceFactory@53ca01a2)[Immediately] 
closed
595 [main] DEBUG org.apache.sshd.common.util.closeable.SequentialCloseable - 
doClose(org.apache.sshd.common.util.closeable.SequentialCloseable$1@358c99f5) 
signal close complete immediately=true
595 [main] DEBUG org.apache.sshd.client.SshClient - 
close(SshClient[10bdf5e5])[Immediately] closed
org.apache.sshd.common.SshException: DefaultOpenFuture[ChannelShell[id=0, 
recipient=-1]-ClientSessionImpl[karaf@localhost/127.0.0.1:8101]]: Failed 
(IllegalArgumentException) to execute: Invalid UINT32 value: -1
at 
org.apache.sshd.common.future.AbstractSshFuture.lambda$verifyResult$1(AbstractSshFuture.java:132)
at 
org.apache.sshd.common.future.AbstractSshFuture.formatExceptionMessage(AbstractSshFuture.java:190)
at 
org.apache.sshd.common.future.AbstractSshFuture.verifyResult(AbstractSshFuture.java:131)
at 
org.apache.sshd.client.future.DefaultOpenFuture.verify(DefaultOpenFuture.java:39)
at 
org.apache.sshd.client.future.DefaultOpenFuture.verify(DefaultOpenFuture.java:32)
at 
org.apache.sshd.common.future.VerifiableFuture.verify(VerifiableFuture.java:43)
at org.apache.karaf.client.Main.main(Main.java:281)
Caused by: java.lang.IllegalArgumentException: Invalid UINT32 value: -1
at 
org.apache.sshd.common.util.ValidateUtils.createFormattedException(ValidateUtils.java:213)
at 
org.apache.sshd.common.util.ValidateUtils.throwIllegalArgumentException(ValidateUtils.java:179)
at 
org.apache.sshd.common.util.ValidateUtils.checkTrue(ValidateUtils.java:162)
at 
org.apache.sshd.common.util.buffer.BufferUtils.validateUint32Value(BufferUtils.java:703)
at org.apache.sshd.common.util.buffer.Buffer.putUInt(Buffer.java:726)
at 
org.apache.sshd.client.channel.PtyCapableChannelSession.lambda$doOpenPty$0(PtyCapableChannelSession.java:265)
at java.util.HashMap.forEach(HashMap.java:1289)
at 
org.apache.sshd.client.channel.PtyCapableChannelSession.doOpenPty(PtyCapableChannelSession.java:263)
at 
org.apache.sshd.client.channel.ChannelShell.doOpen(ChannelShell.java:45)
at 
org.apache.sshd.client.channel.AbstractClientChannel.handleOpenSuccess(AbstractClientChannel.java:366)
at 
org.apache.sshd.common.session.helpers.AbstractConnectionService.channelOpenConfirmation(AbstractConnectionService.java:545)
at 
org.apache.sshd.common.session.helpers.AbstractConnectionService.process(AbstractConnectionService.java:456)
at 
org.apache.sshd.common.session.helpers.CurrentService.process(CurrentService.java:109)
at 
org.apache.sshd.common.session.helpers.AbstractSession.doHandleMessage(AbstractSession.java:594)
at 
org.apache.sshd.common.session.helpers.AbstractSession.lambda$handleMessage$0(AbstractSession.java:525)
at 
org.apache.sshd.common.util.threads.ThreadUtils.runAsInternal(ThreadUtils.java:66)
at 
org.apache.sshd.common.session.helpers.AbstractSession.handleMessage(AbstractSession.java:524)
at 
org.apache.sshd.common.session.helpers.AbstractSession.decode(AbstractSession.java:1644)
at 
org.apache.sshd.common.session.helpers.AbstractSession.messageReceived(AbstractSession.java:485)
at 
org.apache.sshd.common.session.helpers.AbstractSessionIoHandler.messageReceived(AbstractSessionIoHandler.java:64)
at 
org.apache.sshd.common.io.nio2.Nio2Session.handleReadCycleCompletion(Nio2Session.java:371)
at 
org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:344)
at 
org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:339)
at 
org.apache.sshd.common.io.nio2.Nio2CompletionHandler.lambda$completed$0(Nio2CompletionHandler.java:38)
at java.security.AccessController.doPrivileged(Native Method)
at 
org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed(Nio2CompletionHandler.java:37)
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
at sun.nio.ch.Invoker$2.run(Invoker.java:218)
at 
sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
sparrow:apache-karaf-4.4.2 paul$ 


Paul Spencer


Re: Scheduled command fails with "session is closed" after client session closed.

2022-05-17 Thread Paul Spencer
JB,
In my example the command is generating a report using command line parameters. 
 I can see use cases where schedule command perform other repetitive tasks 
requiring parameter input. That said, this may be an edge case with many 
workarounds or better implementations.  I will be using is a cron job that 
launches bin/client with the desired command.


Paul Spencer


> On May 17, 2022, at 2:20 AM, Jean-Baptiste Onofré  wrote:
> 
> Hi Paul,
> 
> if your command uses some session resources (like stream), it's normal
> as the session is closed when you quit the shell.
> 
> For mail reporting, it's better to create a service that you trigger
> with a command (one shot) or with the scheduled (trigger/cron).
> 
> Regards
> JB
> 
> On Mon, May 16, 2022 at 7:20 PM Paul Spencer  
> wrote:
>> 
>> Karaf 4.3.6
>> 
>> I have scheduled a command to run on a cron schedule, but the command fails 
>> with "java.lang.IllegalStateException: session is closed" after I exit the 
>> Karaf client session.  The command will only run in the client session 
>> scheduling the command.
>> 
>> Since command execution can be schedule, I would expect the client session 
>> scheduling the command would not be required for each execution.
>> 
>> What is I doing wrong?
>> 
>> 
>> ***
>> * Command to schedule the execution of foo:emailReport at 5PM
>> **
>> karaf@root()> scheduler:schedule-command --cron "0 0 17 * * ?" 
>> "foo:emailReport -r j...@example.com &"
>> karaf@root()> scheduler:list
>> Name  │ Schedule
>> ──┼───
>> foo:emailReport -r j...@example.com   │ cron(0 0 17 * * ?)
>> 
>> ***
>> * karaf.log
>> ***
>> 2022-05-15T17:00:00,025 | WARN  | Karaf_Worker-5   | ScriptJob   
>>  | 80 - org.apache.karaf.scheduler.core - 4.3.6 | Error executing 
>> scheduled command foo:emailReport -r j...@example.com &
>> java.lang.IllegalStateException: session is closed
>>at 
>> org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:171)
>>  ~[?:?]
>>at 
>> org.apache.karaf.shell.impl.console.ConsoleSessionImpl.execute(ConsoleSessionImpl.java:496)
>>  ~[?:?]
>>at 
>> org.apache.karaf.scheduler.command.support.CommandJob.execute(CommandJob.java:40)
>>  [!/:?]
>>at 
>> org.apache.karaf.scheduler.core.QuartzJobExecutor.execute(QuartzJobExecutor.java:58)
>>  [!/:?]
>>at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [!/:?]
>>at 
>> org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
>>  [!/:?]
>> 2022-05-15T17:03:41,930 | INFO  | Karaf_Worker-6   | 
>> ServiceRequestEmailReceiver  | 152 - 
>> com.alexanderpest.bugdata.msg-email-receiver - 2.0.2 | Message count = 554
>> 
>> 
>> karaf@root()> scheduler:list
>> Name  │ Schedule
>> ──┼───
>> foo:emailReport -r j...@example.com & │ cron(0 0 17 * * ?)
>> 
>> 
>> Paul Spencer



[jira] [Created] (KARAF-7436) Comments and order in json configuration files are not preserved

2022-05-16 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7436:
---

 Summary: Comments and order in json configuration files are not 
preserved 
 Key: KARAF-7436
 URL: https://issues.apache.org/jira/browse/KARAF-7436
 Project: Karaf
  Issue Type: Bug
  Components: karaf
Affects Versions: 4.3.6
Reporter: Paul Spencer


The OSGi specification mentions the support of comments in json configuration 
files, 
[https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.configurator.html#d0e131566],
 but the comments are stripped and the properties are reorder when a 
configuration file is read. How can comments and property order in json 
configuration files be preserved?

*foo.json before config:property-list --pid foo*
{code:java}
{
// Network Port Number
  "port":300,
// Array of int
  "an_int_array":[ 2, 3, 4 ],
// Complex structure
  "complex":{
 "a":1,
 "b":"two"
 }
}
{code}
 

*foo.json after config:property-list --pid foo*
{code:java}
{
  "an_int_array":[
   2,
   3,
   4,
   5
   ],
  "complex":"{\"a\":1,\"b\":\"two\"}",
  "port":300
 }
{code}
 

 



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


[jira] [Updated] (KARAF-7435) Setting a configuration parameter to null throws an NPE.

2022-05-16 Thread Paul Spencer (Jira)


 [ 
https://issues.apache.org/jira/browse/KARAF-7435?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul Spencer updated KARAF-7435:

Description: 
Setting a configuration parameter to null throws a NullPointerException. The 
specification, 
[https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.configurator.html],
 is silent on the use of null as a property value, but includes the following 
"If a requested conversion cannot be performed, then the configuration is not 
processed and the Configurator implementation should log an error."; in 
addition the configuration parameter are stored in a Dictionary structure which 
requires a non-null key and non-null value. Although the json format supports 
'null' as value and OSGi confutation appears to required non-null values, 
should Karaf log something like "Null value for  not supported." 
instead of throwing a NPE?

*Thrown exception*

java.lang.NullPointerException: null at 
org.apache.karaf.config.core.impl.JsonConfigInstaller.setConfig(JsonConfigInstaller.java:87)
 ~[?:?] at 
org.apache.karaf.config.core.impl.JsonConfigInstaller.update(JsonConfigInstaller.java:66)
 ~[?:?] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.update(DirectoryWatcher.java:1117)
 [!/:3.7.4] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.update(DirectoryWatcher.java:919)
 [!/:3.7.4] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:488)
 [!/:3.7.4] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365)
 [!/:3.7.4] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316)
 [!/:3.7.4]

*etc/foo.json*
{  

 "myNullValue":null

}

  was:
Setting a configuration parameter to null throws a NullPointerException. The 
specification, 
[https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.configurator.html],
 is silent on the use of null as a property value, but includes the following 
"If a requested conversion cannot be performed, then the configuration is not 
processed and the Configurator implementation should log an error."; in 
addition the configuration parameter are stored in a Dictionary structure which 
requires a non-null key and non-null value. Although the json format supports 
'null' as value and OSGi confutation appears to required non-null values, 
should Karaf log something like "Null value for  not supported." 
instead of throwing a NPE?

***
* Thrown exception
*** 
java.lang.NullPointerException: null at 
org.apache.karaf.config.core.impl.JsonConfigInstaller.setConfig(JsonConfigInstaller.java:87)
 ~[?:?] at 
org.apache.karaf.config.core.impl.JsonConfigInstaller.update(JsonConfigInstaller.java:66)
 ~[?:?] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.update(DirectoryWatcher.java:1117)
 [!/:3.7.4] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.update(DirectoryWatcher.java:919)
 [!/:3.7.4] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:488)
 [!/:3.7.4] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365)
 [!/:3.7.4] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316)
 [!/:3.7.4] 

***
* etc/foo.json
***
{ 
  "myNullValue":null
}


> Setting a configuration parameter to null throws an NPE.
> 
>
> Key: KARAF-7435
> URL: https://issues.apache.org/jira/browse/KARAF-7435
> Project: Karaf
>  Issue Type: Bug
>      Components: karaf
>Affects Versions: 4.3.6
>Reporter: Paul Spencer
>Priority: Major
>
> Setting a configuration parameter to null throws a NullPointerException. The 
> specification, 
> [https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.configurator.html],
>  is silent on the use of null as a property value, but includes the following 
> "If a requested conversion cannot be performed, then the configuration is not 
> processed and the Configurator implementation should log an error."; in 
> addition the configuration parameter are stored in a Dictionary structure 
> which requires a non-null key and non-null value. Although the json format 
> supports 'null' as value and OSGi confutation appears to required non-null 
> values, should Karaf log something like "Null value for  not 
> supported." instead of throwing a NPE?
> *Thrown exception*
> java.lang.NullPointerException: null at 
> org.apache.karaf.config.core.impl.JsonConfigInstaller.setConfig(JsonConfigInstaller.java:87)
>  ~[?:?] at 
> org.apache.karaf.config.core.impl.JsonConfigInstaller.update(JsonConfigInstaller.java:66)
>  ~[?:?] at 
> o

[jira] [Created] (KARAF-7435) Setting a configuration parameter to null throws an NPE.

2022-05-16 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7435:
---

 Summary: Setting a configuration parameter to null throws an NPE.
 Key: KARAF-7435
 URL: https://issues.apache.org/jira/browse/KARAF-7435
 Project: Karaf
  Issue Type: Bug
  Components: karaf
Affects Versions: 4.3.6
Reporter: Paul Spencer


Setting a configuration parameter to null throws a NullPointerException. The 
specification, 
[https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.configurator.html],
 is silent on the use of null as a property value, but includes the following 
"If a requested conversion cannot be performed, then the configuration is not 
processed and the Configurator implementation should log an error."; in 
addition the configuration parameter are stored in a Dictionary structure which 
requires a non-null key and non-null value. Although the json format supports 
'null' as value and OSGi confutation appears to required non-null values, 
should Karaf log something like "Null value for  not supported." 
instead of throwing a NPE?

***
* Thrown exception
*** 
java.lang.NullPointerException: null at 
org.apache.karaf.config.core.impl.JsonConfigInstaller.setConfig(JsonConfigInstaller.java:87)
 ~[?:?] at 
org.apache.karaf.config.core.impl.JsonConfigInstaller.update(JsonConfigInstaller.java:66)
 ~[?:?] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.update(DirectoryWatcher.java:1117)
 [!/:3.7.4] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.update(DirectoryWatcher.java:919)
 [!/:3.7.4] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:488)
 [!/:3.7.4] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365)
 [!/:3.7.4] at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316)
 [!/:3.7.4] 

***
* etc/foo.json
***
{ 
  "myNullValue":null
}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


scheduled command job fails with "java.lang.IllegalStateException: A job is already in foreground"

2022-05-16 Thread Paul Spencer
e   │ Alias │ Url
───┼──┼──┼─┼───┼─
86 │ Whiteboard$1 │ cxf-servlet  │ Deployed│   │ [/*]
[1]  donehttp:list  

        

   
karaf@root()> 

Paul Spencer



cut/paste error in the logger definition of the Scheduler's CommandJob?

2022-05-16 Thread Paul Spencer
Looks like a cut/paste error in the logger definition for Scheduler's 
CommandJob.

https://github.com/apache/karaf/blob/main/scheduler/src/main/java/org/apache/karaf/scheduler/command/support/CommandJob.java

public class CommandJob implements Job {

private static final Logger LOGGER = 
LoggerFactory.getLogger(ScriptJob.class);

Paul Spencer




Scheduled command fails with "session is closed" after client session closed.

2022-05-16 Thread Paul Spencer
Karaf 4.3.6

I have scheduled a command to run on a cron schedule, but the command fails 
with "java.lang.IllegalStateException: session is closed" after I exit the 
Karaf client session.  The command will only run in the client session 
scheduling the command.

Since command execution can be schedule, I would expect the client session 
scheduling the command would not be required for each execution.

What is I doing wrong?


***
* Command to schedule the execution of foo:emailReport at 5PM
**
karaf@root()> scheduler:schedule-command --cron "0 0 17 * * ?" "foo:emailReport 
-r j...@example.com &"
karaf@root()> scheduler:list
Name  │ Schedule
──┼───
foo:emailReport -r j...@example.com   │ cron(0 0 17 * * ?)

***
* karaf.log
***
2022-05-15T17:00:00,025 | WARN  | Karaf_Worker-5   | ScriptJob  
  | 80 - org.apache.karaf.scheduler.core - 4.3.6 | Error executing 
scheduled command foo:emailReport -r j...@example.com &
java.lang.IllegalStateException: session is closed
at 
org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:171)
 ~[?:?]
at 
org.apache.karaf.shell.impl.console.ConsoleSessionImpl.execute(ConsoleSessionImpl.java:496)
 ~[?:?]
at 
org.apache.karaf.scheduler.command.support.CommandJob.execute(CommandJob.java:40)
 [!/:?]
at 
org.apache.karaf.scheduler.core.QuartzJobExecutor.execute(QuartzJobExecutor.java:58)
 [!/:?]
at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [!/:?]
at 
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) 
[!/:?]
2022-05-15T17:03:41,930 | INFO  | Karaf_Worker-6   | 
ServiceRequestEmailReceiver  | 152 - 
com.alexanderpest.bugdata.msg-email-receiver - 2.0.2 | Message count = 554


karaf@root()> scheduler:list
Name  │ Schedule
──┼───
foo:emailReport -r j...@example.com & │ cron(0 0 17 * * ?)


Paul Spencer

How to preserve comments and property order in json configuration files?

2022-05-16 Thread Paul Spencer
Karaf 4.3.6

The OSGi specification mentions the support of comments in json configuration 
files, 
https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.configurator.html#d0e131566,
 but the comments are stripped and the properties are reorder when a 
configuration file is read.

How can comments and property order in json configuration files be preserved?
 


***
* foo.json before config:property-list --pid foo
***
{
// Network Port Number  
  "port":300,

// Array of int
  "an_int_array":[ 2, 3, 4 ],
  
// Complex structure  
  "complex":{
 "a":1,
 "b":"two"
  }
}


***
* foo.json after config:property-list --pid foo
***
{
  "an_int_array":[
2,
3,
4,
    5
  ],
  "complex":"{\"a\":1,\"b\":\"two\"}",
  "port":300
}


Paul Spencer

Setting a configuration parameter to null throws an NPE.

2022-05-16 Thread Paul Spencer
Karaf 4.3.6
Setting a configuration parameter to null throws a NullPointerException.  The 
specification, 
https://docs.osgi.org/specification/osgi.cmpn/7.0.0/service.configurator.html, 
is silent on the use of null as a property value, but includes the following 
"If a requested conversion cannot be performed, then the configuration is not 
processed and the Configurator implementation should log an error."; in 
addition the configuration parameter are stored in a Dictionary structure which 
requires a non-null key and non-null value.

Although the json format supports 'null' as value and OSGi confutation appears 
to required non-null values, should Karaf log something like "Null value for 
 not supported." instead of throwing a NPE?

***
* Thrown exception
***

java.lang.NullPointerException: null
at 
org.apache.karaf.config.core.impl.JsonConfigInstaller.setConfig(JsonConfigInstaller.java:87)
 ~[?:?]
at 
org.apache.karaf.config.core.impl.JsonConfigInstaller.update(JsonConfigInstaller.java:66)
 ~[?:?]
at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.update(DirectoryWatcher.java:1117)
 [!/:3.7.4]
at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.update(DirectoryWatcher.java:919)
 [!/:3.7.4]
at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:488)
 [!/:3.7.4]
at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365)
 [!/:3.7.4]
at 
org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316)
 [!/:3.7.4]


***
* etc/foo.json
***
{
   "myNullValue":null
}

Paul Spencer

Re: Karaf 4.3.6 Map in .json configuration?

2022-05-15 Thread Paul Spencer
Never mind.

I found 
https://osgi.org/specification/osgi.cmpn/7.0.0/service.configurator.html which 
matches the observed behavior.

Paul Spencer



> On May 15, 2022, at 3:18 PM, Paul Spencer  wrote:
> 
> Karaf 4.3.6
> 
> I would like to include a Map in a json configuration file.  Following the 
> example in 
> http://nanthrax.blogspot.com/2020/11/what-new-in-apache-karaf-430_9.html, I 
> created the etc/foo.json. Unfortunately the returned type of the property 
> "complex" was java.lang.String instead of the expected Map type.
> 
> Can a configuration property be a Map?
>   If so, please include an example.
> 
> 
> ***
> * etc/foo.json saved
> ***
> {
>  "complex":"{
>"a":1,
>"b":"two"
>  }
> }
> 
> ***
> * etc/foo.json rewritten by Karaf
> ***
> {
>  "complex":"{\"a\":1,\"b\":\"two\"}"
> }
> 
> ***
> * Snippet to display the property type
> ***
>@Activate
>protected void activate(final Map configProperties) throws 
> Exception {
>for (Entry entry : configProperties.entrySet()) {
>logger.info("Key : {}, Value {}", entry.getKey(), 
> entry.getValue().getClass().getCanonicalName());
>}
>}
> 
> 
> Paul Spencer



Karaf 4.3.6 Map in .json configuration?

2022-05-15 Thread Paul Spencer
Karaf 4.3.6

I would like to include a Map in a json configuration file.  Following the 
example in 
http://nanthrax.blogspot.com/2020/11/what-new-in-apache-karaf-430_9.html, I 
created the etc/foo.json. Unfortunately the returned type of the property 
"complex" was java.lang.String instead of the expected Map type.

Can a configuration property be a Map?
   If so, please include an example.


***
* etc/foo.json saved
***
{
  "complex":"{
"a":1,
"b":"two"
  }
}

***
* etc/foo.json rewritten by Karaf
***
{
  "complex":"{\"a\":1,\"b\":\"two\"}"
}

***
* Snippet to display the property type
***
@Activate
protected void activate(final Map configProperties) throws 
Exception {
for (Entry entry : configProperties.entrySet()) {
logger.info("Key : {}, Value {}", entry.getKey(), 
entry.getValue().getClass().getCanonicalName());
}
}


Paul Spencer

Configuration properties ending in .target cause NullPointerException when config:update

2022-05-13 Thread Paul Spencer
Karaf 4.3.6

I use a configuration property to configure injected objects, via @Reference.  
Updating a configuration PID containing an property ending in ".target" using 
config:... results in a NullPointerException


***
* etc/foo.cfg
***
mydb.target=(osgi.jndi.service.name=myDb)

***
* Component Reference
***
@Component configurationPid = ({ "foo" })
public class Foo implements FooService {
@Reference
private DataSource mydb = null;
...
}

***
* Steps to reproduce
***
1) Edit the configuration using "config:edit foo"
2) List properties using "config:properties-list"
3) Update the configuration using "config:update"

karaf@root()> config:edit foo
karaf@root()> config:property-list
   dataSource.target = 
karaf@root()> config:update
Error executing command: java.lang.NullPointerException
karaf@root()>   


   

***
* karaf.log
***
16:51:40.372 ERROR [Karaf ssh console user karaf] Exception caught while 
executing command
java.lang.NullPointerException: null
at 
org.apache.felix.utils.properties.ConfigurationHandler.writeValue(ConfigurationHandler.java:791)
 ~[?:?]
at 
org.apache.felix.utils.properties.ConfigurationHandler.write(ConfigurationHandler.java:229)
 ~[?:?]
at 
org.apache.felix.utils.properties.TypedProperties.convertToString(TypedProperties.java:345)
 ~[?:?]
at 
org.apache.felix.utils.properties.TypedProperties.put(TypedProperties.java:172) 
~[?:?]
at 
org.apache.felix.utils.properties.TypedProperties.put(TypedProperties.java:52) 
~[?:?]
at java.util.AbstractMap.putAll(AbstractMap.java:281) ~[?:1.8.0_172]
at 
org.apache.karaf.config.core.impl.ConfigRepositoryImpl.update(ConfigRepositoryImpl.java:73)
 ~[?:?]
at 
org.apache.karaf.config.command.UpdateCommand.doExecute(UpdateCommand.java:42) 
~[?:?]
at 
org.apache.karaf.config.command.ConfigCommandSupport.execute(ConfigCommandSupport.java:49)
 ~[?:?]
at 
org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
 ~[?:?]
at 
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
 ~[?:?]
at 
org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
 ~[?:?]
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599) 
~[?:?]
at 
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526) ~[?:?]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415) 
~[?:?]
at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416) ~[?:?]
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) ~[?:?]
at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) ~[?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
~[?:1.8.0_172]
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
~[?:1.8.0_172]
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
~[?:1.8.0_172]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_172]



Is this a bug?

Paul Spencer

  

Re: How do I load configuration within a shell command?

2022-05-13 Thread Paul Spencer
JB,
Thank you for the answer!

Below is the resulting use case.
***
* Command use case of getting companyName from customerInfo configuration PID 
***

import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;

@Service
@Command(scope = "customer", name = "info")
public class InfoCommand implements Action {
@Reference
private ConfigurationAdmin configAdmin;

@Override
public Object execute() {
Configuration[] configs = 
configAdmin.listConfigurations("(service.pid=customerInfo)");
if (configs != null && configs.length == 1) {
   String companyName = (String) 
configs[0].getProperties().get("companyName");
   System.out.println("Company name = " + companyName);
} 
}
}


Paul Spencer

> On May 13, 2022, at 3:23 PM, Jean-Baptiste Onofré  wrote:
> 
> I don't understand your question, sorry ;)
> 
> You want to display companyName ?
> 
> String companyName = null;
> Configuration[] configs =
> configAdmin.listConfiguration("(service.pid=customerInfo)");
> if (configs != null && configs.length == 1) {
>  companyName = configs[0].getProperties().get("companyName");
> }
> 
> Regards
> JB
> 
> On Fri, May 13, 2022 at 8:57 PM Paul Spencer  
> wrote:
>> 
>> JB,
>> The configuration PID files already exist and are used by other components.
>> 
>> Below are two use cases that will print the companyName property from the 
>> companyInfo configuration PID.  The component use case  works today.  Please 
>> complete the command use case.
>> 
>> ***
>> * /etc/companyInfo.cfg
>> ***
>> companyName = FooBar Inc.
>> 
>> ***
>> * Component use case of getting companyName from customerInfo configuration 
>> PID
>> ***
>> @Component configuationPid = {"customerInfo"})
>> public class Foo implements FooService {
>> 
>>  @Activate
>>  protected activate(final Map configProperties) {
>>String companyName = configProperties.get("companyName").toString();
>>log.info("Foo Service activated for " companyName);
>>  }
>> }
>> 
>> ***
>> * Command use case if getting companyName from customerInfo configuration PID
>> ***
>> @Service
>> @Command(scope = "customer", name = "info")
>> public class InfoCommand implements Action {
>> 
>>  @Override
>>  public Object execute(){
>> // How to populate company name for customerInfo configuration PID?
>> String companyName = ??
>> 
>> // Print company info
>> System.out.println("Company name = " + companyName);
>>  }
>> 
>> Paul Spencer
>> 
>> 
>>> On May 13, 2022, at 12:53 PM, Jean-Baptiste Onofré  
>>> wrote:
>>> 
>>> No, you don't need to have a cfg file.
>>> 
>>> You can create the config like this, if the pid doesn't exist, it will
>>> be created and populated with config:property-set.
>>> 
>>> Regards
>>> JB
>>> 
>>> On Fri, May 13, 2022 at 3:27 PM Paul Spencer  
>>> wrote:
>>>> 
>>>> JB,
>>>> The command needs to use values stored in pid.cfg files, like instance 
>>>> specific CustomerName, just like other components.
>>>> 
>>>> Paul Spencer
>>>> 
>>>>> On May 13, 2022, at 1:46 AM, Jean-Baptiste Onofré  
>>>>> wrote:
>>>>> 
>>>>> Hi Paul,
>>>>> 
>>>>> Not sure I understand exactly the request, but you can do:
>>>>> 
>>>>> config:edit pid
>>>>> config:property-list ...
>>>>> config:cancel | config:commit
>>>>> 
>>>>> Regards
>>>>> JB
>>>>> 
>>>>> On Thu, May 12, 2022 at 6:38 PM Paul Spencer  
>>>>> wrote:
>>>>>> 
>>>>>> Karaf 4.3.6
>>>>>> I am looking to load configuration into a shell command, but I do not 
>>>>>> see where to set the configuration PID nor do I see where the 
>>>>>> configuration is passed or injected into the Action class.
>>>>>> 
>>>>>> 
>>>>>> In a component, the configuration loaded by @Activate is defined by 
>>>>>> @Component and the configurationPid attribute. What are the equivalents 
>>>>>> for shell commands, class that implement 
>>>>>> org.apache.karaf.shell.api.action.Action?
>>>>>> 
>>>>>> Paul Spencer
>>>> 
>> 



Re: How do I load configuration within a shell command?

2022-05-13 Thread Paul Spencer
JB,
The configuration PID files already exist and are used by other components. 

Below are two use cases that will print the companyName property from the 
companyInfo configuration PID.  The component use case  works today.  Please 
complete the command use case.

***
* /etc/companyInfo.cfg
***
companyName = FooBar Inc.

***
* Component use case of getting companyName from customerInfo configuration PID 
***
@Component configuationPid = {"customerInfo"})
public class Foo implements FooService {

  @Activate
  protected activate(final Map configProperties) {
String companyName = configProperties.get("companyName").toString();
log.info("Foo Service activated for " companyName);
  }
}

***
* Command use case if getting companyName from customerInfo configuration PID 
***
@Service
@Command(scope = "customer", name = "info")
public class InfoCommand implements Action {

  @Override
  public Object execute(){
 // How to populate company name for customerInfo configuration PID? 
 String companyName = ?? 

 // Print company info
 System.out.println("Company name = " + companyName);
  }

Paul Spencer


> On May 13, 2022, at 12:53 PM, Jean-Baptiste Onofré  wrote:
> 
> No, you don't need to have a cfg file.
> 
> You can create the config like this, if the pid doesn't exist, it will
> be created and populated with config:property-set.
> 
> Regards
> JB
> 
> On Fri, May 13, 2022 at 3:27 PM Paul Spencer  
> wrote:
>> 
>> JB,
>> The command needs to use values stored in pid.cfg files, like instance 
>> specific CustomerName, just like other components.
>> 
>> Paul Spencer
>> 
>>> On May 13, 2022, at 1:46 AM, Jean-Baptiste Onofré  wrote:
>>> 
>>> Hi Paul,
>>> 
>>> Not sure I understand exactly the request, but you can do:
>>> 
>>> config:edit pid
>>> config:property-list ...
>>> config:cancel | config:commit
>>> 
>>> Regards
>>> JB
>>> 
>>> On Thu, May 12, 2022 at 6:38 PM Paul Spencer  
>>> wrote:
>>>> 
>>>> Karaf 4.3.6
>>>> I am looking to load configuration into a shell command, but I do not see 
>>>> where to set the configuration PID nor do I see where the configuration is 
>>>> passed or injected into the Action class.
>>>> 
>>>> 
>>>> In a component, the configuration loaded by @Activate is defined by 
>>>> @Component and the configurationPid attribute. What are the equivalents 
>>>> for shell commands, class that implement 
>>>> org.apache.karaf.shell.api.action.Action?
>>>> 
>>>> Paul Spencer
>> 



Re: How do I load configuration within a shell command?

2022-05-13 Thread Paul Spencer
João,
I would prefer not to add component bundles whose sole purpose is to pass 
configuration values from pid.cfg to a command via @Reference.

Paul Spencer

> On May 13, 2022, at 9:48 AM, João Assunção  
> wrote:
> 
> Why not have the components implement the required operations as a service, 
> or expose those values in some service operation, and then make the shell 
> command use that service ?
> 
> João Assunção
> 
> Email: joao.assun...@exploitsys.com
> Mobile: +351 916968984
> Phone: +351 211933149
> Web: www.exploitsys.com
> 
> 
> 
> 
> On Fri, May 13, 2022 at 2:27 PM Paul Spencer  
> wrote:
> JB,
> The command needs to use values stored in pid.cfg files, like instance 
> specific CustomerName, just like other components.
> 
> Paul Spencer
> 
> > On May 13, 2022, at 1:46 AM, Jean-Baptiste Onofré  wrote:
> > 
> > Hi Paul,
> > 
> > Not sure I understand exactly the request, but you can do:
> > 
> > config:edit pid
> > config:property-list ...
> > config:cancel | config:commit
> > 
> > Regards
> > JB
> > 
> > On Thu, May 12, 2022 at 6:38 PM Paul Spencer  
> > wrote:
> >> 
> >> Karaf 4.3.6
> >> I am looking to load configuration into a shell command, but I do not see 
> >> where to set the configuration PID nor do I see where the configuration is 
> >> passed or injected into the Action class.
> >> 
> >> 
> >> In a component, the configuration loaded by @Activate is defined by 
> >> @Component and the configurationPid attribute. What are the equivalents 
> >> for shell commands, class that implement 
> >> org.apache.karaf.shell.api.action.Action?
> >> 
> >> Paul Spencer
> 



Re: How do I load configuration within a shell command?

2022-05-13 Thread Paul Spencer
JB,
The command needs to use values stored in pid.cfg files, like instance specific 
CustomerName, just like other components.

Paul Spencer

> On May 13, 2022, at 1:46 AM, Jean-Baptiste Onofré  wrote:
> 
> Hi Paul,
> 
> Not sure I understand exactly the request, but you can do:
> 
> config:edit pid
> config:property-list ...
> config:cancel | config:commit
> 
> Regards
> JB
> 
> On Thu, May 12, 2022 at 6:38 PM Paul Spencer  
> wrote:
>> 
>> Karaf 4.3.6
>> I am looking to load configuration into a shell command, but I do not see 
>> where to set the configuration PID nor do I see where the configuration is 
>> passed or injected into the Action class.
>> 
>> 
>> In a component, the configuration loaded by @Activate is defined by 
>> @Component and the configurationPid attribute. What are the equivalents for 
>> shell commands, class that implement 
>> org.apache.karaf.shell.api.action.Action?
>> 
>> Paul Spencer



How do I load configuration within a shell command?

2022-05-12 Thread Paul Spencer
Karaf 4.3.6
I am looking to load configuration into a shell command, but I do not see where 
to set the configuration PID nor do I see where the configuration is passed or 
injected into the Action class.


In a component, the configuration loaded by @Activate is defined by @Component 
and the configurationPid attribute. What are the equivalents for shell 
commands, class that implement org.apache.karaf.shell.api.action.Action?

Paul Spencer

[jira] [Created] (KARAF-7430) Example of updating a JDBC datasource configuration using Karaf commands.

2022-04-30 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7430:
---

 Summary: Example of updating a JDBC datasource configuration using 
Karaf commands.
 Key: KARAF-7430
 URL: https://issues.apache.org/jira/browse/KARAF-7430
 Project: Karaf
  Issue Type: Documentation
  Components: karaf
Affects Versions: 4.3.6
Reporter: Paul Spencer


The example below demonstrates how to update the configuration of a JDBC 
datasource using Karaf commands. I was unable to find a concise procedure in 
the Karaf documentation and wanted to document a procedure for myself and 
others. 


1) Create the datasource "myDb", in this case with an incorrect username of 
"foo" using the "jdbc:ds-create ..." command
karaf@root()> jdbc:ds-create -dn hsqldb -url "dbc:hsqldb:mem:." -u foo -p bar 
myDb

2) List the datasource showing the new datasource has an "invalid 
authorization" status using the "jdbc:ds-list" command
karaf@root()> jdbc:ds-list
Name │ Service Id │ Product │ Version │ URL │ Status
──┼┼──┼──┼─┼─
178 │ │ │ │ │ Error invalid authorization specification - not found: foo


3) Identify the Pid for the datasource "myDb" using the "config:list 
'(service.factoryPid=org.ops4j.datasource)'" command
karaf@root()> config:list '(service.factoryPid=org.ops4j.datasource)'

Pid: org.ops4j.datasource.40c82a9b-e74a-4e8b-86a6-676ffed33b0e
FactoryPid: org.ops4j.datasource
BundleLocation: mvn:org.ops4j.pax.jdbc/pax-jdbc-config/1.5.0
Properties:
dataSourceName = myDb
osgi.jdbc.driver.name = hsqldb
password = bar
service.factoryPid = org.ops4j.datasource
service.pid = org.ops4j.datasource.40c82a9b-e74a-4e8b-86a6-676ffed33b0e
url = dbc:hsqldb:mem:.
user = foo

4) Open and list properties for the datasource "myDb" using the "config:edit 
org.ops4j.datasource." command, where  is from above for the 
dataSourceName myDb
karaf@root()> config:edit 
org.ops4j.datasource.40c82a9b-e74a-4e8b-86a6-676ffed33b0e
karaf@root()> config:property-list 
dataSourceName = myDb
osgi.jdbc.driver.name = hsqldb
password = bar
url = dbc:hsqldb:mem:.
user = foo
5) Make the configuration changes, in this case setting the user to "sa" and 
removing the password, using the config:property-... commands
karaf@root()> config:property-set user sa
karaf@root()> config:property-delete password
karaf@root()> config:property-list
dataSourceName = myDbAsFoo
osgi.jdbc.driver.name = hsqldb
url = dbc:hsqldb:mem:.
user = sa

6) Save the the configuration changes using the "config:update" command
karaf@root()> config:update

7) List the datasources, showing a correctly configured "myDb"
karaf@root()> jdbc:ds-list
Name │ Service Id │ Product │ Version │ URL │ Status
──┼┼──┼──┼─┼───
myDb │ 179 │ HSQL Database Engine │ 2.5.1 │ jdbc:hsqldb:dbc:hsqldb:mem:. │ OK
karaf@root()>



--
This message was sent by Atlassian Jira
(v8.20.7#820007)


Re: jdbc:ds-create command and "to create the datasource definition file"?

2022-04-30 Thread Paul Spencer
JB,
The feature pax-jdbc-config is installed and it is referenced in 
"BundleLocation: mvn:org.ops4j.pax.jdbc/pax-jdbc-config/1.5.0"

karaf@root()> feature:list --installed | grep -i pax-jdbc | sort


   
pax-jdbc│ 1.5.0│ x│ Started │ 
org.ops4j.pax.jdbc-1.5.0 │ Provides JDBC Service support
pax-jdbc-config │ 1.5.0│ x│ Started │ 
org.ops4j.pax.jdbc-1.5.0 │ Provides JDBC Config support
pax-jdbc-hsqldb │ 1.5.0│ x│ Started │ 
org.ops4j.pax.jdbc-1.5.0 │ Provides JDBC HSQLDB DataSourceFactory
pax-jdbc-pool-dbcp2 │ 1.5.0│ x│ Started │ 
org.ops4j.pax.jdbc-1.5.0 │ Provides JDBC Pooling DataSourceFactory
pax-jdbc-spec   │ 1.5.0│  │ Started │ 
org.ops4j.pax.jdbc-1.5.0 │ Provides OSGi JDBC Service spec
karaf@root()>   


     

Paul Spencer


> On Apr 30, 2022, at 12:24 AM, Jean-Baptiste Onofré  wrote:
> 
> Hi,
> 
> The documentation is correct if we have pax-jdbc-config feature
> installed. A factory config should be created in etc for the
> datasource.
> 
> Let me take a look but it's fine afair.
> 
> Regards
> JB
> 
> On Fri, Apr 29, 2022 at 5:57 PM Paul Spencer  
> wrote:
>> 
>> Karaf 4.3.6
>> 
>> The documentation, 
>> https://karaf.apache.org/manual/latest/#_datasources_jdbc,  for the "name" 
>> argument in the command "jdbc:ds-create" states "to create the datasource 
>> definition file (deploy/datasource-[name].xml)."  I do not see a file 
>> created in the deploy directory, but I do see a file in the cache directory 
>> for the "Apache Felix Configuration Admin Service" bundle with a generated 
>> name.
>> 
>> 1) Is this phase inaccurate and should be removed from the documentation?
>> 
>> 2) If the phrase is correct, how does one create the file in the deploy 
>> directory?
>> 
>> ***
>> * Example of creating JDBC Datasource and looking of the created data 
>> definition file in the deploy directory
>> **
>> karaf@root()> jdbc:ds-create -dn hsqldb -url "dbc:hsqldb:mem:." -u sa myDb
>> karaf@root()> ds-list
>> Name  │ Service Id │ Product  │ Version  
>> │ URL │ Status
>> ──┼┼──┼──┼─┼───
>> myDb  │ 177│ HSQL Database Engine │ 2.5.1
>> │ jdbc:hsqldb:dbc:hsqldb:mem:.│ OK
>> karaf@root()> config:list '(service.factoryPid=org.ops4j.datasource)'
>> 
>> Pid:org.ops4j.datasource.ad014501-2db1-4455-abb9-ced214fee015
>> FactoryPid: org.ops4j.datasource
>> BundleLocation: mvn:org.ops4j.pax.jdbc/pax-jdbc-config/1.5.0
>> Properties:
>>   dataSourceName = myDb
>>   osgi.jdbc.driver.name = hsqldb
>>   service.factoryPid = org.ops4j.datasource
>>   service.pid = org.ops4j.datasource.ad014501-2db1-4455-abb9-ced214fee015
>>   url = dbc:hsqldb:mem:.
>>   user = sa
>> karaf@root()> shell:ls deploy
>> .  .. README
>> karaf@root()>
>> karaf@root()> list -t 0 12
>> START LEVEL 100 , List Threshold: 0
>> ID │ State  │ Lvl │ Version │ Name
>> ───┼┼─┼─┼12
>>  │ Active │  10 │ 1.9.22  │ Apache Felix Configuration Admin Service
>> karaf@root()>
>> karaf@root()> shell:ls -l  
>> data/cache/bundle12/data/config/org/ops4j/datasource/ad014501-2db1-4455-abb9-ced214fee015.config
>> -rw-r--r--   1 paul staff 252 Apr 29 11:30 
>> data/cache/bundle12/data/config/org/ops4j/datasource/ad014501-2db1-4455-abb9-ced214fee015.config
>> karaf@root()>
>> karaf@root()> shell:cat  
>> data/cache/bundle12/data/config/org/ops4j/datasource/ad014501-2db1-4455-abb9-ced214fee015.config
>> :org.apache.felix.configadmin.revision:=L"1"
>> dataSourceName="myDb"
>> osgi.jdbc.driver.name="hsqldb"
>> service.factoryPid="org.ops4j.datasource"
>> service.pid="org.ops4j.datasource.ad014501-2db1-4455-abb9-ced214fee015"
>> url="dbc:hsqldb:mem:."
>> user="sa"
>> karaf@root()>karaf@root()>
>> 
>> 
>> Paul Spencer



Example of updating a JDBC datasource configuration using Karaf commands.

2022-04-29 Thread Paul Spencer
Karaf 4.3.6

The example below demonstrates how to update the configuration of a JDBC 
datasource using Karaf commands. I was unable to find a concise procedure in 
the Karaf documentation and wanted to document a procedure for myself and 
others.  


1) Create the datasource "myDb", in this case with an incorrect username of 
"foo" using the "jdbc:ds-create ..." command
karaf@root()> jdbc:ds-create -dn hsqldb -url "dbc:hsqldb:mem:." -u foo -p bar 
myDb

2) List the datasource showing the new datasource has an "invalid 
authorization" status using the "jdbc:ds-list" command
karaf@root()> jdbc:ds-list
Name  │ Service Id │ Product  │ Version 
 │ URL │ Status
──┼┼──┼──┼─┼─
178   ││  │ 
 │ │ Error invalid 
authorization specification - not found: foo


3) Identify the Pid for the datasource "myDb" using the "config:list 
'(service.factoryPid=org.ops4j.datasource)'" command
karaf@root()> config:list '(service.factoryPid=org.ops4j.datasource)'

Pid:org.ops4j.datasource.40c82a9b-e74a-4e8b-86a6-676ffed33b0e
FactoryPid: org.ops4j.datasource
BundleLocation: mvn:org.ops4j.pax.jdbc/pax-jdbc-config/1.5.0
Properties:
   dataSourceName = myDb
   osgi.jdbc.driver.name = hsqldb
   password = bar
   service.factoryPid = org.ops4j.datasource
   service.pid = org.ops4j.datasource.40c82a9b-e74a-4e8b-86a6-676ffed33b0e
   url = dbc:hsqldb:mem:.
   user = foo

4) Open and list properties for the datasource "myDb" using the "config:edit 
org.ops4j.datasource." command, where  is from above for the 
dataSourceName myDb
karaf@root()> config:edit 
org.ops4j.datasource.40c82a9b-e74a-4e8b-86a6-676ffed33b0e
karaf@root()> config:property-list 
   dataSourceName = myDb
   osgi.jdbc.driver.name = hsqldb
   password = bar
   url = dbc:hsqldb:mem:.
   user = foo
5) Make the configuration changes, in this case setting the user to "sa" and 
removing the password, using the config:property-... commands
karaf@root()> config:property-set user sa
karaf@root()> config:property-delete password
karaf@root()> config:property-list
   dataSourceName = myDbAsFoo
   osgi.jdbc.driver.name = hsqldb
   url = dbc:hsqldb:mem:.
   user = sa

6) Save the the configuration changes using the "config:update" command
karaf@root()> config:update

7) List the datasources, showing a correctly configured "myDb"
karaf@root()> jdbc:ds-list
Name  │ Service Id │ Product  │ Version 
 │ URL │ Status
──┼┼──┼──┼─┼───
myDb  │ 179│ HSQL Database Engine │ 2.5.1   
 │ jdbc:hsqldb:dbc:hsqldb:mem:.│ OK
karaf@root()>   


   

jdbc:ds-create command and "to create the datasource definition file"?

2022-04-29 Thread Paul Spencer
Karaf 4.3.6

The documentation, https://karaf.apache.org/manual/latest/#_datasources_jdbc,  
for the "name" argument in the command "jdbc:ds-create" states "to create the 
datasource definition file (deploy/datasource-[name].xml)."  I do not see a 
file created in the deploy directory, but I do see a file in the cache 
directory for the "Apache Felix Configuration Admin Service" bundle with a 
generated name.
  
1) Is this phase inaccurate and should be removed from the documentation?

2) If the phrase is correct, how does one create the file in the deploy 
directory?

***
* Example of creating JDBC Datasource and looking of the created data 
definition file in the deploy directory
**
karaf@root()> jdbc:ds-create -dn hsqldb -url "dbc:hsqldb:mem:." -u sa myDb
karaf@root()> ds-list
Name  │ Service Id │ Product  │ Version 
 │ URL │ Status
──┼┼──┼──┼─┼───
myDb  │ 177│ HSQL Database Engine │ 2.5.1   
 │ jdbc:hsqldb:dbc:hsqldb:mem:.│ OK
karaf@root()> config:list '(service.factoryPid=org.ops4j.datasource)'

Pid:org.ops4j.datasource.ad014501-2db1-4455-abb9-ced214fee015
FactoryPid: org.ops4j.datasource
BundleLocation: mvn:org.ops4j.pax.jdbc/pax-jdbc-config/1.5.0
Properties:
   dataSourceName = myDb
   osgi.jdbc.driver.name = hsqldb
   service.factoryPid = org.ops4j.datasource
   service.pid = org.ops4j.datasource.ad014501-2db1-4455-abb9-ced214fee015
   url = dbc:hsqldb:mem:.
   user = sa
karaf@root()> shell:ls deploy
.  .. README
karaf@root()> 
karaf@root()> list -t 0 12  


 
START LEVEL 100 , List Threshold: 0
ID │ State  │ Lvl │ Version │ Name
───┼┼─┼─┼12
 │ Active │  10 │ 1.9.22  │ Apache Felix Configuration Admin Service
karaf@root()> 
karaf@root()> shell:ls -l  
data/cache/bundle12/data/config/org/ops4j/datasource/ad014501-2db1-4455-abb9-ced214fee015.config


-rw-r--r--   1 paul staff 252 Apr 29 11:30 
data/cache/bundle12/data/config/org/ops4j/datasource/ad014501-2db1-4455-abb9-ced214fee015.config
karaf@root()> 
karaf@root()> shell:cat  
data/cache/bundle12/data/config/org/ops4j/datasource/ad014501-2db1-4455-abb9-ced214fee015.config


:org.apache.felix.configadmin.revision:=L"1"
dataSourceName="myDb"
osgi.jdbc.driver.name="hsqldb"
service.factoryPid="org.ops4j.datasource"
service.pid="org.ops4j.datasource.ad014501-2db1-4455-abb9-ced214fee015"
url="dbc:hsqldb:mem:."
user="sa"
karaf@root()>karaf@root()>  
        




Paul Spencer 

RE: Static OpenSSL 3 library with FIPS

2022-03-25 Thread Paul Spencer

Thanks for the info.

You mean both libssl.a and libcrypto.a static, and then dynamically loaded 
fips.so, correct? Unfortunately that gets away from the 
single-binary-executable model and so is a somewhat major change.


-Original Message-
From: Matt Caswell 
mailto:matt%20caswell%20%3cm...@openssl.org%3e>>
To: openssl-users@openssl.org<mailto:openssl-users@openssl.org>
Subject: [EXTERNAL] Re: Static OpenSSL 3 library with FIPS
Date: Fri, 25 Mar 2022 20:22:02 +



On 25/03/2022 18:33, Paul Spencer wrote:

Q: Is it possible to have a static (.a) OpenSSL 3 library with FIPS support?


This was possible with OpenSSL 1.0.2 and the FIPS 2.0.x module (and

special linking in the Makefile). However, with SSL3, if I go


Configure no-module enable-fips


then it silently disables FIPS. Is there any way to do this?



You can have a static libcrypto (.a) with a dynamically loaded FIPS

module (i.e. using fips.so).


Configure no-shared enable-fips


You cannot have a statically linked FIPS module. It was a day 1 design

decision that we would no longer support this.


Matt


Static OpenSSL 3 library with FIPS

2022-03-25 Thread Paul Spencer
Q: Is it possible to have a static (.a) OpenSSL 3 library with FIPS support?

This was possible with OpenSSL 1.0.2 and the FIPS 2.0.x module (and special 
linking in the Makefile). However, with SSL3, if I go

Configure no-module enable-fips

then it silently disables FIPS. Is there any way to do this?



Re: Updated mitigation for Log4JShell in Karaf 4.2.x and 4.3.x since setting log4j2.formatMsgNoLookups is a insufficient mitigation measure

2021-12-23 Thread Paul Spencer
JB,
Karaf upgrades will be done, just not during the holiday breaks when compliance 
resources are scarce.  Mitigating the issue by setting 
log4j2.formatMsgNoLookups and removing the JndiLoookup.class will allow the 
current environment to run while upgrades are be run through each customer's 
compliance and deployment processes.

Thank you and the Karaf team for rapidly releasing updated versions of Karaf to 
address the CVE.  The updated Karaf will be will incorporated into our products 
and pushed through the release and deployment process as quickly as possible.

Paul Spencer

> On Dec 23, 2021, at 12:42 PM, Jean-Baptiste Onofre  wrote:
> 
> It would mitigate only the JNDI part, not the other CVE (about the lookup).
> 
> Anyway, it’s a good workaround.
> 
> I don’t understand why you don’t want to upgrade to a new version. It’s 
> exactly the purpose of the new releases to address CVE.
> Else, why we would do new releases if you are stuck with old versions. Log4j 
> did couple of new releases to address the CVE issue, so it’s worth to update.
> 
> Regards
> JB
> 
>> Le 23 déc. 2021 à 18:37, Paul Spencer  a écrit :
>> 
>> JB,
>> Aymen Furter suggested the following:
>> 
>> $ cd karaf-directory
>> $ zip -q -d $(find . | grep pax-logging-log4j2 | grep jar) 
>> org/apache/logging/log4j/core/lookup/JndiLookup.class
>> $ zip -q -d $(grep -rlnw . -e "pax-logging-log4j2" | grep 
>> "data/cache/bundle" | grep jar) 
>> org/apache/logging/log4j/core/lookup/JndiLookup.class
>> 
>> 
>> This looks like a reasonable short term workaround that is relatively easy 
>> to implement. Relative to the Karaf and its services, do you see any 
>> potential problems with the workaround?
>> 
>> 
>> Paul Spencer
>> 
>>> On Dec 23, 2021, at 12:17 PM, JB Onofré  wrote:
>>> 
>>> Then create your own custom distro upgrading pax logging. 
>>> 
>>>> Le 23 déc. 2021 à 17:23, Paul Spencer  a écrit 
>>>> :
>>>> 
>>>> JB,
>>>> As stated earlier, upgrading Karaf is not an option in the short term.
>>>> 
>>>> Paul Spencer
>>>> 
>>>> 
>>>>> On Dec 23, 2021, at 11:21 AM, JB Onofré  wrote:
>>>>> 
>>>>> Upgrade to Karaf 4.2.13. 
>>>>> 
>>>>>>> Le 23 déc. 2021 à 17:02, Paul Spencer  a 
>>>>>>> écrit :
>>>>>> 
>>>>>> In light of the updated mitigation for the Log4JShell published by 
>>>>>> Log4J[1], specifically "zip -q -d log4j-core-*.jar 
>>>>>> org/apache/logging/log4j/core/lookup/JndiLookup.class", the insufficient 
>>>>>> mitigation measure of setting system property log4j2.formatMsgNoLookups, 
>>>>>> and the presents of JndiLookup.class in the pax-logging-log4j2 jar. What 
>>>>>> is the suggested mitigation for Karaf 4.2.x and Karaf 4.3.x when 
>>>>>> upgrading Karaf is not an option in the short term?
>>>>>> 
>>>>>> ***
>>>>>> * Example from Karaf 4.2.9
>>>>>> 
>>>>>> [user@localhost karaf]$ zip -sf 
>>>>>> ./system/org/ops4j/pax/logging/pax-logging-log4j2/1.11.6/pax-logging-log4j2-1.11.6.jar
>>>>>>  | grep JndiLookup
>>>>>> org/apache/logging/log4j/core/lookup/JndiLookup.class
>>>>>> [user@localhost karaf]$ 
>>>>>> 
>>>>>> Paul Spencer
>>>>>> 
>>>>>> [1] https://logging.apache.org/log4j/2.x/security.html#CVE-2021-44228
>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 



Re: Updated mitigation for Log4JShell in Karaf 4.2.x and 4.3.x since setting log4j2.formatMsgNoLookups is a insufficient mitigation measure

2021-12-23 Thread Paul Spencer
JB,
Aymen Furter suggested the following:

$ cd karaf-directory
$ zip -q -d $(find . | grep pax-logging-log4j2 | grep jar) 
org/apache/logging/log4j/core/lookup/JndiLookup.class
$ zip -q -d $(grep -rlnw . -e "pax-logging-log4j2" | grep "data/cache/bundle" | 
grep jar) org/apache/logging/log4j/core/lookup/JndiLookup.class


This looks like a reasonable short term workaround that is relatively easy to 
implement. Relative to the Karaf and its services, do you see any potential 
problems with the workaround?


Paul Spencer

> On Dec 23, 2021, at 12:17 PM, JB Onofré  wrote:
> 
> Then create your own custom distro upgrading pax logging. 
> 
>> Le 23 déc. 2021 à 17:23, Paul Spencer  a écrit :
>> 
>> JB,
>> As stated earlier, upgrading Karaf is not an option in the short term.
>> 
>> Paul Spencer
>> 
>> 
>>> On Dec 23, 2021, at 11:21 AM, JB Onofré  wrote:
>>> 
>>> Upgrade to Karaf 4.2.13. 
>>> 
>>>>> Le 23 déc. 2021 à 17:02, Paul Spencer  a 
>>>>> écrit :
>>>> 
>>>> In light of the updated mitigation for the Log4JShell published by 
>>>> Log4J[1], specifically "zip -q -d log4j-core-*.jar 
>>>> org/apache/logging/log4j/core/lookup/JndiLookup.class", the insufficient 
>>>> mitigation measure of setting system property log4j2.formatMsgNoLookups, 
>>>> and the presents of JndiLookup.class in the pax-logging-log4j2 jar. What 
>>>> is the suggested mitigation for Karaf 4.2.x and Karaf 4.3.x when upgrading 
>>>> Karaf is not an option in the short term?
>>>> 
>>>> ***
>>>> * Example from Karaf 4.2.9
>>>> 
>>>> [user@localhost karaf]$ zip -sf 
>>>> ./system/org/ops4j/pax/logging/pax-logging-log4j2/1.11.6/pax-logging-log4j2-1.11.6.jar
>>>>  | grep JndiLookup
>>>> org/apache/logging/log4j/core/lookup/JndiLookup.class
>>>> [user@localhost karaf]$ 
>>>> 
>>>> Paul Spencer
>>>> 
>>>> [1] https://logging.apache.org/log4j/2.x/security.html#CVE-2021-44228
>>>> 
>>>> 
>>> 
>> 
> 



Re: Updated mitigation for Log4JShell in Karaf 4.2.x and 4.3.x since setting log4j2.formatMsgNoLookups is a insufficient mitigation measure

2021-12-23 Thread Paul Spencer
JB,
As stated earlier, upgrading Karaf is not an option in the short term.

Paul Spencer


> On Dec 23, 2021, at 11:21 AM, JB Onofré  wrote:
> 
> Upgrade to Karaf 4.2.13. 
> 
>> Le 23 déc. 2021 à 17:02, Paul Spencer  a écrit :
>> 
>> In light of the updated mitigation for the Log4JShell published by 
>> Log4J[1], specifically "zip -q -d log4j-core-*.jar 
>> org/apache/logging/log4j/core/lookup/JndiLookup.class", the insufficient 
>> mitigation measure of setting system property log4j2.formatMsgNoLookups, and 
>> the presents of JndiLookup.class in the pax-logging-log4j2 jar. What is the 
>> suggested mitigation for Karaf 4.2.x and Karaf 4.3.x when upgrading Karaf is 
>> not an option in the short term?
>> 
>> ***
>> * Example from Karaf 4.2.9
>> 
>> [user@localhost karaf]$ zip -sf 
>> ./system/org/ops4j/pax/logging/pax-logging-log4j2/1.11.6/pax-logging-log4j2-1.11.6.jar
>>  | grep JndiLookup
>> org/apache/logging/log4j/core/lookup/JndiLookup.class
>> [user@localhost karaf]$ 
>> 
>> Paul Spencer
>> 
>> [1] https://logging.apache.org/log4j/2.x/security.html#CVE-2021-44228
>> 
>> 
> 



Updated mitigation for Log4JShell in Karaf 4.2.x and 4.3.x since setting log4j2.formatMsgNoLookups is a insufficient mitigation measure

2021-12-23 Thread Paul Spencer
In light of the updated mitigation for the Log4JShell published by Log4J[1], 
specifically "zip -q -d log4j-core-*.jar 
org/apache/logging/log4j/core/lookup/JndiLookup.class", the insufficient 
mitigation measure of setting system property log4j2.formatMsgNoLookups, and 
the presents of JndiLookup.class in the pax-logging-log4j2 jar. What is the 
suggested mitigation for Karaf 4.2.x and Karaf 4.3.x when upgrading Karaf is 
not an option in the short term?

***
* Example from Karaf 4.2.9

[user@localhost karaf]$ zip -sf 
./system/org/ops4j/pax/logging/pax-logging-log4j2/1.11.6/pax-logging-log4j2-1.11.6.jar
 | grep JndiLookup
  org/apache/logging/log4j/core/lookup/JndiLookup.class
[user@localhost karaf]$ 

Paul Spencer

[1] https://logging.apache.org/log4j/2.x/security.html#CVE-2021-44228




Karaf 3.0.x "Apache Log4j Remote Code Execution Vulnerability" mitigation?

2021-12-12 Thread Paul Spencer
For users of Karaf 3.0.x that uses Pax Logging version 1.8.x, what is the 
recommended mitigation for "Apache Log4j Remote Code Execution Vulnerability", 
CVE-2021-44228?

Paul Spencer



Karaf 4.2.x "Apache Log4j Remote Code Execution Vulnerability" mitigation?

2021-12-12 Thread Paul Spencer
For users of Karaf 4.2.x, what is the recommended mitigation for "Apache Log4j 
Remote Code Execution Vulnerability", CVE-2021-44228?

Paul Spencer



Karaf 4.3.x "Apache Log4j Remote Code Execution Vulnerability" mitigation?

2021-12-12 Thread Paul Spencer
For users of Karaf 4.3.x, what is the recommended mitigation for "Apache Log4j 
Remote Code Execution Vulnerability", CVE-2021-44228?

Paul Spencer



Supported Java Version for Karaf 4.3.x?

2021-09-14 Thread Paul Spencer
Per the Downloads page, http://karaf.apache.org/download.html, Karaf 4.3.x is 
supported under Java 11+, but the required version in the root pom.xml, 
https://github.com/apache/karaf/blob/main/pom.xml, the required Java version is 
1.8.  Additionally I have been developing bundles for Karaf 4.3.x using Java 
1.8.

Is Karaf 4.3.x supported under Java 1.8?
If not, why is the required Java version in pom.xml 1.8?

Paul Spencer  

4.3.x JSON based configuration example for an OSGi bundle?

2021-09-09 Thread Paul Spencer
I am looking for a example of getting configuration using Karaf 4.3.x from JSON 
configuration file.  Below is an example, based on Karaf 4.2.x 
karaf-config-example-scr, of getting the value for “key1” from the 
configuration file “etc/foo.conf” that I am looking to Karaf 4.3 and JSON.  

Ideally the example will include array and map examples for JSON file similar 
to the following.
{
   “Array”: [ “a”,’b”,”c”],
“Map”: {
 “key1”: “value 1”,
 “key2”: “value 2”
}
}

***
* Karaf 4.2 Bundle Class 
***
@Component(configuationPid = “foo”)
…
  @Activate
  public activate( ComponentContext context) {
String keyValue = context.getProperties().get(“key1”);
  }

***
*  etc/foo.cfg
***
key1 = value 1
key2 = value 2

Paul Spencer



Karaf online forums are not found

2021-08-05 Thread Paul Spencer
The online forums links on the Karaf Community page, 
http://karaf.apache.org/community.html, are no longer working.  
  User Forum: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
  Dev Forum: http://karaf.922171.n3.nabble.com/Karaf-Dev-f930721.html

Have the forums moved?

Paul Spencer

[jira] [Commented] (KARAF-7113) Scheduler should ignores runnable without scheduler service properties

2021-04-19 Thread Paul Spencer (Jira)


[ 
https://issues.apache.org/jira/browse/KARAF-7113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17324722#comment-17324722
 ] 

Paul Spencer commented on KARAF-7113:
-

The bug is in the calculation of the SetviceIdentifier when the 
configurationPid of the Component is an Array and the scheduler.name property 
is not defined.  When the configurationPis is a String, the Scheduler correctly 
determines if the component should.be ignored. 

> Scheduler should ignores runnable without scheduler service properties
> --
>
> Key: KARAF-7113
> URL: https://issues.apache.org/jira/browse/KARAF-7113
> Project: Karaf
>  Issue Type: Bug
>  Components: karaf
>Reporter: Jean-Baptiste Onofré
>Assignee: Jean-Baptiste Onofré
>Priority: Major
>
> Scheduler throws NPE when it detects a Runnable without the service 
> properties:
> {code:java}
> 16:44:46.313 ERROR [pipe-start 195] Bundle org.apache.karaf.scheduler.core 
> [182] EventDispatcher: Error during dispatch. (java.lang.ClassCastException: 
> java.util.ArrayList cannot be cast to java.lang.String)
> java.lang.ClassCastException: java.util.ArrayList cannot be cast to 
> java.lang.String
>   at 
> org.apache.karaf.scheduler.core.WhiteboardHandler.getServiceIdentifier(WhiteboardHandler.java:87)
>  ~[?:?]
>   at 
> org.apache.karaf.scheduler.core.WhiteboardHandler.register(WhiteboardHandler.java:101)
>  ~[?:?]
>   at 
> org.apache.karaf.scheduler.core.WhiteboardHandler.access$100(WhiteboardHandler.java:36)
>  ~[?:?]
>   at 
> org.apache.karaf.scheduler.core.WhiteboardHandler$1.addingService(WhiteboardHandler.java:65)
>  ~[?:?]
>   at 
> org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)
>  ~[osgi.core-6.0.0.jar:?]
>   at 
> org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870)
>  ~[osgi.core-6.0.0.jar:?]
>   at 
> org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) 
> ~[osgi.core-6.0.0.jar:?]
>   at 
> org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) 
> ~[osgi.core-6.0.0.jar:?]
>   at 
> org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:901)
>  ~[osgi.core-6.0.0.jar:?]
>  {code}
> {code:java}
> @Component {configurationPid = {"foo","bar"})
> public class Foo implements Runnable {
> ...
> } {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Created] (KARAF-7108) Scheduler documentation fails to mention the option of Whitboard-Service configurtion a job using OSGi configuration.

2021-04-18 Thread Paul Spencer (Jira)
Paul Spencer created KARAF-7108:
---

 Summary: Scheduler documentation fails to mention the option of 
Whitboard-Service configurtion a  job using OSGi configuration.
 Key: KARAF-7108
 URL: https://issues.apache.org/jira/browse/KARAF-7108
 Project: Karaf
  Issue Type: Documentation
  Components: karaf
 Environment: Karaf 4.2.11
Reporter: Paul Spencer


The Scheduler documentation fails to mention the option of using 
Whitboard-Service configuration for job using OSGi configuration.

Below are the OSGi Configuration properties used by the Scheduler 
Whiteboard-Service to configure components implementing Runnable or 
org.apache.karaf.scheduler.Job.

# The period for the job is expressed in seconds. Ignored when 
scheduler.expression is defined.
#scheduler.period=

# The configuration property to definesthe number of iterations for a job. 
# default to "-1", which means the run forever. Ignored when 
scheduler.expression is defined.
#scheduler.times= -1

# Should a periodic job startup immediate? If "false", the job is started the 
first time after the period has expired. Ignored when scheduler.expression is 
defined.
#scheduler.immediate=false

# The cron expression for a job. Required if scheduler.period is not defined.
#scheduler.expression=

# May job can be run concurrently? Default is "true"
#scheduler.concurrent = true

# Job name, defaults to the configurationPid name. When the configuration is 
shared by multiple components, care but be 
# taken so multiple jobs do not end up with the same job name. A job name is 
calculated from scheduler.name and the service pid.
#scheduler.name=



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


configurationPid array may cause the Scheduler to throw a ClassCastException

2021-04-18 Thread Paul Spencer
Karaf 4.2.11 with Scheduler feature installed


I am seeing the following error for Components implementing Runnable without 
Scheduler configuration and multiple ConfigurationPID. 

16:44:46.313 ERROR [pipe-start 195] Bundle org.apache.karaf.scheduler.core 
[182] EventDispatcher: Error during dispatch. (java.lang.ClassCastException: 
java.util.ArrayList cannot be cast to java.lang.String)
java.lang.ClassCastException: java.util.ArrayList cannot be cast to 
java.lang.String
at 
org.apache.karaf.scheduler.core.WhiteboardHandler.getServiceIdentifier(WhiteboardHandler.java:87)
 ~[?:?]
at 
org.apache.karaf.scheduler.core.WhiteboardHandler.register(WhiteboardHandler.java:101)
 ~[?:?]
at 
org.apache.karaf.scheduler.core.WhiteboardHandler.access$100(WhiteboardHandler.java:36)
 ~[?:?]
at 
org.apache.karaf.scheduler.core.WhiteboardHandler$1.addingService(WhiteboardHandler.java:65)
 ~[?:?]
at 
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)
 ~[osgi.core-6.0.0.jar:?]
at 
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:870)
 ~[osgi.core-6.0.0.jar:?]
at 
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) 
~[osgi.core-6.0.0.jar:?]
at 
org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) 
~[osgi.core-6.0.0.jar:?]
at 
org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:901)
 ~[osgi.core-6.0.0.jar:?]

@Component {configurationPid = {"foo","bar"})
public class Foo implements Runnable {
...
}

It appears the Scheduler assumes all runnable components may have valid 
Scheduler configuration in the @Component annotation or OSGi configuration 
files. In my case, the Scheduler is failing to set a Service Identifier when 
there is no scheduler.name configuration and the component's configurationPid 
is an array.

Is this a bug?



Paul Spencer



[jira] [Commented] (KARAF-7102) maven:repository-remove fails with NPE if ~/.m2/settings does not exist

2021-04-12 Thread Paul Spencer (Jira)


[ 
https://issues.apache.org/jira/browse/KARAF-7102?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17319716#comment-17319716
 ] 

Paul Spencer commented on KARAF-7102:
-

[~jbonofre]  I found the duplicated issued.  It is KARAF-7101.

> maven:repository-remove fails with NPE if ~/.m2/settings does not exist
> ---
>
> Key: KARAF-7102
> URL: https://issues.apache.org/jira/browse/KARAF-7102
> Project: Karaf
>  Issue Type: Bug
>  Components: karaf
>Affects Versions: 4.2.11
> Environment: Karaf 4.2.11
> Java  1.8.0_282
> OS    Redhat 8.2
>Reporter: Paul Spencer
>Priority: Minor
>
> Starting with a virgin Karaf 4.2.11 installation, I added my own repository 
> and I attempted to remove the default remote repositories. 
>  Removing the repository id central fails with a NPE.  Why?
> Per [link 
> Freeman|http://karaf.922171.n3.nabble.com/Karaf-4-2-11-maven-repository-remove-id-central-fails-with-NPE-Why-tp4059832p4059834.html]:
> {quote}This is caused by that you don't have ~/.m2/settings.xml, so 
> mavenSettings is null. We need to add a NPE guard here.
> {quote}
> karaf@root()> maven:repository-add -id myrepo 
> [http://myrepo.example.com|http://myrepo.example.com/]
>  karaf@root()> maven:repository-remove -id central 
>  Are you sure to remove repository with ID "central" for URL 
> [https://repo1.maven.org/maven2/]? (y/N) y 
>  null 
>  karaf@root()> 
> From karaf.log
> 14:16:28.422 WARN [pipe-maven:repository-remove -id central] The Parser of 
> class 
> org.apache.karaf.shell.impl.console.ConsoleSessionImpl$$Lambda$411/734988569 
> does not support the CompletingParsedLine interface. Completion with escaped 
> or quoted words won't work correctly. 
>  14:16:30.081 ERROR [pipe-maven:repository-remove -id central] null 
>  java.lang.NullPointerException: null 
>         at 
> org.apache.karaf.maven.command.RepositoryRemoveCommand.edit(RepositoryRemoveCommand.java:73)
>  ~[!/:?] 
>        at 
> org.apache.karaf.maven.command.RepositoryEditCommandSupport.doAction(RepositoryEditCommandSupport.java:65)
>  ~[!/:?] 
>         at 
> org.apache.karaf.maven.command.MavenConfigurationSupport.execute(MavenConfigurationSupport.java:161)
>  [!/:?] 
>         at 
> org.apache.karaf.shell.impl.action.command.ActionCommand.execute(ActionCommand.java:84)
>  [!/:4.2.11] 
>         at 
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:68)
>  [!/:4.2.11] 
>         at 
> org.apache.karaf.shell.impl.console.osgi.secured.SecuredCommand.execute(SecuredCommand.java:86)
>  [!/:4.2.11] 
>         at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599) 
> [!/:4.2.11] 
>         at 
> org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526) 
> [!/:4.2.11] 
>        at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415) 
> [!/:4.2.11] 
>         at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416) 
> [!/:4.2.11] 
>         at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) [!/:4.2.11] 
>         at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) [!/:4.2.11] 
>         at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
> [?:1.8.0_282] 
>         at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>  [?:1.8.0_282] 
>         at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>  [?:1.8.0_282] 
>        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282] 
> Paul Spencer



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


  1   2   3   4   5   6   7   8   9   10   >