You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Alex Soto <al...@envieta.com> on 2020/04/15 18:58:58 UTC

Re: Stopping Karaf

Thanks JB,  would it work with file:// <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).
> 
> Regards
> JB
> 
>> Le 15 avr. 2020 à 17:25, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> a écrit :
>> 
>> Hello,
>> 
>> 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: 
>> 
>> 	@Reference
>> 	private SystemService systemService;
>> 
>> 	@Activate
>> 	void init() {
>> 		if (!authorized()) {
>> 			systemService.halt();
>> 		}
>> 	}
>> 
>> 
>> Is this a good approach?
>> Should I add the bundle containing this component as a boot feature? 
>> Any other advise?
>> 
>> 
>> Best regards,
>> Alex soto
>> 
>> 
>> 
>> 
> 


Re: Stopping Karaf

Posted by Alex Soto <al...@envieta.com>.
It is working now with level 3, I had the jar in the wrong place in the “system” directory, so it have been finding an older version of this jar.   Thanks! 



> On Apr 16, 2020, at 9:53 AM, Alex Soto <al...@envieta.com> wrote:
> 
> I tried different ones: 3, 5...
> 
> 
> 
> 
>> On Apr 16, 2020, at 9:51 AM, Jean-Baptiste Onofre <jb@nanthrax.net <ma...@nanthrax.net>> wrote:
>> 
>> What’s the start level ?
>> 
>>> Le 16 avr. 2020 à 15:37, Alex Soto <alex.soto@envieta.com <ma...@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 <ma...@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.
>>>> 
>>>> Regards
>>>> JB 
>>>> 
>>>>> Le 15 avr. 2020 à 20:58, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> a écrit :
>>>>> 
>>>>> Thanks JB,  would it work with file:// <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 <ma...@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).
>>>>>> 
>>>>>> Regards
>>>>>> JB
>>>>>> 
>>>>>>> Le 15 avr. 2020 à 17:25, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> a écrit :
>>>>>>> 
>>>>>>> Hello,
>>>>>>> 
>>>>>>> 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: 
>>>>>>> 
>>>>>>> 	@Reference
>>>>>>> 	private SystemService systemService;
>>>>>>> 
>>>>>>> 	@Activate
>>>>>>> 	void init() {
>>>>>>> 		if (!authorized()) {
>>>>>>> 			systemService.halt();
>>>>>>> 		}
>>>>>>> 	}
>>>>>>> 
>>>>>>> 
>>>>>>> Is this a good approach?
>>>>>>> Should I add the bundle containing this component as a boot feature? 
>>>>>>> Any other advise?
>>>>>>> 
>>>>>>> 
>>>>>>> Best regards,
>>>>>>> Alex soto
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: Stopping Karaf

Posted by Alex Soto <al...@envieta.com>.
I tried different ones: 3, 5...




> On Apr 16, 2020, at 9:51 AM, Jean-Baptiste Onofre <jb...@nanthrax.net> wrote:
> 
> What’s the start level ?
> 
>> Le 16 avr. 2020 à 15:37, Alex Soto <alex.soto@envieta.com <ma...@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 <ma...@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.
>>> 
>>> Regards
>>> JB 
>>> 
>>>> Le 15 avr. 2020 à 20:58, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> a écrit :
>>>> 
>>>> Thanks JB,  would it work with file:// <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 <ma...@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).
>>>>> 
>>>>> Regards
>>>>> JB
>>>>> 
>>>>>> Le 15 avr. 2020 à 17:25, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> a écrit :
>>>>>> 
>>>>>> Hello,
>>>>>> 
>>>>>> 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: 
>>>>>> 
>>>>>> 	@Reference
>>>>>> 	private SystemService systemService;
>>>>>> 
>>>>>> 	@Activate
>>>>>> 	void init() {
>>>>>> 		if (!authorized()) {
>>>>>> 			systemService.halt();
>>>>>> 		}
>>>>>> 	}
>>>>>> 
>>>>>> 
>>>>>> Is this a good approach?
>>>>>> Should I add the bundle containing this component as a boot feature? 
>>>>>> Any other advise?
>>>>>> 
>>>>>> 
>>>>>> Best regards,
>>>>>> Alex soto
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: Stopping Karaf

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
What’s the start level ?

> Le 16 avr. 2020 à 15:37, Alex Soto <al...@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 <ma...@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.
>> 
>> Regards
>> JB 
>> 
>>> Le 15 avr. 2020 à 20:58, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> a écrit :
>>> 
>>> Thanks JB,  would it work with file:// <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 <ma...@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).
>>>> 
>>>> Regards
>>>> JB
>>>> 
>>>>> Le 15 avr. 2020 à 17:25, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> a écrit :
>>>>> 
>>>>> Hello,
>>>>> 
>>>>> 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: 
>>>>> 
>>>>> 	@Reference
>>>>> 	private SystemService systemService;
>>>>> 
>>>>> 	@Activate
>>>>> 	void init() {
>>>>> 		if (!authorized()) {
>>>>> 			systemService.halt();
>>>>> 		}
>>>>> 	}
>>>>> 
>>>>> 
>>>>> Is this a good approach?
>>>>> Should I add the bundle containing this component as a boot feature? 
>>>>> Any other advise?
>>>>> 
>>>>> 
>>>>> Best regards,
>>>>> Alex soto
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 


Re: Stopping Karaf

Posted by Alex Soto <al...@envieta.com>.
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.
> 
> Regards
> JB 
> 
>> Le 15 avr. 2020 à 20:58, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> a écrit :
>> 
>> Thanks JB,  would it work with file:// <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 <ma...@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).
>>> 
>>> Regards
>>> JB
>>> 
>>>> Le 15 avr. 2020 à 17:25, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> a écrit :
>>>> 
>>>> Hello,
>>>> 
>>>> 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: 
>>>> 
>>>> 	@Reference
>>>> 	private SystemService systemService;
>>>> 
>>>> 	@Activate
>>>> 	void init() {
>>>> 		if (!authorized()) {
>>>> 			systemService.halt();
>>>> 		}
>>>> 	}
>>>> 
>>>> 
>>>> Is this a good approach?
>>>> Should I add the bundle containing this component as a boot feature? 
>>>> Any other advise?
>>>> 
>>>> 
>>>> Best regards,
>>>> Alex soto
>>>> 
>>>> 
>>>> 
>>>> 
>>> 
>> 
> 


Re: Stopping Karaf

Posted by Jean-Baptiste Onofre <jb...@nanthrax.net>.
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.

Regards
JB 

> Le 15 avr. 2020 à 20:58, Alex Soto <al...@envieta.com> a écrit :
> 
> Thanks JB,  would it work with file:// <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 <ma...@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).
>> 
>> Regards
>> JB
>> 
>>> Le 15 avr. 2020 à 17:25, Alex Soto <alex.soto@envieta.com <ma...@envieta.com>> a écrit :
>>> 
>>> Hello,
>>> 
>>> 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: 
>>> 
>>> 	@Reference
>>> 	private SystemService systemService;
>>> 
>>> 	@Activate
>>> 	void init() {
>>> 		if (!authorized()) {
>>> 			systemService.halt();
>>> 		}
>>> 	}
>>> 
>>> 
>>> Is this a good approach?
>>> Should I add the bundle containing this component as a boot feature? 
>>> Any other advise?
>>> 
>>> 
>>> Best regards,
>>> Alex soto
>>> 
>>> 
>>> 
>>> 
>> 
>