From user-return-22134-apmail-karaf-user-archive=karaf.apache.org@karaf.apache.org Thu Apr 16 13:51:16 2020 Return-Path: X-Original-To: apmail-karaf-user-archive@minotaur.apache.org Delivered-To: apmail-karaf-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by minotaur.apache.org (Postfix) with SMTP id C0DCD19324 for ; Thu, 16 Apr 2020 13:51:15 +0000 (UTC) Received: (qmail 2646 invoked by uid 500); 16 Apr 2020 13:51:14 -0000 Delivered-To: apmail-karaf-user-archive@karaf.apache.org Received: (qmail 2615 invoked by uid 500); 16 Apr 2020 13:51:14 -0000 Mailing-List: contact user-help@karaf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@karaf.apache.org Delivered-To: mailing list user@karaf.apache.org Received: (qmail 2601 invoked by uid 99); 16 Apr 2020 13:51:14 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Apr 2020 13:51:14 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id BF20CC1D07 for ; Thu, 16 Apr 2020 13:51:13 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.513 X-Spam-Level: X-Spam-Status: No, score=0.513 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=0.2, KAM_DMARC_STATUS=0.01, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_NONE=0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-he-de.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 3s-36qQtRwYF for ; Thu, 16 Apr 2020 13:51:10 +0000 (UTC) Received-SPF: None (mailfrom) identity=mailfrom; client-ip=217.70.178.231; helo=relay11.mail.gandi.net; envelope-from=jb@nanthrax.net; receiver= Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by mx1-he-de.apache.org (ASF Mail Server at mx1-he-de.apache.org) with ESMTPS id 75C187FB3F for ; Thu, 16 Apr 2020 13:51:09 +0000 (UTC) Received: from [192.168.0.147] (hvc29-1-78-218-26-15.fbx.proxad.net [78.218.26.15]) (Authenticated sender: jb@nanthrax.net) by relay11.mail.gandi.net (Postfix) with ESMTPSA id A9734100006 for ; Thu, 16 Apr 2020 13:51:02 +0000 (UTC) From: Jean-Baptiste Onofre Content-Type: multipart/alternative; boundary="Apple-Mail=_DB06CE59-08FE-4F1E-BD14-DD6E92588F7A" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: Stopping Karaf Date: Thu, 16 Apr 2020 15:51:09 +0200 References: <519B784D-C69C-497A-9885-FF51A4832321@envieta.com> <396BECBB-891C-411B-AB5E-F8583352996F@envieta.com> To: user@karaf.apache.org In-Reply-To: <396BECBB-891C-411B-AB5E-F8583352996F@envieta.com> Message-Id: <9B3599F7-0DC4-435E-9F4D-00733DD59DBA@nanthrax.net> X-Mailer: Apple Mail (2.3608.80.23.2.2) --Apple-Mail=_DB06CE59-08FE-4F1E-BD14-DD6E92588F7A Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 What=E2=80=99s the start level ? > Le 16 avr. 2020 =C3=A0 15:37, Alex Soto a = =C3=A9crit : >=20 > Thank you JB. =20 >=20 > When I add my jar to the =E2=80=9Cstartup.properties=E2=80=9D I am = getting error "java.lang.NoClassDefFoundError: = javax/crypto/spec/DHParameterSpec=E2=80=9D, which does not occur when I = deploy the same jar manually from the deployment directory. Any idea = why? >=20 > This is Java 8: >=20 > $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) >=20 >=20 > Best regards, > Alex soto >=20 >=20 >=20 >=20 >> On Apr 15, 2020, at 3:03 PM, Jean-Baptiste Onofre > wrote: >>=20 >> Hi Alex, >>=20 >> Actually, etc/startup.properties doesn=E2=80=99t really use mvn. When = you use mvn, Karaf is looking for the file in the system folder (as = pax-url is not yet started). >>=20 >> So, you can use mvn (as soon as your bundle is in the system folder), = file or reference. >>=20 >> 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. >>=20 >> Just use a "regular" bundle with an activator. You will have limited = dependencies. >>=20 >> Regards >> JB=20 >>=20 >>> Le 15 avr. 2020 =C3=A0 20:58, Alex Soto > a =C3=A9crit : >>>=20 >>> Thanks JB, would it work with file:// protocol, or only = mvn?=20 >>> Also, what start level do you recommend? >>>=20 >>> Best regards, >>> Alex soto >>>=20 >>>=20 >>>=20 >>>=20 >>>> On Apr 15, 2020, at 1:55 PM, Jean-Baptiste Onofre > wrote: >>>>=20 >>>> Hi Alex, >>>>=20 >>>> Yes, SystemService is exactly provided for that (it=E2=80=99s used = by the halt/shutdown Karaf command). >>>>=20 >>>> Another option (it=E2=80=99s basically what the SystemService is = doing) is to do: bundleContext.stop(0); >>>>=20 >>>> Bundle 0 is the system bundle (the framework basically). >>>>=20 >>>> SystemService is a better option IMHO. >>>>=20 >>>> If you want to be even faster, you can also have this bundle in = etc/startup.properties (it=E2=80=99s before the feature service to boot = features). >>>>=20 >>>> Regards >>>> JB >>>>=20 >>>>> Le 15 avr. 2020 =C3=A0 17:25, Alex Soto > a =C3=A9crit : >>>>>=20 >>>>> Hello, >>>>>=20 >>>>> What would be the best way to shutdown Karaf as soon as possible = from a Declarative Component that needs to run at startup.=20 >>>>> 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 =3D true) and:=20 >>>>>=20 >>>>> @Reference >>>>> private SystemService systemService; >>>>>=20 >>>>> @Activate >>>>> void init() { >>>>> if (!authorized()) { >>>>> systemService.halt(); >>>>> } >>>>> } >>>>>=20 >>>>>=20 >>>>> Is this a good approach? >>>>> Should I add the bundle containing this component as a boot = feature?=20 >>>>> Any other advise? >>>>>=20 >>>>>=20 >>>>> Best regards, >>>>> Alex soto >>>>>=20 >>>>>=20 >>>>>=20 >>>>>=20 >>>>=20 >>>=20 >>=20 >=20 --Apple-Mail=_DB06CE59-08FE-4F1E-BD14-DD6E92588F7A Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 What=E2=80=99s the start level ?

Le 16 = avr. 2020 =C3=A0 15:37, Alex Soto <alex.soto@envieta.com> a =C3=A9crit :

Thank you JB. =   

When I = add my jar to the =E2=80=9Cstartup.properties=E2=80=9D I am getting = error "java.lang.NoClassDefFoundError: = javax/crypto/spec/DHParameterSpec=E2=80=9D, 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=E2=80=99t 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 =C3=A0 20:58, Alex Soto = <alex.soto@envieta.com> a =C3=A9crit :

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=E2=80=99s used by the halt/shutdown Karaf = command).

Another option (it=E2=80=99s 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=E2=80=99s before the = feature service to boot features).

Regards
JB

Le 15 avr. 2020 =C3=A0 17:25, Alex Soto = <alex.soto@envieta.com> a =C3=A9crit :

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 =3D 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









= --Apple-Mail=_DB06CE59-08FE-4F1E-BD14-DD6E92588F7A--