You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Steinar Bang <sb...@dod.no> on 2021/03/22 17:55:48 UTC

Should 4.2.11 applications run on 4.3.0?

How run-time compatible are karaf 4.2.11 and 4.3.0 supposed to be?
Compatible?
Maybe compatible?
Incompatible?

I tried running my set of karaf applications, that are running fine on
karaf 4.2.11 on karaf 4.3.0.

That didn't work.  Or rather: it partly worked.

The first error in the karaf.log is this one:
 https://gist.github.com/steinarb/4a863956069f03d0e18c0431ab9402d8

Thanks!


- Steinar


Re: Should 4.2.11 applications run on 4.3.0?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:

> So, you need core, no brainer ;)

Yup!

> In karaf, you don’t care about config, and so on, Karaf provides it.

I know. :-)

One of the many reasons I like karaf.



Re: Should 4.2.11 applications run on 4.3.0?

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
So, you need core, no brainer ;)

In karaf, you don’t care about config, and so on, Karaf provides it.

Regards
JB

> Le 28 mars 2021 à 14:09, Steinar Bang <sb...@dod.no> a écrit :
> 
>>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:
> 
>> Hi,
>> Yes, not surprising: LogService is from cmpn so core is required.
> 
>> Instead of using LogService, you can use slf4j (and so pax-logging), and you won’t have the core dependency (at least for logging).
> 
> Actually I think using the logservice is simpler... slf4j and the
> various config files to make logs appear and disappear, have always been
> a mystery to me...
> 
> The logservice is nicely mockable also I made myself this one a long
> time ago for use in unit tests:
> https://github.com/steinarb/adapters-for-osgi-services/blob/master/service-mocks/src/main/java/no/priv/bang/osgi/service/mocks/logservice/MockLogService.java#L39
> 
> This MockLogService dumps everything to System.err (for quick feedback
> in the JUnit console of the IDE) and also saves it into a list that can
> be asserted on.
> 
> But if there is a pax-logging, it sounds like it's something I should
> check out.
> 
> So I'll do that.
> 


pax-logging (Was: Should 4.2.11 applications run on 4.3.0?)

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:

>> Instead of using LogService, you can use slf4j (and so pax-logging), and you won’t have the core dependency (at least for logging).

> Actually I think using the logservice is simpler... slf4j and the
> various config files to make logs appear and disappear, have always been
> a mystery to me...

[snip!]
> But if there is a pax-logging, it sounds like it's something I should
> check out.

> So I'll do that.

So basically: you use slf4j in your code, but the actual logging
mechanism is the OSGi LogService?
 https://ops4j1.jira.com/wiki/spaces/paxlogging/overview

That means that all the obscure config files (which belongs to
the underlying logging logging system, e.g. Logback or Log4J, rather
than slf4j) becomes irrelevant for production code.

So that's nice.

Also, the slf4j API is well known and much nicer than the LogService
one.  Much nicer for others working on my code.

However, LogService gave me the possibility of asserting on log messages
in JUnit tests, something I've never been able to do with the regular
logging frameworks.

And I have lots of tests doing it.

Also, I'm using LogService throughout my code and it would be a lot of
work to change it.

(losing the osgi.core maven dependency isn't a big deal for me. I just
wondered why I needed it...?)



Re: Should 4.2.11 applications run on 4.3.0?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:

> Hi,
> Yes, not surprising: LogService is from cmpn so core is required.

> Instead of using LogService, you can use slf4j (and so pax-logging), and you won’t have the core dependency (at least for logging).

Actually I think using the logservice is simpler... slf4j and the
various config files to make logs appear and disappear, have always been
a mystery to me...

The logservice is nicely mockable also I made myself this one a long
time ago for use in unit tests:
 https://github.com/steinarb/adapters-for-osgi-services/blob/master/service-mocks/src/main/java/no/priv/bang/osgi/service/mocks/logservice/MockLogService.java#L39

This MockLogService dumps everything to System.err (for quick feedback
in the JUnit console of the IDE) and also saves it into a list that can
be asserted on.

But if there is a pax-logging, it sounds like it's something I should
check out.

So I'll do that.


Re: Should 4.2.11 applications run on 4.3.0?

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi,

Yes, not surprising: LogService is from cmpn so core is required.

Instead of using LogService, you can use slf4j (and so pax-logging), and you won’t have the core dependency (at least for logging).

Regards
JB

> Le 28 mars 2021 à 11:30, Steinar Bang <sb...@dod.no> a écrit :
> 
>>>>>> Steinar Bang <sb...@dod.no>:
> 
>>> But I guess it would be better if I also switched to OSGi core 7.0.0 and
>>> a corresponding version of OSGi services (1.4.0...?)...?
> 
>> Which begs the question: why do my applications need maven dependencies
>> to the OSGi core?
> 
>> That may just be a historical leftover from what I was using before SCR
>> (i.e. my own little DI framework)...?
> 
>> I will try removing OSGi core from the maven dependencies of the
>> applications.
> 
> Using the OSGi LogService requires a provided dependency to osgi.core to
> be able to build.
> 
> So as long as I use LogService I need osgi.core as a provided dependency.
> 


