What’s the start level ?

Le 16 avr. 2020 à 15:37, Alex Soto <alex.soto@envieta.com> a écrit :

Thank you JB.   

When I add my jar to the “startup.properties” I am getting error "java.lang.NoClassDefFoundError: javax/crypto/spec/DHParameterSpec”, which does not occur when I deploy the same jar manually from the deployment directory. Any idea why?

This is Java 8:

$JAVA_HOME/bin/java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

Best regards,
Alex soto

On Apr 15, 2020, at 3:03 PM, Jean-Baptiste Onofre <jb@nanthrax.net> wrote:

Hi Alex,

Actually, etc/startup.properties doesn’t really use mvn. When you use mvn, Karaf is looking for the file in the system folder (as pax-url is not yet started).

So, you can use mvn (as soon as your bundle is in the system folder), file or reference.

For the start level, it depends the dependencies that your bundle require. I would recommend to avoid SCR else you would need SCR in etc/startup.properties before your bundle.

Just use a "regular" bundle with an activator. You will have limited dependencies.


Le 15 avr. 2020 à 20:58, Alex Soto <alex.soto@envieta.com> a écrit :

Thanks JB,  would it work with file:// protocol, or only mvn? 
Also, what start level do you recommend?

Best regards,
Alex soto

On Apr 15, 2020, at 1:55 PM, Jean-Baptiste Onofre <jb@nanthrax.net> wrote:

Hi Alex,

Yes, SystemService is exactly provided for that (it’s used by the halt/shutdown Karaf command).

Another option (it’s basically what the SystemService is doing) is to do: bundleContext.stop(0);

Bundle 0 is the system bundle (the framework basically).

SystemService is a better option IMHO.

If you want to be even faster, you can also have this bundle in etc/startup.properties (it’s before the feature service to boot features).


Le 15 avr. 2020 à 17:25, Alex Soto <alex.soto@envieta.com> a écrit :


What would be the best way to shutdown Karaf as soon as possible from a Declarative Component that needs to run at startup. 
This component will check some authorization API and decide if the user is authorized to run the app.  So, I thought to have a component  with @Component(immediate = true) and: 

private SystemService systemService;

void init() {
if (!authorized()) {

Is this a good approach?
Should I add the bundle containing this component as a boot feature? 
Any other advise?

Best regards,
Alex soto