You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Andre Schlegel-Tylla <an...@virtimo.de> on 2022/01/28 06:18:02 UTC

BUG: Overriding ports via environment variable don't work on first start

Hello,

We are using environment variables to override the karaf ports (
https://karaf.apache.org/manual/latest/#_environment_variables_system_properties).
We have some tests where we make a fresh installation with some changed
ports. In this case we have seen port conflicts with a parallel vanilla
installation on the same machine (ssh port and http port). It seems that
the override by the environment variables didn't work. After a restart of
the installation all was fine.

I can reproduce the problem on my machine. I have downloaded the
current 4.3.6 release. Set there env vars:

export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
export ORG_APACHE_KARAF_MANAGEMENT_RMIREGISTRYPORT=11099
export ORG_APACHE_KARAF_MANAGEMENT_RMISERVERPORT=14444
export ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT=18181
export ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT_SECURE=18282

When I start the fresh karaf (bin/karaf) the ssh port is open on 8101 and
not on 18101. When I stop the karaf and start again the ssh port is open on
18101.

Kind regards
Andre

Re: BUG: Overriding ports via environment variable don't work on first start

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Andre,

So far no, but I guess it's a race condition. I will resume my
investigations around that.

I will keep you posted.

Regards
JB

On Mon, Feb 14, 2022 at 1:36 PM Andre Schlegel-Tylla
<an...@virtimo.de> wrote:
>
> Hi JB,
>
> Were you able to reproduce the problem?
>
> Regards
> Andre

Re: BUG: Overriding ports via environment variable don't work on first start

Posted by Andre Schlegel-Tylla <an...@virtimo.de>.
Hi JB,

Were you able to reproduce the problem?

Regards
Andre

Re: BUG: Overriding ports via environment variable don't work on first start

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

I’m working on Decanter and ActiveMQ this week end, I will take a look next week.

Regards
JB

> Le 28 janv. 2022 à 11:28, Andre Schlegel-Tylla <an...@virtimo.de> a écrit :
> 
> Done
> 
> https://issues.apache.org/jira/browse/KARAF-7362
> 
> Am Fr., 28. Jan. 2022 um 11:07 Uhr schrieb Jean-Baptiste Onofré <jb...@nanthrax.net>:
> Yes, please if you can (else I will do it).
> 
> Thanks !
> Regards
> JB
> 
> On 28/01/2022 11:05, Andre Schlegel-Tylla wrote:
> > Thank you.
> > 
> > Should I file a Jira ticket?
> > 
> > Regards
> > Andre
> > 
> > Am Fr., 28. Jan. 2022 um 10:34 Uhr schrieb Jean-Baptiste Onofré 
> > <jb@nanthrax.net <ma...@nanthrax.net>>:
> > 
> >     Hi Andre,
> > 
> >     thanks for the update.
> > 
> >     Yeah, it seems to be a race condition where the config interceptor
> >     (overriding values with system properties and env variables) is started
> >     after some other services.
> > 
> >     Let me investigate a bit (probably finalizing interceptor start before
> >     features service).
> > 
> >     Regards
> >     JB
> > 
> >     On 28/01/2022 10:01, Andre Schlegel-Tylla wrote:
> >      > Hi JB,
> >      >
> >      > yes I have used Karaf 4.3.6 vanilla. I have repeated my tests by
> >      > deleting the data folder.
> >      >
> >      > I have repeated it again and got different results (now with
> >     deleting
> >      > the whole karaf and unpack the vanilla tar.gz again).
> >      >
> >      > I had used this:
> >      >
> >      > export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
> >      > tar -xzf apache-karaf-4.3.6.tar.gz
> >      > apache-karaf-4.3.6/bin/karaf
> >      >
> >      >
> >      > * First time all went as expected; ports have been changed
> >      > * Second time I got this:
> >      >
> >      >    karaf-env-test tar -xzf apache-karaf-4.3.6.tar.gz
> >      >    karaf-env-test apache-karaf-4.3.6/bin/karaf
> >      >          __ __                  ____
> >      >         / //_/____ __________ _/ __/
> >      >        / ,<  / __ `/ ___/ __ `/ /_
> >      >       / /| |/ /_/ / /  / /_/ / __/
> >      >      /_/ |_|\__,_/_/   \__,_/_/
> >      >
> >      >    Apache Karaf (4.3.6)
> >      >
> >      > Hit '<tab>' for a list of available commands
> >      > and '[cmd] --help' for help on a specific command.
> >      > Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown
> >     Karaf.
> >      >
> >      > karaf@root()> Exception in thread "JMX Connector Thread
> >      >
> >     [service:jmx:rmi://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root
> >     <http://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root>
> >      > <http://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root
> >     <http://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root>>]"
> >      > java.lang.RuntimeException: Could not start JMX connector server
> >      > at
> >      >
> >     org.apache.karaf.management.ConnectorServerFactory.lambda$init$0(ConnectorServerFactory.java:438)
> >      > at java.base/java.lang.Thread.run(Thread.java:829)
> >      > Caused by: java.io.IOException: Cannot bind to URL
> >      > [rmi://127.0.0.1:1099/karaf-root
> >     <http://127.0.0.1:1099/karaf-root> <http://127.0.0.1:1099/karaf-root
> >     <http://127.0.0.1:1099/karaf-root>>]:
> >      > javax.naming.CommunicationException [Root exception is
> >      > java.rmi.NoSuchObjectException: no such object in table]
> >      > at
> >      >
> >     java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:854)
> >      > at
> >      >
> >     java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:501)
> >      > at
> >      >
> >     org.apache.karaf.management.ConnectorServerFactory.lambda$init$0(ConnectorServerFactory.java:421)
> >      > ... 1 more
> >      > Caused by: javax.naming.CommunicationException [Root exception is
> >      > java.rmi.NoSuchObjectException: no such object in table]
> >      > at
> >      >
> >     jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:162)
> >      > at
> >      >
> >     java.naming/com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:230)
> >      > at
> >     java.naming/javax.naming.InitialContext.bind(InitialContext.java:417)
> >      > at
> >      >
> >     java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:713)
> >      > at
> >      >
> >     java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:496)
> >      > ... 2 more
> >      > Caused by: java.rmi.NoSuchObjectException: no such object in table
> >      > at
> >      >
> >     java.rmi/sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303)
> >      > at
> >      >
> >     java.rmi/sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:279)
> >      > at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:380)
> >      > at
> >      >
> >     java.rmi/sun.rmi.registry.RegistryImpl_Stub.bind(RegistryImpl_Stub.java:73)
> >      > at
> >      >
> >     jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:156)
> >      > ... 6 more
> >      >
> >      > * Third time there was no JMX error, ssh port was open on 8101
> >     not on
> >      > 18101 as expected. And the config result is this:
> >      > karaf@root()> config:list | grep Port
> >      >     jmxmpPort = 9999
> >      >     rmiRegistryPort = 11099
> >      >     rmiServerPort = 14444
> >      >     sshPort = 18101
> >      >
> >      > It seems to me that there are some timing issues.
> >      >
> >      > On our test installation which is done by a script in Jenkins we
> >     always
> >      > got the problem with the httpPort and sometimes also with the
> >     sshPort.
> >      >
> >      > Regards
> >      > Andre
> >      >
> >      >
> >      >
> >      > *ANDRE SCHLEGEL-TYLLA*/
> >      > Teamleiter Development/
> >      >
> >      >
> >      > *
> >      >
> >      > VIRTIMO AG*
> >      > Behrenstraße 18  | 10117 Berlin
> >      > Mobil: +49 175 67 853 74 | Fax: +49 30 55 574 40 99
> >      > andre.schlegel-tylla@virtimo.de
> >     <ma...@virtimo.de>
> >      > <mailto:andre.schlegel-tylla@virtimo.de
> >     <ma...@virtimo.de>> | www.virtimo.de
> >     <http://www.virtimo.de>
> >      > <http://www.virtimo.de/ <http://www.virtimo.de/>>
> >      >
> >      >
> >      > Registergericht: AG Berlin-Charlottenburg | HRB 131281 B | Sitz der
> >      > Gesellschaft: Berlin | USt-IdNr.: DE274491859
> >      > Vorstand: Christoph Fuchß, Dirk Breitkreuz, Tobias Weinert |
> >      > Vorsitzender des Aufsichtsrates: Prof. Dr. Stefan Stieglitz
> >      >
> >      >
> >      > Am Fr., 28. Jan. 2022 um 08:23 Uhr schrieb Jean-Baptiste Onofré
> >      > <jb@nanthrax.net <ma...@nanthrax.net> <mailto:jb@nanthrax.net
> >     <ma...@nanthrax.net>>>:
> >      >
> >      >     Hi Andre,
> >      >
> >      >     do you start with no data folder ?
> >      >
> >      >     I just tried and it works fine for me.
> >      >
> >      >     ConfigAdmin service has be started before SSH (which is the
> >     case by
> >      >     default).
> >      >
> >      >     Do you use a Karaf 4.3.6 vanilla ?
> >      >
> >      >     Regards
> >      >     JB
> >      >
> >      >     On 28/01/2022 07:18, Andre Schlegel-Tylla wrote:
> >      >      > Hello,
> >      >      >
> >      >      > We are using environment variables to override the karaf ports
> >      >      >
> >      >   
> >       (https://karaf.apache.org/manual/latest/#_environment_variables_system_properties <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties>
> >      >   
> >       <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties>>
> >      >
> >      >      >
> >      >   
> >       <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties>
> >      >   
> >       <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties>>>).
> >      >
> >      >      > We have some tests where we make a fresh installation with
> >     some
> >      >     changed
> >      >      > ports. In this case we have seen port conflicts with a
> >     parallel
> >      >     vanilla
> >      >      > installation on the same machine (ssh port and http port). It
> >      >     seems that
> >      >      > the override by the environment variables didn't work. After a
> >      >     restart
> >      >      > of the installation all was fine.
> >      >      >
> >      >      > I can reproduce the problem on my machine. I have
> >     downloaded the
> >      >      > current 4.3.6 release. Set there env vars:
> >      >      >
> >      >      > export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
> >      >      > export ORG_APACHE_KARAF_MANAGEMENT_RMIREGISTRYPORT=11099
> >      >      > export ORG_APACHE_KARAF_MANAGEMENT_RMISERVERPORT=14444
> >      >      > export ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT=18181
> >      >      > export
> >     ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT_SECURE=18282
> >      >      >
> >      >      > When I start the fresh karaf (bin/karaf) the ssh port is
> >     open on
> >      >     8101
> >      >      > and not on 18101. When I stop the karaf and start again
> >     the ssh
> >      >     port is
> >      >      > open on 18101.
> >      >      >
> >      >      > Kind regards
> >      >      > Andre
> >      >
> > 


