Stop jboss 5.x from shell script - java

I am writing some small shell script utility which automates deployment process. I ready many links related to command for shutting down the jboss server in linux so that I can shutdown the server from my utility.
Read some links which will tell how to do it in jboss 7 or later but not in old jboss versions like 5.x. One such is
"$JBOSS_HOME/bin/jboss-cli.sh" --connect command=:shutdown
I want to shutdown the jboss 5.2 version from my shell script?
Edit: Jboss 5 version has shutdown.sh in the bin folder. But I am getting the below exception when I say
sh shutdown.sh -S
[john#mymachine bin]$ sh shutdown.sh -S
Exception in thread "main" javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost/127.0.0.1:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost/127.0.0.1:1099 [Root exception is java.net.ConnectException: Connection refused]]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1851)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:720)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:713)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.jboss.Shutdown.main(Shutdown.java:225)
Caused by: javax.naming.CommunicationException: Failed to connect to server localhost/127.0.0.1:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost/127.0.0.1:1099 [Root exception is java.net.ConnectException: Connection refused]]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:362)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:287)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1821)
... 4 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost/127.0.0.1:1099 [Root exception is java.net.ConnectException: Connection refused]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:332)
... 6 more
Caused by: java.net.ConnectException: Connection refused
Any idea ??
Regards

JBoss 5 has a shutdown.sh, from the docs:
usage: shutdown [options] <operation>
options:
-h, --help Show this help message (default)
-D<name>[=<value>] Set a system property
-- Stop processing options
-s, --server=<url> Specify the JNDI URL of the remote server
-n, --serverName=<url> Specify the JMX name of the ServerImpl
-a, --adapter=<name> Specify JNDI name of the MBeanServerConnection to use
-u, --user=<name> Specify the username for authentication
-p, --password=<name> Specify the password for authentication
operations:
-S, --shutdown Shutdown the server
-e, --exit=<code> Force the VM to exit with a status code
-H, --halt=<code> Force the VM to halt with a status code

I believe you should check your JBoss configuration and look for the JNP port. Probably you are running with a non default port and that's why you receive the connection refused exception.
Have a look at the file server/default/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml.
Reference https://community.jboss.org/wiki/ConfigurePorts

If you have on ubuntu with default visual interface, open the "System Monitor", change to tab Process and filter by "jboss", it's will result in a java process, kill then.

Related

Cannot connect to Wildfly

I have just installed Wildfly and I tried to connect it :
\wildfly-11.0.0.Final\bin>jboss-cli.bat -c
But gives me follow error :
Failed to connect to the controller: The controller is not available
at localhost:9990: java.net.ConnectException: WFLYPRT0053: Could not
connect to remote+http://localhost:9990. The connection failed:
WFLYPRT0053: Could not connect to remote+http://localhost:9990. The
connection failed: Connection refused: no further information
I tried a lot of solutions but it's not working for me.
With Widlfly running, i.e. (standalone.bat), use the --controller option to define where it is:
jboss-cli.bat -c --controller=localhost:9990
Got the same error on wildfly version 16
Error
Failed to connect to the controller: The controller is not available at localhost:: java.net.ConnectException: WFLYPRT0053: Could not connect to remote+http://localhost:. The connection failed: WFLYPRT0053: Could not connect to remote+http://localhost:. The connection failed: Connection refused
And following done and resolved successfully
Step 01
Comment (or you can remove) following line from /bin/jboss-cli.xml
default-protocol use-legacy-override="true">remote+https</default-protocol
Correct protocol Ex:
<default-protocol use-legacy-override="true">remote+http</default-protocol>
<!-- The default controller to connect to when 'connect' command is executed w/o arguments -->
<default-controller>
<protocol>remote+http</protocol>
<host>localhost</host>
<port>9990</port>
</default-controller>
Step 02
In my case i have alredy created a Administrative user hence, I have statup the CLI with following commnad
./jboss-cli.sh --user="<user>" --password="<password>" --controller=remote+http:<your IP>:<port> --connect
Example :
./jboss-cli.sh --user="Admin" --password="Password" --controller=remote+http://19.199.115.172:9990 --connect
Make sure your wildfly is up and running. If you have used different port for the admin console it should be added .
Jboss must be running while doing this. I was trying to do this while my jboss was not up n running... then i got this error message. So boot up jboss and try again.
The most common case is that there is a mismatch between the default controller defined in jboss-cli.xml and the management port, configured in the standalone.xml/domain.xml. Out of the box, they should converge on localhost:9990. Therefore, verify if you changed any of the two files. Other than that, it could be a firewall/network issue.
See also: Cannot connect to WildFly with CLI

