Two servers: bind exception 1099 when another is trying to start - java

I have configured two servers and one active mq server.
One server will send a JMS message and the Other server will receive the JMS messages from the active mq server.
Usually we will start active mq server and the servers one by one.
Now one of the server get's started successfully where as the other throws bind exception with 1099 as port already bind.
I have verified none of the process uses the port 1099.
Need a workaround if solution is not possible.
Exception stack trace
[Apr 10 09:58:37] [/] WARN org.apache.activemq.broker.jmx.ManagementContext
(JCLLoggerAdapter.java:359) - Failed to start jmx connector: Cannot bind to URL
[rmi://localhost:1099/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root
exception is java.rmi.AlreadyBoundException: jmxrmi]
[Apr 10 09:58:37] [/] WARN org.apache.activemq.broker.jmx.ManagementContext
(JCLLoggerAdapter.java:359) - Failed to start jmx connector: Cannot bind to URL
[rmi://localhost:1099/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root
exception is java.rmi.AlreadyBoundException: jmxrmi]
[Apr 10 09:58:37] [/] DEBUG org.apache.activemq.broker.jmx.ManagementContext
(JCLLoggerAdapter.java:245) - Reason for failed jms connector start
java.io.IOException: Cannot bind to URL [rmi://localhost:1099/jmxrmi]:
javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is
java.rmi.AlreadyBoundException: jmxrmi]
at
Thanks.

As described by the provided stacktrace, both server have Remote JMX enabled on the same port. Use the -Dcom.sun.management.jmxremote.port=portNum option at the JVM level to tune the JMX port, or purely disable Remote JMX by removing the -Dcom.sun.management.jmxremote option. These options are usually located in ActiveMQ startup scripts.

Related

Java EJB Client connection via SSL port