Re: BUG: Overriding ports via environment variable don't work on first start

Posted by Andre Schlegel-Tylla <an...@virtimo.de>.
Done

https://issues.apache.org/jira/browse/KARAF-7362

Am Fr., 28. Jan. 2022 um 11:07 Uhr schrieb Jean-Baptiste Onofré <
jb@nanthrax.net>:

> Yes, please if you can (else I will do it).
>
> Thanks !
> Regards
> JB
>
> On 28/01/2022 11:05, Andre Schlegel-Tylla wrote:
> > Thank you.
> >
> > Should I file a Jira ticket?
> >
> > Regards
> > Andre
> >
> > Am Fr., 28. Jan. 2022 um 10:34 Uhr schrieb Jean-Baptiste Onofré
> > <jb@nanthrax.net <ma...@nanthrax.net>>:
> >
> >     Hi Andre,
> >
> >     thanks for the update.
> >
> >     Yeah, it seems to be a race condition where the config interceptor
> >     (overriding values with system properties and env variables) is
> started
> >     after some other services.
> >
> >     Let me investigate a bit (probably finalizing interceptor start
> before
> >     features service).
> >
> >     Regards
> >     JB
> >
> >     On 28/01/2022 10:01, Andre Schlegel-Tylla wrote:
> >      > Hi JB,
> >      >
> >      > yes I have used Karaf 4.3.6 vanilla. I have repeated my tests by
> >      > deleting the data folder.
> >      >
> >      > I have repeated it again and got different results (now with
> >     deleting
> >      > the whole karaf and unpack the vanilla tar.gz again).
> >      >
> >      > I had used this:
> >      >
> >      > export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
> >      > tar -xzf apache-karaf-4.3.6.tar.gz
> >      > apache-karaf-4.3.6/bin/karaf
> >      >
> >      >
> >      > * First time all went as expected; ports have been changed
> >      > * Second time I got this:
> >      >
> >      >    karaf-env-test tar -xzf apache-karaf-4.3.6.tar.gz
> >      >    karaf-env-test apache-karaf-4.3.6/bin/karaf
> >      >          __ __                  ____
> >      >         / //_/____ __________ _/ __/
> >      >        / ,<  / __ `/ ___/ __ `/ /_
> >      >       / /| |/ /_/ / /  / /_/ / __/
> >      >      /_/ |_|\__,_/_/   \__,_/_/
> >      >
> >      >    Apache Karaf (4.3.6)
> >      >
> >      > Hit '<tab>' for a list of available commands
> >      > and '[cmd] --help' for help on a specific command.
> >      > Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown
> >     Karaf.
> >      >
> >      > karaf@root()> Exception in thread "JMX Connector Thread
> >      >
> >     [service:jmx:rmi://
> 127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root
> >     <http://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root>
> >      > <http://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root
> >     <http://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root>>]"
> >      > java.lang.RuntimeException: Could not start JMX connector server
> >      > at
> >      >
> >
>  org.apache.karaf.management.ConnectorServerFactory.lambda$init$0(ConnectorServerFactory.java:438)
> >      > at java.base/java.lang.Thread.run(Thread.java:829)
> >      > Caused by: java.io.IOException: Cannot bind to URL
> >      > [rmi://127.0.0.1:1099/karaf-root
> >     <http://127.0.0.1:1099/karaf-root> <http://127.0.0.1:1099/karaf-root
> >     <http://127.0.0.1:1099/karaf-root>>]:
> >      > javax.naming.CommunicationException [Root exception is
> >      > java.rmi.NoSuchObjectException: no such object in table]
> >      > at
> >      >
> >
>  java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:854)
> >      > at
> >      >
> >
>  java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:501)
> >      > at
> >      >
> >
>  org.apache.karaf.management.ConnectorServerFactory.lambda$init$0(ConnectorServerFactory.java:421)
> >      > ... 1 more
> >      > Caused by: javax.naming.CommunicationException [Root exception is
> >      > java.rmi.NoSuchObjectException: no such object in table]
> >      > at
> >      >
> >
>  jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:162)
> >      > at
> >      >
> >
>  java.naming/com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:230)
> >      > at
> >     java.naming/javax.naming.InitialContext.bind(InitialContext.java:417)
> >      > at
> >      >
> >
>  java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:713)
> >      > at
> >      >
> >
>  java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:496)
> >      > ... 2 more
> >      > Caused by: java.rmi.NoSuchObjectException: no such object in table
> >      > at
> >      >
> >
>  java.rmi/sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303)
> >      > at
> >      >
> >
>  java.rmi/sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:279)
> >      > at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:380)
> >      > at
> >      >
> >
>  java.rmi/sun.rmi.registry.RegistryImpl_Stub.bind(RegistryImpl_Stub.java:73)
> >      > at
> >      >
> >
>  jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:156)
> >      > ... 6 more
> >      >
> >      > * Third time there was no JMX error, ssh port was open on 8101
> >     not on
> >      > 18101 as expected. And the config result is this:
> >      > karaf@root()> config:list | grep Port
> >      >     jmxmpPort = 9999
> >      >     rmiRegistryPort = 11099
> >      >     rmiServerPort = 14444
> >      >     sshPort = 18101
> >      >
> >      > It seems to me that there are some timing issues.
> >      >
> >      > On our test installation which is done by a script in Jenkins we
> >     always
> >      > got the problem with the httpPort and sometimes also with the
> >     sshPort.
> >      >
> >      > Regards
> >      > Andre
> >      >
> >      >
> >      >
> >      > *ANDRE SCHLEGEL-TYLLA*/
> >      > Teamleiter Development/
> >      >
> >      >
> >      > *
> >      >
> >      > VIRTIMO AG*
> >      > Behrenstraße 18  | 10117 Berlin
> >      > Mobil: +49 175 67 853 74 | Fax: +49 30 55 574 40 99
> >      > andre.schlegel-tylla@virtimo.de
> >     <ma...@virtimo.de>
> >      > <mailto:andre.schlegel-tylla@virtimo.de
> >     <ma...@virtimo.de>> | www.virtimo.de
> >     <http://www.virtimo.de>
> >      > <http://www.virtimo.de/ <http://www.virtimo.de/>>
> >      >
> >      >
> >      > Registergericht: AG Berlin-Charlottenburg | HRB 131281 B | Sitz
> der
> >      > Gesellschaft: Berlin | USt-IdNr.: DE274491859
> >      > Vorstand: Christoph Fuchß, Dirk Breitkreuz, Tobias Weinert |
> >      > Vorsitzender des Aufsichtsrates: Prof. Dr. Stefan Stieglitz
> >      >
> >      >
> >      > Am Fr., 28. Jan. 2022 um 08:23 Uhr schrieb Jean-Baptiste Onofré
> >      > <jb@nanthrax.net <ma...@nanthrax.net> <mailto:jb@nanthrax.net
> >     <ma...@nanthrax.net>>>:
> >      >
> >      >     Hi Andre,
> >      >
> >      >     do you start with no data folder ?
> >      >
> >      >     I just tried and it works fine for me.
> >      >
> >      >     ConfigAdmin service has be started before SSH (which is the
> >     case by
> >      >     default).
> >      >
> >      >     Do you use a Karaf 4.3.6 vanilla ?
> >      >
> >      >     Regards
> >      >     JB
> >      >
> >      >     On 28/01/2022 07:18, Andre Schlegel-Tylla wrote:
> >      >      > Hello,
> >      >      >
> >      >      > We are using environment variables to override the karaf
> ports
> >      >      >
> >      >
> >       (
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
> <
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
> >
> >      >
> >       <
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
> <
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
> >>
> >      >
> >      >      >
> >      >
> >       <
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
> <
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
> >
> >      >
> >       <
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
> <
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
> >>>).
> >      >
> >      >      > We have some tests where we make a fresh installation with
> >     some
> >      >     changed
> >      >      > ports. In this case we have seen port conflicts with a
> >     parallel
> >      >     vanilla
> >      >      > installation on the same machine (ssh port and http port).
> It
> >      >     seems that
> >      >      > the override by the environment variables didn't work.
> After a
> >      >     restart
> >      >      > of the installation all was fine.
> >      >      >
> >      >      > I can reproduce the problem on my machine. I have
> >     downloaded the
> >      >      > current 4.3.6 release. Set there env vars:
> >      >      >
> >      >      > export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
> >      >      > export ORG_APACHE_KARAF_MANAGEMENT_RMIREGISTRYPORT=11099
> >      >      > export ORG_APACHE_KARAF_MANAGEMENT_RMISERVERPORT=14444
> >      >      > export ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT=18181
> >      >      > export
> >     ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT_SECURE=18282
> >      >      >
> >      >      > When I start the fresh karaf (bin/karaf) the ssh port is
> >     open on
> >      >     8101
> >      >      > and not on 18101. When I stop the karaf and start again
> >     the ssh
> >      >     port is
> >      >      > open on 18101.
> >      >      >
> >      >      > Kind regards
> >      >      > Andre
> >      >
> >
>