Websphere MQ client deploy to Jboss Fuse

Error appear when MQConnectionFactory try to create connection.
At the same time I'm able to send\receive message from standalone application.
jboss stack trace.
Caused by: com.ibm.mq.MQException: JMSCMQ0001: JMSCMQ0001, 2, MQCC_FAILED, 2195, MQRC_UNEXPECTED_ERROR
at com.ibm.msg.client.wmq.common.internal.Reason.createException(Reason.java:209)
... 24 more
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2195;AMQ9204: Connection to host 'hostname(1450)' rejected. [1=com.ibm.mq.jmqi.JmqiException[CC=2;RC=2195],3=hostname(1450),5=WMQThreadPool.enqueue]
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:2053)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1226)
at com.ibm.msg.client.wmq.internal.WMQConnection.<init>(WMQConnection.java:346)
... 23 more
Caused by: com.ibm.mq.jmqi.JmqiException: CC=2;RC=2195
at com.ibm.msg.client.wmq.common.internal.WMQThreadPool.enqueue(WMQThreadPool.java:109)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.setUpAsyncMode(RemoteConnection.java:1554)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.initSess(RemoteConnection.java:1348)
at com.ibm.mq.jmqi.remote.impl.RemoteConnection.connect(RemoteConnection.java:727)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSessionFromNewConnection(RemoteConnectionSpecification.java:400)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionSpecification.getSession(RemoteConnectionSpecification.java:299)
at com.ibm.mq.jmqi.remote.impl.RemoteConnectionPool.getSession(RemoteConnectionPool.java:164)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiConnect(RemoteFAP.java:1598)
... 25 more
Caused by: com.ibm.msg.client.commonservices.CSIException: JMSCS0002
at com.ibm.msg.client.commonservices.workqueue.PIWorkQueueManager.enqueueItem(PIWorkQueueManager.java:67)
at com.ibm.msg.client.commonservices.workqueue.WorkQueueManager.enqueue(WorkQueueManager.java:225)
at com.ibm.msg.client.commonservices.workqueue.WorkQueueManager.enqueue(WorkQueueManager.java:194)
at com.ibm.msg.client.wmq.common.internal.WMQThreadPool.enqueue(WMQThreadPool.java:91)
Query manager log:
----- amqrmrsa.c : 898 --------------------------------------------------------
24.03.2015 17:09:06 - Process(21296.261) User(mqm) Program(amqrmppa)
Host(localserver-name) Installation(Installation1)
VRMF(7.5.0.2) QMgr(manager-name)
AMQ9209: Connection to host 'jboss-short-hostname (jboss-ip)' for channel
'channel-name' closed.
EXPLANATION:
An error occurred receiving data from 'jboss-short-hostname (jboss-ip)' over TCP/IP.
The connection to the remote host has unexpectedly terminated.
The channel name is 'channel-name'; in some cases it cannot be determined and so
is shown as '????'.
ACTION:
Tell the systems administrator.
----- amqccita.c : 3843 -------------------------------------------------------
24.03.2015 17:09:06 - Process(21296.261) User(mqm) Program(amqrmppa)
Host(localserver-name) Installation(Installation1)
VRMF(7.5.0.2) QMgr(manager-name)
AMQ9999: Channel 'channel-name' to host 'jboss-short-hostname (jboss-ip)' ended
abnormally.
EXPLANATION:
The channel program running under process ID 21296 for channel 'channel-name'
ended abnormally. The host name is 'jboss-short-hostname (jboss-ip)'; in some cases
the host name cannot be determined and so is shown as '????'.
ACTION:
Look at previous error messages for the channel program in the error logs to
determine the cause of the failure. Note that this message can be excluded
completely or suppressed by tuning the "ExcludeMessage" or "SuppressMessage"
attributes under the "QMErrorLog" stanza in qm.ini. Further information can be
found in the System Administration Guide.
----- amqrmrsa.c : 898 --------------------------------------------------------
About my test stand:
Fuse Fabric (7.2.0.redhat-024)
IBM WebSphere MQ Version : 7.5.0.2
Java 1.7
Server WebSphere MQ and jboss installed on different servers.
I installed as features following jars:
com.ibm.mq.osgi.directip_7.5.0.2.jar
com.ibm.mq.osgi.java_7.5.0.2.jar
com.ibm.msg.client.osgi.commonservices.j2se_7.5.0.2.jar
com.ibm.msg.client.osgi.jms.prereq_7.5.0.2.jar
com.ibm.msg.client.osgi.jms_7.5.0.2.jar
com.ibm.msg.client.osgi.nls_7.5.0.2.jar
com.ibm.msg.client.osgi.wmq.nls_7.5.0.2.jar
com.ibm.msg.client.osgi.wmq.prereq_7.5.0.2.jar
com.ibm.msg.client.osgi.wmq_7.5.0.2.jar
My code snippet:
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
// Config
cf.setHostName("hostname");
cf.setPort("port");
cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
cf.setChannel("channel-name");
cf.setQueueManager("manager-name");
MQQueueConnection connectionDpc = (MQQueueConnection) cf.createQueueConnection("user", "pass");
Please try using the IBM MQ 7.5.0.6 (or later) OSGI bundles. The 7.5.0.2 bundles are known to have this issue.