My requirement is to connect an application deployed in weblogic server, i will use a shell script to invoke a java EJB client residing in the same server but i need to use via SSL port.
When i try connecting with non-ssl port the connection is established but when SSL port is used im getting the below error:
"javax.namin.CommunicationException: Failed to initialize JNDI context, tried 2 time or times, the interval of each time is 0ms.
[Login failed for an unknown reason:P] [Root exception is weblogic.socket.UnrecoverableConnectException: [Login faile dfor an unknown reason:P]
Current java client arguments doesnot include SSL parameters, please help on this how do i achieve this.

Activemq embedded broker Error when trying to start

ERROR org.apache.activemq.broker.BrokerService - Failed to start Apache ActiveMQ ([localhost, null], java.io.IOException: org/apache/activemq/store/NoLocalSubscriptionAware)
INFO org.apache.activemq.broker.BrokerService - Apache ActiveMQ 5.9.1 (localhost, null) is shutting down
INFO org.apache.activemq.broker.TransportConnector - Connector tcp://localhost:61616 stopped
WARN org.apache.activemq.broker.jmx.ManagementContext - Failed to start JMX connector Cannot bind to URL [rmi://localhost:1099/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException: jmxrmi]. Will restart management to re-create JMX connector, trying to remedy this issue.
The code I am trying to use is
BrokerService broker = new BrokerService();
TransportConnector connector = new TransportConnector();
connector.setUri(new URI("tcp://localhost:61616"));
broker.addConnector(connector);
broker.start();
I am getting exception at start() method. I am deploying this on server not in my computer.
It's quite hard to say what is wrong given the limited information but one thing I'd check is that there isn't already a broker running on that server as it looks like something is at least sitting on the JMX port already. You could check in the broker log to see if the broker logs any additional information on the error.

Connection Refused localhost:9999 java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException

I'm using Datadog to collect metrics from Kafka running on my localhost.
When I run the -info command on my Datadog agent this is the error I get for Kafka. Any ideas whats causing this?
kafka
-----
- instance #kafka-localhost-9999 [ERROR]: 'Cannot connect to instance localhost:9999 java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: \n\tjava.net.ConnectException: Connection refused]' collected 0 metrics
- Collected 0 metrics, 0 events & 0 service checks
It looks like that you have not set your JMX_PORT for kafka from where your datadog agent can listen information abouot the metrics.
Restart your Kafka with the following additional key/value pair parameter:
'JMX_PORT=9999'
$ JMX_PORT=9999 ./kafka-server-start.sh ../config/server.properties
This error essentially means that the Datadog Agent is unable to connect to the Kafka instance to retrieve metrics from the exposed mBeans over the RMI protocol. This error can be resolved by including the following JVM (Java Virtual Machine) arguments when starting the Kafka instance (required for Producer, Consumer, and Broker as they are all separate Java instances)
please
Please read this article

Java Lwm2m Bootstrap Server

I would like to connect one LwM2M client to multiple servers LwM2M by bootstrap server. I'm using Leshan (LwM2M implementation in Java).
So I'm using Lwm2m demo from github.com/Eclipse/Leshan. I run the server demo, the bootstrap server demo, and the client demo. I want to register the client in the server User Interface by using bootstrap server (I entered the client endpoint, the server URI, no security mode).
When I run them both, the client is not registered and I have this message in the terminal matching the client :
[bootstrap=Bootstrap Server [uri=coap://192.168.1.100:5683],
deviceMangements={123=DM Server
[uri=coap://192.168.1.85:8081,lifetime=20, binding=U]}].
[2016-07-05 12:48:17,684 INFO RegistrationEngine] Trying to register to
coap://192.168.1.85:8081 ...
[2016-07-05 12:49:39,113 ERROR RegistrationEngine] Registration failed: Timeout.
[2016-07-05 12:49:39,116 INFO RegistrationEngine] Unable to connect to any server,
next retry in 600s ...
How can I fix this?
coap://192.168.1.85:8081 doesn't sound like a standard CoAP port which is more like 5683 (or 5684 for DTLS)
First you better check your configuration such as IP Address and Port.
Client should point to bootstrap server IP and port. Bootstrap server configure client to correct server.
According to your terminal message, lifetime is only 20s. You can try to extend the life time to 180s (3mins) in Bootstrap.
[bootstrap=Bootstrap Server [uri=coap://192.168.1.100:5683],
deviceMangements={123=DM Server
[uri=coap://192.168.1.85:8081,lifetime=20, binding=U]}].
[2016-07-05 12:48:17,684 INFO RegistrationEngine] Trying to register
to coap://192.168.1.85:8081 ... [2016-07-05 12:49:39,113 ERROR
RegistrationEngine] Registration failed: Timeout. [2016-07-05
12:49:39,116 INFO RegistrationEngine] Unable to connect to any server,
next retry in 600s ...

post message to a remote JMS provider

I want to be able to send messages to a remote JBoss server (JBoss MQ).
I can do it for a local one but i'm stuck when trying with a remote one.
can anyone explain to me how to do it ?
are there any specific steps to take ?
[what i've tried so far]
I need to send a message to a remote server's queue (running "JBoss MQ") so that it can process the message and act on it.
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
properties.put(Context.PROVIDER_URL, "jnp://192.168.131.129:1299");
InitialContext jndiContext = new InitialContext(properties);
//[2] Look up connection factory and queue.
ConnectionFactory connectionFactory = (ConnectionFactory)jndiContext.lookup("UIL2XAConnectionFactory");
Queue queue = (Queue)jndiContext.lookup("Queue/DataTransferQueue");
but I get an exception when running the above code :
(even though, I can ping the remote server).
javax.naming.CommunicationException: Could not obtain connection to any of these urls: 192.168.1.131.129:1299 and
discovery failed with error: javax.naming.CommunicationException:
Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
[Root exception is javax.naming.CommunicationException: Failed to connect to server 192.168.1.131.129:1299
Is there anything special to do to connect to a remote queue ?
Have you verified that you can connect to that remote host and port, i.e. telnet 192.168.131.129 1299? You might have a firewall that's blocking some traffic but allowing pings.
OK, so after trying a lot, I finally found out what the problem was :
I didn't start JBoss on the remote server in a way it could accept remote connections. by default, JBoss starts allowing only local connections.
so, I restarted it with this argument : -b 0.0.0.0 and it works fine now.
Thanks for your help and support.

Categories