Re: BUG: Overriding ports via environment variable don't work on first start

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Yes, please if you can (else I will do it).

Thanks !
Regards
JB

On 28/01/2022 11:05, Andre Schlegel-Tylla wrote:
> Thank you.
> 
> Should I file a Jira ticket?
> 
> Regards
> Andre
> 
> Am Fr., 28. Jan. 2022 um 10:34 Uhr schrieb Jean-Baptiste Onofré 
> <jb@nanthrax.net <ma...@nanthrax.net>>:
> 
>     Hi Andre,
> 
>     thanks for the update.
> 
>     Yeah, it seems to be a race condition where the config interceptor
>     (overriding values with system properties and env variables) is started
>     after some other services.
> 
>     Let me investigate a bit (probably finalizing interceptor start before
>     features service).
> 
>     Regards
>     JB
> 
>     On 28/01/2022 10:01, Andre Schlegel-Tylla wrote:
>      > Hi JB,
>      >
>      > yes I have used Karaf 4.3.6 vanilla. I have repeated my tests by
>      > deleting the data folder.
>      >
>      > I have repeated it again and got different results (now with
>     deleting
>      > the whole karaf and unpack the vanilla tar.gz again).
>      >
>      > I had used this:
>      >
>      > export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
>      > tar -xzf apache-karaf-4.3.6.tar.gz
>      > apache-karaf-4.3.6/bin/karaf
>      >
>      >
>      > * First time all went as expected; ports have been changed
>      > * Second time I got this:
>      >
>      >    karaf-env-test tar -xzf apache-karaf-4.3.6.tar.gz
>      >    karaf-env-test apache-karaf-4.3.6/bin/karaf
>      >          __ __                  ____
>      >         / //_/____ __________ _/ __/
>      >        / ,<  / __ `/ ___/ __ `/ /_
>      >       / /| |/ /_/ / /  / /_/ / __/
>      >      /_/ |_|\__,_/_/   \__,_/_/
>      >
>      >    Apache Karaf (4.3.6)
>      >
>      > Hit '<tab>' for a list of available commands
>      > and '[cmd] --help' for help on a specific command.
>      > Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown
>     Karaf.
>      >
>      > karaf@root()> Exception in thread "JMX Connector Thread
>      >
>     [service:jmx:rmi://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root
>     <http://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root>
>      > <http://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root
>     <http://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root>>]"
>      > java.lang.RuntimeException: Could not start JMX connector server
>      > at
>      >
>     org.apache.karaf.management.ConnectorServerFactory.lambda$init$0(ConnectorServerFactory.java:438)
>      > at java.base/java.lang.Thread.run(Thread.java:829)
>      > Caused by: java.io.IOException: Cannot bind to URL
>      > [rmi://127.0.0.1:1099/karaf-root
>     <http://127.0.0.1:1099/karaf-root> <http://127.0.0.1:1099/karaf-root
>     <http://127.0.0.1:1099/karaf-root>>]:
>      > javax.naming.CommunicationException [Root exception is
>      > java.rmi.NoSuchObjectException: no such object in table]
>      > at
>      >
>     java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:854)
>      > at
>      >
>     java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:501)
>      > at
>      >
>     org.apache.karaf.management.ConnectorServerFactory.lambda$init$0(ConnectorServerFactory.java:421)
>      > ... 1 more
>      > Caused by: javax.naming.CommunicationException [Root exception is
>      > java.rmi.NoSuchObjectException: no such object in table]
>      > at
>      >
>     jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:162)
>      > at
>      >
>     java.naming/com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:230)
>      > at
>     java.naming/javax.naming.InitialContext.bind(InitialContext.java:417)
>      > at
>      >
>     java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:713)
>      > at
>      >
>     java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:496)
>      > ... 2 more
>      > Caused by: java.rmi.NoSuchObjectException: no such object in table
>      > at
>      >
>     java.rmi/sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303)
>      > at
>      >
>     java.rmi/sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:279)
>      > at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:380)
>      > at
>      >
>     java.rmi/sun.rmi.registry.RegistryImpl_Stub.bind(RegistryImpl_Stub.java:73)
>      > at
>      >
>     jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:156)
>      > ... 6 more
>      >
>      > * Third time there was no JMX error, ssh port was open on 8101
>     not on
>      > 18101 as expected. And the config result is this:
>      > karaf@root()> config:list | grep Port
>      >     jmxmpPort = 9999
>      >     rmiRegistryPort = 11099
>      >     rmiServerPort = 14444
>      >     sshPort = 18101
>      >
>      > It seems to me that there are some timing issues.
>      >
>      > On our test installation which is done by a script in Jenkins we
>     always
>      > got the problem with the httpPort and sometimes also with the
>     sshPort.
>      >
>      > Regards
>      > Andre
>      >
>      >
>      >
>      > *ANDRE SCHLEGEL-TYLLA*/
>      > Teamleiter Development/
>      >
>      >
>      > *
>      >
>      > VIRTIMO AG*
>      > Behrenstraße 18  | 10117 Berlin
>      > Mobil: +49 175 67 853 74 | Fax: +49 30 55 574 40 99
>      > andre.schlegel-tylla@virtimo.de
>     <ma...@virtimo.de>
>      > <mailto:andre.schlegel-tylla@virtimo.de
>     <ma...@virtimo.de>> | www.virtimo.de
>     <http://www.virtimo.de>
>      > <http://www.virtimo.de/ <http://www.virtimo.de/>>
>      >
>      >
>      > Registergericht: AG Berlin-Charlottenburg | HRB 131281 B | Sitz der
>      > Gesellschaft: Berlin | USt-IdNr.: DE274491859
>      > Vorstand: Christoph Fuchß, Dirk Breitkreuz, Tobias Weinert |
>      > Vorsitzender des Aufsichtsrates: Prof. Dr. Stefan Stieglitz
>      >
>      >
>      > Am Fr., 28. Jan. 2022 um 08:23 Uhr schrieb Jean-Baptiste Onofré
>      > <jb@nanthrax.net <ma...@nanthrax.net> <mailto:jb@nanthrax.net
>     <ma...@nanthrax.net>>>:
>      >
>      >     Hi Andre,
>      >
>      >     do you start with no data folder ?
>      >
>      >     I just tried and it works fine for me.
>      >
>      >     ConfigAdmin service has be started before SSH (which is the
>     case by
>      >     default).
>      >
>      >     Do you use a Karaf 4.3.6 vanilla ?
>      >
>      >     Regards
>      >     JB
>      >
>      >     On 28/01/2022 07:18, Andre Schlegel-Tylla wrote:
>      >      > Hello,
>      >      >
>      >      > We are using environment variables to override the karaf ports
>      >      >
>      >   
>       (https://karaf.apache.org/manual/latest/#_environment_variables_system_properties <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties>
>      >   
>       <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties>>
>      >
>      >      >
>      >   
>       <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties>
>      >   
>       <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties>>>).
>      >
>      >      > We have some tests where we make a fresh installation with
>     some
>      >     changed
>      >      > ports. In this case we have seen port conflicts with a
>     parallel
>      >     vanilla
>      >      > installation on the same machine (ssh port and http port). It
>      >     seems that
>      >      > the override by the environment variables didn't work. After a
>      >     restart
>      >      > of the installation all was fine.
>      >      >
>      >      > I can reproduce the problem on my machine. I have
>     downloaded the
>      >      > current 4.3.6 release. Set there env vars:
>      >      >
>      >      > export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
>      >      > export ORG_APACHE_KARAF_MANAGEMENT_RMIREGISTRYPORT=11099
>      >      > export ORG_APACHE_KARAF_MANAGEMENT_RMISERVERPORT=14444
>      >      > export ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT=18181
>      >      > export
>     ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT_SECURE=18282
>      >      >
>      >      > When I start the fresh karaf (bin/karaf) the ssh port is
>     open on
>      >     8101
>      >      > and not on 18101. When I stop the karaf and start again
>     the ssh
>      >     port is
>      >      > open on 18101.
>      >      >
>      >      > Kind regards
>      >      > Andre
>      >
> 