What is wrong with this Java code for a RMI JMX connection?

What is wrong with this Java code for a RMI JMX connection? I am clearly not trying to connect to localhost but the error implies that I am. On the remote server, I enabled JMX options on port 1099 (no authentication).
Here is my groovy script:
import javax.management.remote.*;
JMXServiceURL u =
new JMXServiceURL("service:jmx:rmi://10.222.244.185:9999/jndi/rmi://10.222.244.185:1099/jmxrmi");
JMXConnector c = JMXConnectorFactory.connect(u);
And here is the error I get:
C:\Temp>groovy jmx.gv
Caught: java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Conn
ection refused to host: 10.222.244.185; nested exception is:
java.net.ConnectException: Connection refused: connect]
java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection r
efused to host: 10.222.244.185; nested exception is:
java.net.ConnectException: Connection refused: connect]
at jmx.run(jmx.gv:5)
Caused by: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 10.222.244.185; nested except
ion is:
java.net.ConnectException: Connection refused: connect]
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:101)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
... 1 more
Caused by: java.rmi.ConnectException: Connection refused to host: 10.222.244.185; nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:97)
... 2 more
Caused by: java.net.ConnectException: Connection refused: connect
... 3 more
This is the famous java.rmi.server.hostname problem. Usually caused by /etc/hosts misconfiguration in some Linux distributions. 127.0.0.1 should map to localhost, and your real hostname should map to your real IP address. See item A.1 in the RMI FAQ for another solution.
EDIT: Now that you've edited the IP addresses in your question, it is more probable that the JMX service you are looking up simply isn't running at that IP address.
Somehow your code trying to connect to 127.0.0.1 instead of remote
Connection refused to host: 127.0.0.1; nested exception is:
I suspect the code you are executing is different from the code you have in question. Make sure what ever the code you have in question is being executed.
This is more of configurtion issue where you have to explicitly mention how are you going to access the stubs. Try setting jmxremote options through JVM args. Following options might resolve your issue. I tried same for my own project.
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8091
-Dcom.sun.management.jmxremote.rmi.port=8091
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

Can't connect to weblogic server remotely using JConsole

