Can't connect to weblogic server remotely using JConsole - java

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.

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

Stop jboss 5.x from shell script

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.

Eclipse connection refused when remote debugging

I've been following this tutorial which is how to setup remote debugging.
I have my Jar running debug mode listening on port 6065 on my server with the following setting:
-Xrunjdwp\:transport\=dt_socket,server\=y,address\=6065,suspend\=n
I start the JAR on my server with jar in debug mode with:
myApplicationThatContainsJar.exe -debug "my application"
> Now Starting JVM
> Listening for transport dt_socket at address: 6065
I have psping tool installed which I use to ping (IPaddress:port). I am able to ping my ipaddress example: 44.66.33.66:6065 from my dev box and get a reply. But when I try to initiate remote debug in Eclipse I get:
Failed to connect to remote VM. Connection refused. Connection
refused: connect
I have verified I've added permission for both inbound and outbound traffic for that port on both my DEV box and server.
When I start my JAR on my server and before I try to connect with Eclipse I do a:
psping 44.66.33.66:6065
And I get a response stating that it sent and recieved with 0% loss, meaning I am indeed getting a response.
In the eclipse debug configuration, which in the 'Debug Configurations' window I have the host and port listed properly and the 'Connection Type: Standard(Socket Attach)'.
As soon as I try to connect with Eclipse and get the connection refused error I try psping again from the command line, but now eclipse did something to the connection and I get in the command line:
The remote computer refused the network connection.
Any suggestions where else I should check? or where else I should troubleshoot? I'm trying to do remote-debugging for my JAR from the DEV box to my server.
-Xrunjdwp\:transport\=dt_socket,server\=y,address\=6065,suspend\=n
should be:
-Xrunjdwp\:transport\=dt_socket,server\=y,address\=6065,suspend\=y
notice the suspend\=y keep in mind I need to escape the equals and others may not need to do this. Once I set to suspend\=y the application waited for me to connect from eclipse and I was able to begin remote debugging.
Don't forget to open inbound and outbound traffic for the port you used for address\=6065
Check network setting in VM and set Attached to: Bridged Adapter
Check VM IP using ipconfig command
Run Java Application using following command
> java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n myapp
Above command myapp replace to your application name
In eclipse go to debug configuration -> remote java Application -> New
Host: remote VM ip
Port: given port that given in command
Apply -> Debug

Could not start GlassFish 4.0 (Windows) - port 1527 - Address already in use

I'm a newbie in Java EE 7.
I have Netbeans 7.4 with GlassFish 4.0 and Java EE 7. In a 64-bit Windows 8.1 Pro machine. I want to start the GlassFish 4.0 Server, so I clicked on the services tab in Netbeans and then in the Servers option I right-clicked GlassFish Server 4.0 and then clicked Start.
When I did that I got the following message: "Could not start GlassFish Server 4.0: HTTP or HTTPS listener port is occupied while server is not running". I have also the IIS server, but I stopped it. After stopping IIS I tried to start again the GlassFish but it showed me the same message.
Also there is a window in Netbeans called Output - Java DB Database Process and it showed me the following:
Tue May 06 22:03:11 GMT-05:00 2014 : Security manager installed using the Basic server security policy.
Tue May 06 22:03:11 GMT-05:00 2014 Thread[main,5,main] java.io.FileNotFoundException: D:\Users\Juan Jose\.netbeans-derby\derby.log (Access is denied)
Tue May 06 22:03:12 GMT-05:00 2014 : Could not listen on port 1527 on host localhost:
java.net.BindException: Address already in use: JVM_Bind
Tue May 06 22:03:12 GMT-05:00 2014 : Could not listen on port 1527 on host localhost:
java.net.BindException: Address already in use: JVM_Bind
I ran a netstat -a in Windows to see what was happening with the 1527 port and that port is in LISTENING mode.
So how can I know what application or process is ocuppying the 1527 port?
Thanks for your help !!
To find the process1 that keeps the busy port, try the following command:
netstat -ano | find "1527"
This will show a line with the port and the identifier of the process. e.g.:
TCP 127.0.0.1:1527 0.0.0.0:0 LISTENING 2268
Once you have the process ID (e.g. 2268), run the following command for release the port (this will kill the process):
taskkill /F /PID 2268
Now, try to start Glassfish.
On Linux:
lsof -Pnl +M -i6 | grep 1527
Produces:
java 31139 1001 32u IPv6 114916062 0t0 TCP 127.0.0.1:1527 (LISTEN)
Killed with:
kill -9 31139
1 If you want to know the associated program, see How do I find out what service is using a certain port?
If the above doesn't work for anyone pls follow the below steps.. Sure It will work..
Go to C:\Program Files\glassfish-4.1\glassfish\domains\domain1\config
Open "domain.xml" in a xml editor or u can use notepad++
Find "8080"(below highlighted for ur reference)
network-listener port="8080" protocol="http-listener-1"
transport="tcp" name="http-listener-1" thread-pool="http-thread-pool"
Replace "8080" with any open port. If you don't know how to find out open port try to use port no "3702" then save your file
now run your project
After running the project please have an eye on the URL
http://localhost:8080/...... should be http://localhost:3702/.....
To get open ports follow the below steps
open cmd.exe
execute cmd "netstat -ano"
Pick any one which you find is free(Like inside the green box above )
This is not an error you need to worry about. When you start GlassFish, NetBeans will also start the JavaDB (aka, Derby) database, which listens on port 1527 by default. When you shut down NetBeans, it will shut down GlassFish but will not shut down JavaDB. Therefore, when you start NetBeans a second time, NetBeans will try to start JavaDB again and fail because it is already running and listening on port 1527.
To shut down the database, you can use the NetBeans Services(Tab)->Databases->JavaDB(right click->Stop Server. To shut down from the command line use $NETBEANS_HOME/glassfish-4.0/javadb/bin/stopNetworkServer, where $NETBEANS_HOME is the top-level directory where NetBeans is installed (at least on Mac/Linux/Unix).

Failed to connect to remote VM using Glassfish and Eclipse

i'm using Glassfish 3.1.2.2 and Eclipse Kepler.
Glassfish configuration:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009.
Debug: Enabled
Into Eclipse, in the Remote Java Application i've selected the project, and in the connection properties i've set:
Host: localhost
port: 9009
When i try to connect the debug, the message error is:
Failed to connect to remote VM. Connection refused.
Connection refused: connect
I've checked the port 9009 with a telnet, and is not used...
can someone help me?
tx
[SOLVED] it's a problem with the glassfish plugin in Eclipse! you must to start glassfish form the command line, not from the Eclipse window. After, you can connect like remote debug to your local glassfish ;)
In Host, you need to give IP address of the remote machine you want to connect.
localhost is your own machine.

Categories