Re: BUG: Overriding ports via environment variable don't work on first start

Posted by Andre Schlegel-Tylla <an...@virtimo.de>.
Thank you.

Should I file a Jira ticket?

Regards
Andre

Am Fr., 28. Jan. 2022 um 10:34 Uhr schrieb Jean-Baptiste Onofré <
jb@nanthrax.net>:

> Hi Andre,
>
> thanks for the update.
>
> Yeah, it seems to be a race condition where the config interceptor
> (overriding values with system properties and env variables) is started
> after some other services.
>
> Let me investigate a bit (probably finalizing interceptor start before
> features service).
>
> Regards
> JB
>
> On 28/01/2022 10:01, Andre Schlegel-Tylla wrote:
> > Hi JB,
> >
> > yes I have used Karaf 4.3.6 vanilla. I have repeated my tests by
> > deleting the data folder.
> >
> > I have repeated it again and got different results (now with deleting
> > the whole karaf and unpack the vanilla tar.gz again).
> >
> > I had used this:
> >
> > export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
> > tar -xzf apache-karaf-4.3.6.tar.gz
> > apache-karaf-4.3.6/bin/karaf
> >
> >
> > * First time all went as expected; ports have been changed
> > * Second time I got this:
> >
> >    karaf-env-test tar -xzf apache-karaf-4.3.6.tar.gz
> >    karaf-env-test apache-karaf-4.3.6/bin/karaf
> >          __ __                  ____
> >         / //_/____ __________ _/ __/
> >        / ,<  / __ `/ ___/ __ `/ /_
> >       / /| |/ /_/ / /  / /_/ / __/
> >      /_/ |_|\__,_/_/   \__,_/_/
> >
> >    Apache Karaf (4.3.6)
> >
> > Hit '<tab>' for a list of available commands
> > and '[cmd] --help' for help on a specific command.
> > Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.
> >
> > karaf@root()> Exception in thread "JMX Connector Thread
> > [service:jmx:rmi://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root
> > <http://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root>]"
> > java.lang.RuntimeException: Could not start JMX connector server
> > at
> >
> org.apache.karaf.management.ConnectorServerFactory.lambda$init$0(ConnectorServerFactory.java:438)
> > at java.base/java.lang.Thread.run(Thread.java:829)
> > Caused by: java.io.IOException: Cannot bind to URL
> > [rmi://127.0.0.1:1099/karaf-root <http://127.0.0.1:1099/karaf-root>]:
> > javax.naming.CommunicationException [Root exception is
> > java.rmi.NoSuchObjectException: no such object in table]
> > at
> >
> java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:854)
> > at
> >
> java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:501)
> > at
> >
> org.apache.karaf.management.ConnectorServerFactory.lambda$init$0(ConnectorServerFactory.java:421)
> > ... 1 more
> > Caused by: javax.naming.CommunicationException [Root exception is
> > java.rmi.NoSuchObjectException: no such object in table]
> > at
> >
> jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:162)
> > at
> >
> java.naming/com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:230)
> > at java.naming/javax.naming.InitialContext.bind(InitialContext.java:417)
> > at
> >
> java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:713)
> > at
> >
> java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:496)
> > ... 2 more
> > Caused by: java.rmi.NoSuchObjectException: no such object in table
> > at
> >
> java.rmi/sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303)
> > at
> >
> java.rmi/sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:279)
> > at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:380)
> > at
> >
> java.rmi/sun.rmi.registry.RegistryImpl_Stub.bind(RegistryImpl_Stub.java:73)
> > at
> >
> jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:156)
> > ... 6 more
> >
> > * Third time there was no JMX error, ssh port was open on 8101 not on
> > 18101 as expected. And the config result is this:
> > karaf@root()> config:list | grep Port
> >     jmxmpPort = 9999
> >     rmiRegistryPort = 11099
> >     rmiServerPort = 14444
> >     sshPort = 18101
> >
> > It seems to me that there are some timing issues.
> >
> > On our test installation which is done by a script in Jenkins we always
> > got the problem with the httpPort and sometimes also with the sshPort.
> >
> > Regards
> > Andre
> >
> >
> >
> > *ANDRE SCHLEGEL-TYLLA*/
> > Teamleiter Development/
> >
> >
> > *
> >
> > VIRTIMO AG*
> > Behrenstraße 18  | 10117 Berlin
> > Mobil: +49 175 67 853 74 | Fax: +49 30 55 574 40 99
> > andre.schlegel-tylla@virtimo.de
> > <ma...@virtimo.de> | www.virtimo.de
> > <http://www.virtimo.de/>
> >
> >
> > Registergericht: AG Berlin-Charlottenburg | HRB 131281 B | Sitz der
> > Gesellschaft: Berlin | USt-IdNr.: DE274491859
> > Vorstand: Christoph Fuchß, Dirk Breitkreuz, Tobias Weinert |
> > Vorsitzender des Aufsichtsrates: Prof. Dr. Stefan Stieglitz
> >
> >
> > Am Fr., 28. Jan. 2022 um 08:23 Uhr schrieb Jean-Baptiste Onofré
> > <jb@nanthrax.net <ma...@nanthrax.net>>:
> >
> >     Hi Andre,
> >
> >     do you start with no data folder ?
> >
> >     I just tried and it works fine for me.
> >
> >     ConfigAdmin service has be started before SSH (which is the case by
> >     default).
> >
> >     Do you use a Karaf 4.3.6 vanilla ?
> >
> >     Regards
> >     JB
> >
> >     On 28/01/2022 07:18, Andre Schlegel-Tylla wrote:
> >      > Hello,
> >      >
> >      > We are using environment variables to override the karaf ports
> >      >
> >     (
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
> >     <
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
> >
> >
> >      >
> >     <
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
> >     <
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
> >>).
> >
> >      > We have some tests where we make a fresh installation with some
> >     changed
> >      > ports. In this case we have seen port conflicts with a parallel
> >     vanilla
> >      > installation on the same machine (ssh port and http port). It
> >     seems that
> >      > the override by the environment variables didn't work. After a
> >     restart
> >      > of the installation all was fine.
> >      >
> >      > I can reproduce the problem on my machine. I have downloaded the
> >      > current 4.3.6 release. Set there env vars:
> >      >
> >      > export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
> >      > export ORG_APACHE_KARAF_MANAGEMENT_RMIREGISTRYPORT=11099
> >      > export ORG_APACHE_KARAF_MANAGEMENT_RMISERVERPORT=14444
> >      > export ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT=18181
> >      > export ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT_SECURE=18282
> >      >
> >      > When I start the fresh karaf (bin/karaf) the ssh port is open on
> >     8101
> >      > and not on 18101. When I stop the karaf and start again the ssh
> >     port is
> >      > open on 18101.
> >      >
> >      > Kind regards
> >      > Andre
> >
>