I need to monitor a weblogic server running on a remote machine using JConsole. Just for now, while I'm trying I'm testing everything on my machine, that is I'm trying to make it work remotely on my machine, when this works I will make the necessary changes on the server but as the application on the server is being used for other users I'm not able to do the changes and stop/start the server very often. So, I'm using my pc as the server and to connect "remotely" using JConsole.
Environment: both, my pc and the server are running with WL 10.3; the server is running with Java Sun JDK 1.6.0_27 and Solaris OS, and my pc is running with Java Sun JDK 1.6.0_26 and Ubuntu OS.
I'm able to connect Locally, running JConsole and clicking on the weblogic process.
The application deployment is pretty big, it runs a few scripts. When the domain of weblogic is created I set the following properties:
java -classpath ${CLASSPATH} ${MY_OPTS} -Dweblogic.management.username=${ADMIN_USER} \
-Dweblogic.management.password=${ADMIN_PASSWD} -Dweblogic.Domain=${MY_DOMAIN} \
-Dweblogic.Name=${MY_SERVER} -Dweblogic.ListenPort=${MY_PORT} \
-Dweblogic.RootDirectory=${MY_DOMAIN_HOME}/${MY_DOMAIN} \
-Dcom.sun.management.jmxremote.port=22222 \
-Dcom.sun.management.jmxremote.authenticate=true \
-Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.password.file=/home/MY_USER/jmxremote.password \
-Dcom.sun.management.jmxremote.access.file=/home/MY_USER/jmxremote.access \
-Dweblogic.management.GenerateDefaultConfig=true weblogic.Server &
I also add at some point this property -Djava.rmi.server.hostname= --> I'm not using neither localhost nor 127.0.0.1, but it made no difference
Then, I run jconsole -debug from console and try to connect with the remote option using the following service url (I try different one):
service:jmx:rmi:///jndi/rmi://127.0.0.1:22222/jmxrmi
service:jmx:rmi:///jndi/rmi://<my_ip>:22222/jmxrmi
service:jmx:rmi://127.0.0.1:22222/jndi/rmi://127.0.0.1:1099/
1099 is the port where rmiregistry runs, but I have to start it manually with rmiregistry &, otherwise that port is not listening.
While the application is running I run netstat command, though I see ports 8080, 8081 (SSL port) and the port of my administration console (which it is not the default 7001) I don't see the port 22222 listening, and I think I should, right?
I've even add the following at weblogic.policy:
grant {
permission java.net.SocketPermission
"<my_ip>:1024-65535", "connect,resolve";
};
In the console while the application is deploying I see:
Connector Server Address = service:jmx:iiop://<my_ip>:8080 /jndi/weblogic.management.mbeanservers.runtime
Connector Server Address = service:jmx:iiop://:8080/jndi/weblogic.management.mbeanservers.edit
Connector Server Address = service:jmx:rmi://127.0.0.1/stub/rO0ABXNyAC5qYXZheC5tYW5hZ2VtZW50LnJlbW90ZS5ybWkuUk1JU2VydmVySW1wbF9TdHViAAAAAAAAAAICAAB4cgAaamF2YS5ybWkuc2VydmVyLlJlbW90ZVN0dWLp/tzJi+FlGgIAAHhyABxqYXZhLnJtaS5zZXJ2ZXIuUmVtb3RlT2JqZWN002G0kQxhMx4DAAB4cHc0AAtVbmljYXN0UmVmMgAACTEyNy4wLjEuMQAAxMelHYZki5P74FdoVWYAAAEzsm1U1oACAHg=
Conector JMX ready in: service:jmx:rmi:///jndi/rmi://usuario-System-Product-Name:22222/jmxrmi
I try these ones too but unsuccessfully.
The only way I'm able to connect is if I first access locally using the pid, then in console I get a service url similar to the one I get in the logs:
service:jmx:rmi://127.0.0.1/stub/rO0ABXNyAC5qYXZheC5tYW5hZ2VtZW50LnJlbW90ZS5ybWkuUk1JU2VydmVySW1wbF9TdHViAAAAAAAAAAICAAB4cgAaamF2YS5ybWkuc2VydmVyLlJlbW90ZVN0dWLp/tzJi+FlGgIAAHhyABxqYXZhLnJtaS5zZXJ2ZXIuUmVtb3RlT2JqZWN002G0kQxhMx4DAAB4cHc0AAtVbmljYXN0UmVmMgAACTEyNy4wLjEuMQAAgDBSpbjGvIybrBekgUYAAAEzsm9/YIASAHg=
Using this url in the remote section I'm able to connect, it is similar but not the same to the one logged, which btw doesn't work.
The errors I get in JConsole console when using -debug are:
Some of the errors I got in the console are, they are not random.. I mean, different errors while I tried different urls, running /not running rmiregistry manually, etc.:
Failed to retrieve RMIServer stub: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
11/11/2011 09:46:46 RMIConnector connect
MÁS FINA: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://127.0.0.1:22222/jmxrmi] connecting...
11/11/2011 09:46:46 RMIConnector connect
MÁS FINA: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://127.0.0.1:22222/jmxrmi] finding stub...
11/11/2011 09:46:46 RMIConnector connect
MÁS FINA: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://127.0.0.1:22222/jmxrmi] Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException:
non-JRMP server at remote endpoint]
Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: non-JRMP server at remote endpoint]
java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: non-JRMP server at remote endpoint]
17/11/2011 12:08:28 RMIConnector connect
MÁS FINA: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://<my_ip>:22222/jmxrmi] connecting...
17/11/2011 12:08:28 RMIConnector connect
MÁS FINA: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://<my_ip>:22222/jmxrmi] finding stub...
17/11/2011 12:08:28 RMIConnector connect
MÁS FINA: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://<my_ip>:22222/jmxrmi] Failed to retrieve RMIServer stub: javax.naming.NameNotFoundException: jmxrmi
java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.NameNotFoundException: jmxrmi
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:340)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
at sun.tools.jconsole.ProxyClient.tryConnect(ProxyClient.java:350)
at sun.tools.jconsole.ProxyClient.connect(ProxyClient.java:296)
at sun.tools.jconsole.VMPanel$2.run(VMPanel.java:280)
Caused by: javax.naming.NameNotFoundException: jmxrmi
at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:99)
at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:185)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at javax.management.remote.rmi.RMIConnector.findRMIServerJNDI(RMIConnector.java:1888)
at javax.management.remote.rmi.RMIConnector.findRMIServer(RMIConnector.java:1858)
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:257)
... 4 more
Notes: When I used I'm meaning 172.xx.xxx.xxx
What am I doing wrong? What else should I set / check / change?
Well I've a few changes but I still can't make it worked.
I set the
java -classpath ${CLASSPATH} ${MY_OPTS} -Dweblogic.management.username=${ADMIN_USER} \ -Dweblogic.management.password=${ADMIN_PASSWD} -Dweblogic.Domain=${MY_DOMAIN} \ -Dweblogic.Name=${MY_SERVER} -Dweblogic.ListenPort=${MY_PORT} \ -Dweblogic.RootDirectory=${MY_DOMAIN_HOME}/${MY_DOMAIN} \ -Djava.rmi.server.hostname=${ADMIN_HOST} \ -Dcom.sun.management.jmxremote.port=22222 \ -Dcom.sun.management.jmxremote.authenticate=false \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.password.file=/home/MY_USER/jmxremote.password \ -Dcom.sun.management.jmxremote.access.file=/home/MY_USER/jmxremote.access \ -Dweblogic.management.GenerateDefaultConfig=true weblogic.Server &
I changed the authentication property to false and added the java.rmi.server.hostname where ADMIN_HOST is a variable set to the ip 172.17.209.66 of my computer.
When I used the service url in JConsole: service:jmx:rmi:///jndi/rmi://172.17.209.66:22222/jmxrmi
I get the following exception
22/11/2011 05:22:54 RMIConnector connect
MÁS FINA: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://172.17.209.66:22222/jmxrmi] connecting...
22/11/2011 05:22:54 RMIConnector connect
MÁS FINA: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://172.17.209.66:22222/jmxrmi] finding stub...
22/11/2011 05:22:54 RMIConnector connect
MÁS FINA: [javax.management.remote.rmi.RMIConnector: jmxServiceURL=service:jmx:rmi:///jndi/rmi://172.17.209.66:22222/jmxrmi] Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 172.17.209.66; nested exception is:
java.net.ConnectException: Conexión rehusada]
java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: 172.17.209.65; nested exception is:
java.net.ConnectException: Conexión rehusada]
at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:340)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:207)
And in the logs of my application I see the following:
Conector JMX ready in: service:jmx:rmi:///jndi/rmi://usuario-System-Product-Name:22222/jmxrmi
The /etc/hosts shows:
172.17.209.65 usuario-System-Product-Name # Added by NetworkManager
127.0.0.1 localhost.localdomain localhost ::1 usuario-System-Product-Name localhost6.localdomain6 localhost6
127.0.1.1 usuario-System-Product-Name
is that why I see the usuario-System-Product-Name and not the ip? Even if I set as hostname the ip of my computer?
I disabled both firewals and try the command line jmx tool Alex suggested buy with no luck :-(
Any other suggestions / tips / help ?
I think that you have problems with firewall on one of the ends.
So, first (if it is possible) try to close both firewalls and see what happens. If it started to work check which ports do you have to open. The problem is that JMX uses 2 ports. One you can configure, other one is chosen dynamically. So, it depends on your firewall how can you open it.
Other possibility is to use command line jmx tool: run it locally on the same machine where server is running through SSH/telnet terminal window.
I used one such application: http://crawler.archive.org/cmdline-jmxclient/downloads.html
and saw that it works quite fine.
I ran into the same problem and I did a scan of the server using a port scanner. And then I realized that most of the ports on the server are closed to outside by default. At least that's the case in my organization. In fact, the scanner says 22 is the only one opened and I guess that's why I can SSH to the server. You might want to clarify with your network team what it means by "closed firewalls" and make sure the port(22222 in your case) is turned on to your working machine.

Problems with shutting down JBoss in Eclipse if I change JNDI port

1st phase
I have a problem shutting down my running JBoss instance under Eclipse since I changed
the JNDI port of JBoss. Of course I can shut it down from the console view but not with
the stop button (it still searches JNDI port at the default 1099 port). I'm looking
forward to any solutions. Thank you!
Used environment:
JBoss 4.0.2 (using default)
Eclipse 3.4.0. (using JBoss Tools 2.1.1.GA)
Default ports: 1098, 1099
Changed ports: 11098, 11099
I changed the following part in jbosspath/server/default/conf/jboss-service.xml:
<!-- ==================================================================== -->
<!-- JNDI -->
<!-- ==================================================================== -->
<mbean code="org.jboss.naming.NamingService"
name="jboss:service=Naming"
xmbean-dd="resource:xmdesc/NamingService-xmbean.xml">
<!-- The call by value mode. true if all lookups are unmarshalled using
the caller's TCL, false if in VM lookups return the value by reference.
-->
<attribute name="CallByValue">false</attribute>
<!-- The listening port for the bootstrap JNP service. Set this to -1
to run the NamingService without the JNP invoker listening port.
-->
<attribute name="Port">11099</attribute>
<!-- The bootstrap JNP server bind address. This also sets the default
RMI service bind address. Empty == all addresses
-->
<attribute name="BindAddress">${jboss.bind.address}</attribute>
<!-- The port of the RMI naming service, 0 == anonymous -->
<attribute name="RmiPort">11098</attribute>
<!-- The RMI service bind address. Empty == all addresses
-->
<attribute name="RmiBindAddress">${jboss.bind.address}</attribute>
<!-- The thread pool service used to control the bootstrap lookups -->
<depends optional-attribute-name="LookupPool"
proxy-type="attribute">jboss.system:service=ThreadPool</depends>
</mbean>
<mbean code="org.jboss.naming.JNDIView"
name="jboss:service=JNDIView"
xmbean-dd="resource:xmdesc/JNDIView-xmbean.xml">
</mbean>
Eclipse setup:
About my JBoss Tools preferences:
I had a previous version, I got this problem, I read about some bugfix in JbossTools, so updated to 2.1.1.GA. Now the buttons changed, and I've got a new preferences view, but I cannot modify anything...seems to be abnormal as well:
Error dialog:
The stacktrace:
javax.naming.CommunicationException: Could not obtain connection to any of these urls: localhost:1099 [Root exception is javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]]
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at org.jboss.Shutdown.main(Shutdown.java:202)
Caused by: javax.naming.CommunicationException: Failed to connect to server localhost:1099 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:254)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1370)
... 4 more
Caused by: javax.naming.ServiceUnavailableException: Failed to connect to server localhost:1099 [Root exception is java.net.ConnectException: Connection refused: connect]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:228)
... 5 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at java.net.Socket.<init>(Socket.java:309)
at java.net.Socket.<init>(Socket.java:211)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:69)
at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory.java:62)
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:224)
... 5 more
Exception in thread "main"
2nd phase:
After creating a new Server in File/new/other/server, it did appear in the preferences tab. Now the stop button is working (the server receives the shutdown messages without any additional modification of the jndi port -- there is no opportunity for it now) but it still throws an error message, though different, it's without exception stack trace: "Server JBoss 4.0 Server failed to stop."
Here is a detailed fix for this problem:
The Eclipse WTP server connector won't shut down JBoss when the jndi port is remapped.
This is because the default server connector profiles don't use their own alias for the jndiPort. This problem is also discussed at eclipse.org:
http://www.eclipse.org/forums/index.php?t=msg&goto=489439&S=0db4920aab0a501c80a626edff84c17d#msg_489439
The solution comes from the .serverdef files in eclipse:
<eclipse>\plugins\org.eclipse.jst.server.generic.jboss_1.5.105.v200709061325\servers\jboss*.serverdef
They declare an xml property for the jndi port:
<property id="jndiPort"
label="%jndiPort"
type="string"
context="server"
default="1099" />
This simply needs to be used where the serverdef has the STOP command coded:
So this:
<stop>
<mainClass>org.jboss.Shutdown</mainClass>
<workingDirectory>${serverRootDirectory}/bin</workingDirectory>
<programArguments>-S</programArguments>
<vmParameters></vmParameters>
<classpathReference>jboss</classpathReference>
</stop>
becomes this:
<stop>
<mainClass>org.jboss.Shutdown</mainClass>
<workingDirectory>${serverRootDirectory}/bin</workingDirectory>
<programArguments>-s jnp://${serverAddress}:${jndiPort}</programArguments>
<vmParameters></vmParameters>
<classpathReference>jboss</classpathReference>
</stop>
The philosophy for this can be verified by comparison to the definition for the jndi connection:
<jndiConnection>
<providerUrl>jnp://${serverAddress}:${jndiPort}</providerUrl>
<initialContextFactory>org.jnp.interfaces.NamingContextFactory</initialContextFactory>
<jndiProperty>
<name></name>
<value></value>
</jndiProperty>
</jndiConnection>
Credit for the inspiration for this general case fix goes to: Moisa Laurentiu Florin. It was their contribution that got me to look for a way of substituting in the ${jndiPort} instead of a hard coded value.
This fix corrects both plain Eclipse WTP server connector. I'm still investigating the JBOss IDE connector
Open jboss-path\bin\shutdown.jar
example: jboss-4.2.3.GA\bin\shutdown.jar
and open jboss-path\bin\shutdown.jar\jndi.properties
and change
java.naming.provider.url=jnp://localhost:1099 to java.naming.provider.url=jnp://localhost:11099
OK, what you have to do is File->New->Other->Server, and set up your JBoss server there. It will then appear in Preferences->JBossTools->Servers.
Convoluted.
In MyEclipse server configuration, you find the field "Optional Shutdown Argument", which is filled with the default value
--shutdown
Change it to
-s jnp://localhost:11099 --shutdown
Edited:
Sorry, this answer is related to MyEclipse. However, there must be some place where you can specify the JBoss shutdown command in your environment as well.
Maybe you take a look at the "Run..." configurations?
you should modify in the file "/home/fmoisa/workspace/eclipse/plugins/org.eclipse.jst.server.generic.jboss_1.5.206.v20090115/servers/jboss42.serverdef" this:
org.jboss.Shutdown
${serverRootDirectory}/bin
-S
-Djboss.boot.loader.name=shutdown.bat
jboss.shutdown
to this:
org.jboss.Shutdown
${serverRootDirectory}/bin
-S -sjnp://localhost:11099
-Djboss.boot.loader.name=shutdown.bat
jboss.shutdown
gl all ;)
Use the server adapter provided by JBoss tools and not the one that comes default from Eclipse WTP.
Then you can simply double click on the server and you can edit the JNDI port (which btw. is automatically picked up from the XML configuration if you don't do any thing). You can also do the trick about setting the JNDI port via command line arguments in the Launch Configuration but that is more trouble than just setting the port values.
This was changed in JBoss 6.0.0M3.
The stop command is now:
"- s service:jmx:rmi:///jndi/rmi://localhost:1090/jmxrmi"
Note that the port also changed: It is no longer the JNDI port at 1099, but RMI/JMX port 1090. So, you will need another config parameter in the server definition.
I don't know whether the "JNDI port" parameter is required at all for JBoss 6.0.0M3 servers.
I have a modified eclipse plugin at http://www.cs.hs-rm.de/~knauf/public/ which contains a server definition for 6.0.0M3 including this change. This site also links to a JBoss forum thread with more details about this change.
Best regards
Wolfgang Knauf

Categories