how to create groovy client? getting an error, below.

**

start up jboss with following paremater:

**

set JAVA_OPTS= -Djava.rmi.server.hostname=localhost
               -Dcom.sun.management.jmxremote.ssl=false
               -Dcom.sun.management.jmxremote.authenticate=true
               -Dcom.sun.management.jmxremote.password.file=C:\Java\jdk1.7.0\jre\lib\management\jmxremote.password
               -Dcom.sun.management.jmxremote.access.file=C:\Java\jdk1.7.0\jre\lib\management\jmxremote.access"

**

test jboss is started:

**

http://localhost:9990/
username: abc
password: abc1#

**

Groovy script:

**

import javax.management.ObjectName
import javax.management.remote.JMXConnectorFactory as JmxFactory
import javax.management.remote.JMXServiceURL as JmxUrl
import groovy.swing.SwingBuilder
import javax.swing.WindowConstants as WC


// Connect to server
def serverUrl = 'service:jmx:rmi:///jndi/rmi://localhost:9990/jmxrmi'
def server = JmxFactory.connect(new JmxUrl(serverUrl)).MBeanServerConnection
def serverInfo = new GroovyMBean(server, 'Catalina:type=Server').serverInfo
println "Connected to: $serverInfo"

**

Error:

**

Exception thrown

java.io.IOException: Failed to retrieve RMIServer stub: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
    java.net.SocketTimeoutException: Read timed out]
    at jmxClient.run(jmxClient.groovy:10)

Caused by: javax.naming.CommunicationException [Root exception is java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
    java.net.SocketTimeoutException: Read timed out]
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:118)
    at com.sun.jndi.toolkit.url.GenericURLContext.lookup(GenericURLContext.java:203)
    ... 1 more

Caused by: java.rmi.ConnectIOException: error during JRMP connection establishment; nested exception is:
    java.net.SocketTimeoutException: Read timed out
    at com.sun.jndi.rmi.registry.RegistryContext.lookup(RegistryContext.java:114)
    ... 2 more


Caused by: java.net.SocketTimeoutException: Read timed out
    ... 3 more

it seems that you're trying to connect on the http port of your jboss, instead of rmi connection ?

by default, rmi binds on port 1099.

maybe you should try

def serverUrl = 'service:jmx:rmi:///jndi/rmi://localhost/jmxrmi'
commented: thanks alot for getting back to me +3

i think I found the problem. i have start up JBoss but I never start rmi server. Do you have any idea's how can I start rmi using JBOSS in window?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.