Re: BUG: Overriding ports via environment variable don't work on first start

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Andre,

thanks for the update.

Yeah, it seems to be a race condition where the config interceptor 
(overriding values with system properties and env variables) is started 
after some other services.

Let me investigate a bit (probably finalizing interceptor start before 
features service).

Regards
JB

On 28/01/2022 10:01, Andre Schlegel-Tylla wrote:
> Hi JB,
> 
> yes I have used Karaf 4.3.6 vanilla. I have repeated my tests by 
> deleting the data folder.
> 
> I have repeated it again and got different results (now with deleting 
> the whole karaf and unpack the vanilla tar.gz again).
> 
> I had used this:
> 
> export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
> tar -xzf apache-karaf-4.3.6.tar.gz
> apache-karaf-4.3.6/bin/karaf
> 
> 
> * First time all went as expected; ports have been changed
> * Second time I got this:
> 
>    karaf-env-test tar -xzf apache-karaf-4.3.6.tar.gz
>    karaf-env-test apache-karaf-4.3.6/bin/karaf
>          __ __                  ____
>         / //_/____ __________ _/ __/
>        / ,<  / __ `/ ___/ __ `/ /_
>       / /| |/ /_/ / /  / /_/ / __/
>      /_/ |_|\__,_/_/   \__,_/_/
> 
>    Apache Karaf (4.3.6)
> 
> Hit '<tab>' for a list of available commands
> and '[cmd] --help' for help on a specific command.
> Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.
> 
> karaf@root()> Exception in thread "JMX Connector Thread 
> [service:jmx:rmi://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root 
> <http://127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root>]" 
> java.lang.RuntimeException: Could not start JMX connector server
> at 
> org.apache.karaf.management.ConnectorServerFactory.lambda$init$0(ConnectorServerFactory.java:438)
> at java.base/java.lang.Thread.run(Thread.java:829)
> Caused by: java.io.IOException: Cannot bind to URL 
> [rmi://127.0.0.1:1099/karaf-root <http://127.0.0.1:1099/karaf-root>]: 
> javax.naming.CommunicationException [Root exception is 
> java.rmi.NoSuchObjectException: no such object in table]
> at 
> java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:854)
> at 
> java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:501)
> at 
> org.apache.karaf.management.ConnectorServerFactory.lambda$init$0(ConnectorServerFactory.java:421)
> ... 1 more
> Caused by: javax.naming.CommunicationException [Root exception is 
> java.rmi.NoSuchObjectException: no such object in table]
> at 
> jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:162)
> at 
> java.naming/com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:230)
> at java.naming/javax.naming.InitialContext.bind(InitialContext.java:417)
> at 
> java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:713)
> at 
> java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:496)
> ... 2 more
> Caused by: java.rmi.NoSuchObjectException: no such object in table
> at 
> java.rmi/sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303)
> at 
> java.rmi/sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:279)
> at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:380)
> at 
> java.rmi/sun.rmi.registry.RegistryImpl_Stub.bind(RegistryImpl_Stub.java:73)
> at 
> jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:156)
> ... 6 more
> 
> * Third time there was no JMX error, ssh port was open on 8101 not on 
> 18101 as expected. And the config result is this:
> karaf@root()> config:list | grep Port
>     jmxmpPort = 9999
>     rmiRegistryPort = 11099
>     rmiServerPort = 14444
>     sshPort = 18101
> 
> It seems to me that there are some timing issues.
> 
> On our test installation which is done by a script in Jenkins we always 
> got the problem with the httpPort and sometimes also with the sshPort.
> 
> Regards
> Andre
> 
> 
> 
> *ANDRE SCHLEGEL-TYLLA*/
> Teamleiter Development/
> 
> 
> *
> 
> VIRTIMO AG*
> Behrenstraße 18  | 10117 Berlin
> Mobil: +49 175 67 853 74 | Fax: +49 30 55 574 40 99
> andre.schlegel-tylla@virtimo.de 
> <ma...@virtimo.de> | www.virtimo.de 
> <http://www.virtimo.de/>
> 
> 
> Registergericht: AG Berlin-Charlottenburg | HRB 131281 B | Sitz der 
> Gesellschaft: Berlin | USt-IdNr.: DE274491859
> Vorstand: Christoph Fuchß, Dirk Breitkreuz, Tobias Weinert | 
> Vorsitzender des Aufsichtsrates: Prof. Dr. Stefan Stieglitz
> 
> 
> Am Fr., 28. Jan. 2022 um 08:23 Uhr schrieb Jean-Baptiste Onofré 
> <jb@nanthrax.net <ma...@nanthrax.net>>:
> 
>     Hi Andre,
> 
>     do you start with no data folder ?
> 
>     I just tried and it works fine for me.
> 
>     ConfigAdmin service has be started before SSH (which is the case by
>     default).
> 
>     Do you use a Karaf 4.3.6 vanilla ?
> 
>     Regards
>     JB
> 
>     On 28/01/2022 07:18, Andre Schlegel-Tylla wrote:
>      > Hello,
>      >
>      > We are using environment variables to override the karaf ports
>      >
>     (https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
>     <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties>
> 
>      >
>     <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
>     <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties>>).
> 
>      > We have some tests where we make a fresh installation with some
>     changed
>      > ports. In this case we have seen port conflicts with a parallel
>     vanilla
>      > installation on the same machine (ssh port and http port). It
>     seems that
>      > the override by the environment variables didn't work. After a
>     restart
>      > of the installation all was fine.
>      >
>      > I can reproduce the problem on my machine. I have downloaded the
>      > current 4.3.6 release. Set there env vars:
>      >
>      > export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
>      > export ORG_APACHE_KARAF_MANAGEMENT_RMIREGISTRYPORT=11099
>      > export ORG_APACHE_KARAF_MANAGEMENT_RMISERVERPORT=14444
>      > export ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT=18181
>      > export ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT_SECURE=18282
>      >
>      > When I start the fresh karaf (bin/karaf) the ssh port is open on
>     8101
>      > and not on 18101. When I stop the karaf and start again the ssh
>     port is
>      > open on 18101.
>      >
>      > Kind regards
>      > Andre
> 