Re: Should 4.2.11 applications run on 4.3.0?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

>> But I guess it would be better if I also switched to OSGi core 7.0.0 and
>> a corresponding version of OSGi services (1.4.0...?)...?

> Which begs the question: why do my applications need maven dependencies
> to the OSGi core?

> That may just be a historical leftover from what I was using before SCR
> (i.e. my own little DI framework)...?

> I will try removing OSGi core from the maven dependencies of the
> applications.

Using the OSGi LogService requires a provided dependency to osgi.core to
be able to build.

So as long as I use LogService I need osgi.core as a provided dependency.


Re: Should 4.2.11 applications run on 4.3.0?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> But I guess it would be better if I also switched to OSGi core 7.0.0 and
> a corresponding version of OSGi services (1.4.0...?)...?

Which begs the question: why do my applications need maven dependencies
to the OSGi core?

That may just be a historical leftover from what I was using before SCR
(i.e. my own little DI framework)...?

I will try removing OSGi core from the maven dependencies of the
applications.


Re: Should 4.2.11 applications run on 4.3.0?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:

> Here is the full log (different run, so the first failing servlet is a
> different one, but it is a servlet derived from JerseyServlet):
>  https://gist.github.com/steinarb/da22602f1d626298143b880ebc5bab2a

> Hm... it's not a reload, either.

> The servlet starts here (seems like a successful activation):
>  https://gist.github.com/steinarb/da22602f1d626298143b880ebc5bab2a#file-karaf-log-L897

> Then it fails in the next line:
>  https://gist.github.com/steinarb/da22602f1d626298143b880ebc5bab2a#file-karaf-log-L898

> And this is the first time this exact servlet is mentioned in karaf.log.

Recompiling authservice with dependencies from the karaf 4.3.0 BoM
instead of the karaf 4.2.11 BoM is enough to fix this problem.

But I guess it would be better if I also switched to OSGi core 7.0.0 and
a corresponding version of OSGi services (1.4.0...?)...?


Re: Should 4.2.11 applications run on 4.3.0?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofre <jb...@nanthrax.net>:

> Hi,
> It depends of the import range mostly.

> I would say that most of user scoped applications should run smoothly on 4.2.x and 4.3.x if the import version ranges are large enough.

> In your case, it seems you are registering the same servlet two times
> with different alias.

Hm... I don't think I do...?

They may have the same base class(es), but each servlet that is a
@Component, should have its own concrete class.

Isn't that sufficent?

Is deriving from the same base class a problem?

> I have to check in Pax Web 7.3.x if we added some "checks"
> there. However, it sounds like a fix in 4.3.x, and you "used" the bug
> in 4.2.x by dual registration.

Here is the failing servlet:
https://github.com/steinarb/ukelonn/blob/master/ukelonn.web.services/src/main/java/no/priv/bang/ukelonn/api/UkelonnRestApiServlet.java#L30

Could it be a reload issue?

Or could it be caused by e.g. this component? (which I know is loaded at
this point in time)
 https://github.com/steinarb/authservice/blob/master/authservice.web.users.api/src/main/java/no/priv/bang/authservice/web/users/api/UserAdminWebApiServlet.java#L38

Here is the full log (different run, so the first failing servlet is a
different one, but it is a servlet derived from JerseyServlet):
 https://gist.github.com/steinarb/da22602f1d626298143b880ebc5bab2a

Hm... it's not a reload, either.

The servlet starts here (seems like a successful activation):
 https://gist.github.com/steinarb/da22602f1d626298143b880ebc5bab2a#file-karaf-log-L897

Then it fails in the next line:
 https://gist.github.com/steinarb/da22602f1d626298143b880ebc5bab2a#file-karaf-log-L898

And this is the first time this exact servlet is mentioned in karaf.log.


Re: Should 4.2.11 applications run on 4.3.0?

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
Hi,

It depends of the import range mostly.

I would say that most of user scoped applications should run smoothly on 4.2.x and 4.3.x if the import version ranges are large enough.

In your case, it seems you are registering the same servlet two times with different alias. I have to check in Pax Web 7.3.x if we added some "checks" there. However, it sounds like a fix in 4.3.x, and you "used" the bug in 4.2.x by dual registration.

Regards
JB

> Le 22 mars 2021 à 18:55, Steinar Bang <sb...@dod.no> a écrit :
> 
> How run-time compatible are karaf 4.2.11 and 4.3.0 supposed to be?
> Compatible?
> Maybe compatible?
> Incompatible?
> 
> I tried running my set of karaf applications, that are running fine on
> karaf 4.2.11 on karaf 4.3.0.
> 
> That didn't work.  Or rather: it partly worked.
> 
> The first error in the karaf.log is this one:
> https://gist.github.com/steinarb/4a863956069f03d0e18c0431ab9402d8
> 
> Thanks!
> 
> 
> - Steinar
>