Re: BUG: Overriding ports via environment variable don't work on first start

Posted by Andre Schlegel-Tylla <an...@virtimo.de>.
Hi JB,

yes I have used Karaf 4.3.6 vanilla. I have repeated my tests by deleting
the data folder.

I have repeated it again and got different results (now with deleting the
whole karaf and unpack the vanilla tar.gz again).

I had used this:

export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
tar -xzf apache-karaf-4.3.6.tar.gz
apache-karaf-4.3.6/bin/karaf


* First time all went as expected; ports have been changed
* Second time I got this:

  karaf-env-test tar -xzf apache-karaf-4.3.6.tar.gz
  karaf-env-test apache-karaf-4.3.6/bin/karaf
        __ __                  ____
       / //_/____ __________ _/ __/
      / ,<  / __ `/ ___/ __ `/ /_
     / /| |/ /_/ / /  / /_/ / __/
    /_/ |_|\__,_/_/   \__,_/_/

  Apache Karaf (4.3.6)

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.

karaf@root()> Exception in thread "JMX Connector Thread [service:jmx:rmi://
127.0.0.1:44444/jndi/rmi://127.0.0.1:1099/karaf-root]"
java.lang.RuntimeException: Could not start JMX connector server
at
org.apache.karaf.management.ConnectorServerFactory.lambda$init$0(ConnectorServerFactory.java:438)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.io.IOException: Cannot bind to URL [rmi://
127.0.0.1:1099/karaf-root]: javax.naming.CommunicationException [Root
exception is java.rmi.NoSuchObjectException: no such object in table]
at
java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.newIOException(RMIConnectorServer.java:854)
at
java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:501)
at
org.apache.karaf.management.ConnectorServerFactory.lambda$init$0(ConnectorServerFactory.java:421)
... 1 more
Caused by: javax.naming.CommunicationException [Root exception is
java.rmi.NoSuchObjectException: no such object in table]
at
jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:162)
at
java.naming/com.sun.jndi.toolkit.url.GenericURLContext.bind(GenericURLContext.java:230)
at java.naming/javax.naming.InitialContext.bind(InitialContext.java:417)
at
java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.bind(RMIConnectorServer.java:713)
at
java.management.rmi/javax.management.remote.rmi.RMIConnectorServer.start(RMIConnectorServer.java:496)
... 2 more
Caused by: java.rmi.NoSuchObjectException: no such object in table
at
java.rmi/sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303)
at
java.rmi/sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:279)
at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:380)
at
java.rmi/sun.rmi.registry.RegistryImpl_Stub.bind(RegistryImpl_Stub.java:73)
at
jdk.naming.rmi/com.sun.jndi.rmi.registry.RegistryContext.bind(RegistryContext.java:156)
... 6 more

* Third time there was no JMX error, ssh port was open on 8101 not on 18101
as expected. And the config result is this:
karaf@root()> config:list | grep Port
   jmxmpPort = 9999
   rmiRegistryPort = 11099
   rmiServerPort = 14444
   sshPort = 18101

It seems to me that there are some timing issues.

On our test installation which is done by a script in Jenkins we always got
the problem with the httpPort and sometimes also with the sshPort.

Regards
Andre



*ANDRE SCHLEGEL-TYLLA*
*Teamleiter Development*




*VIRTIMO AG*
Behrenstraße 18  | 10117 Berlin
Mobil: +49 175 67 853 74 | Fax: +49 30 55 574 40 99
andre.schlegel-tylla@virtimo.de | www.virtimo.de


Registergericht: AG Berlin-Charlottenburg | HRB 131281 B | Sitz der
Gesellschaft: Berlin | USt-IdNr.: DE274491859
Vorstand: Christoph Fuchß, Dirk Breitkreuz, Tobias Weinert | Vorsitzender
des Aufsichtsrates: Prof. Dr. Stefan Stieglitz


Am Fr., 28. Jan. 2022 um 08:23 Uhr schrieb Jean-Baptiste Onofré <
jb@nanthrax.net>:

> Hi Andre,
>
> do you start with no data folder ?
>
> I just tried and it works fine for me.
>
> ConfigAdmin service has be started before SSH (which is the case by
> default).
>
> Do you use a Karaf 4.3.6 vanilla ?
>
> Regards
> JB
>
> On 28/01/2022 07:18, Andre Schlegel-Tylla wrote:
> > Hello,
> >
> > We are using environment variables to override the karaf ports
> > (
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties
> > <
> https://karaf.apache.org/manual/latest/#_environment_variables_system_properties>).
>
> > We have some tests where we make a fresh installation with some changed
> > ports. In this case we have seen port conflicts with a parallel vanilla
> > installation on the same machine (ssh port and http port). It seems that
> > the override by the environment variables didn't work. After a restart
> > of the installation all was fine.
> >
> > I can reproduce the problem on my machine. I have downloaded the
> > current 4.3.6 release. Set there env vars:
> >
> > export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
> > export ORG_APACHE_KARAF_MANAGEMENT_RMIREGISTRYPORT=11099
> > export ORG_APACHE_KARAF_MANAGEMENT_RMISERVERPORT=14444
> > export ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT=18181
> > export ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT_SECURE=18282
> >
> > When I start the fresh karaf (bin/karaf) the ssh port is open on 8101
> > and not on 18101. When I stop the karaf and start again the ssh port is
> > open on 18101.
> >
> > Kind regards
> > Andre
>

Re: BUG: Overriding ports via environment variable don't work on first start

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Andre,

do you start with no data folder ?

I just tried and it works fine for me.

ConfigAdmin service has be started before SSH (which is the case by 
default).

Do you use a Karaf 4.3.6 vanilla ?

Regards
JB

On 28/01/2022 07:18, Andre Schlegel-Tylla wrote:
> Hello,
> 
> We are using environment variables to override the karaf ports 
> (https://karaf.apache.org/manual/latest/#_environment_variables_system_properties 
> <https://karaf.apache.org/manual/latest/#_environment_variables_system_properties>). 
> We have some tests where we make a fresh installation with some changed 
> ports. In this case we have seen port conflicts with a parallel vanilla 
> installation on the same machine (ssh port and http port). It seems that 
> the override by the environment variables didn't work. After a restart 
> of the installation all was fine.
> 
> I can reproduce the problem on my machine. I have downloaded the 
> current 4.3.6 release. Set there env vars:
> 
> export ORG_APACHE_KARAF_SHELL_SSHPORT=18101
> export ORG_APACHE_KARAF_MANAGEMENT_RMIREGISTRYPORT=11099
> export ORG_APACHE_KARAF_MANAGEMENT_RMISERVERPORT=14444
> export ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT=18181
> export ORG_OPS4J_PAX_WEB_ORG_OSGI_SERVICE_HTTP_PORT_SECURE=18282
> 
> When I start the fresh karaf (bin/karaf) the ssh port is open on 8101 
> and not on 18101. When I stop the karaf and start again the ssh port is 
> open on 18101.
> 
> Kind regards
> Andre