2

I need to connect to websphere jmx with groovy: host is input argument

def urlRuntime = '/jndi/JMXConnector'
def urlBase = 'service:jmx:iiop://' + host

def serviceURL = new JMXServiceURL(urlBase + urlRuntime)
def h = new Hashtable()
h.put(Context.SECURITY_PRINCIPAL, username)
h.put(Context.SECURITY_CREDENTIALS, password)

h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "com.ibm.websphere.management.remote")

def server = JMXConnectorFactory.connect(serviceURL,h).MBeanServerConnection

println server

when I run this example I got this example:

JSAS1480I: Security is not enabled because the ConfigURL property file is not set.
Caught: java.io.IOException: Connector not available: Error during resolve
java.io.IOException: Connector not available: Error during resolve
    at com.ibm.websphere.management.remote.WsProvider.newJMXConnector(WsProvider.java:155)
    at KonfiguraceSluzebConfig.main(rob-app-task.groovy:59)

what is wrong with my code ? Iam using websphere version 8.5.5.0

UPDATE

I try to add config file:

   h.put("com.ibm.CORBA.ConfigURL","ssl.client.props");

but exception is still same. I dont know how to add there this file

UPDATE2

so after little research I found that I need to add this argument witch groovy:

-Dcom.ibm.CORBA.ConfigURL=sas.client.props
-Dcom.ibm.SSL.ConfigURL=ssl.client.props

now exception JSAS1480I is solved but there is another exception:

Caused by: java.lang.ClassCastException: com.ibm.rmi.javax.rmi.PortableRemoteObject incompatible with javax.rmi.CORBA.PortableRemoteObjectDelegate

when I remove this properties:

h.put(Context.SECURITY_PRINCIPAL, username)
h.put(Context.SECURITY_CREDENTIALS, password)

then pop up window with username and pasword is showed. When I enter valid username and password then we have the same exception:

java.io.IOException: Connector not available: Error during resolve
    at com.ibm.websphere.management.remote.WsProvider.newJMXConnector(WsProvider.java:155)

which really doesn't tell me where is the problem ... nice IBM

can anyone helps me with this problem ?

PS: In java this example works

hudi
  • 15,555
  • 47
  • 142
  • 246
  • Does this help? http://stackoverflow.com/questions/13840637/how-to-connect-to-a-websphere-application-server-8-5-message-queue-while-adminis – tim_yates Dec 10 '13 at 15:07
  • nope I really dont want to specify some file which I dont know how to create and the main problem with connector – hudi Dec 10 '13 at 15:12
  • Maybe you need the admin client jar in your classpath? http://stackoverflow.com/questions/357095/how-do-you-enable-jmx-in-websphere – tim_yates Dec 10 '13 at 15:28
  • I already have this lib in path: com.ibm.ws.admin.client_8.5.0.jar com.ibm.ws.orb_8.5.0.jar com.ibm.ws.webservices.thinclient_8.5.0.jar – hudi Dec 10 '13 at 15:31
  • What happens when you remove the following line "h.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, "com.ibm.websphere.management.remote")". It basically tells the JMX to look for protocol providers (or connectors) in the specified package. It might be the cause why the connector can not be found. – JB- Dec 16 '13 at 08:29
  • Have you also tried passing in the credentials as argument? `-Dcom.ibm.CORBA.loginUserid=username -Dcom.ibm.CORBA.loginPassword=password`. – dmahapatro Dec 16 '13 at 18:38

1 Answers1

0

When I connect Websphere8.5 through jmx, I suffered the same situation as yours.

I decompiled com.ibm.ws.admin.client_8.5.0 and I debugged the source code of class com.ibm.websphere.management.remote.WsProvider.

When the code run at line initialContext.lookup(jndiURL);, the exception was thrown ! Then I watch the detail of exception, I found the case of exception :

' Connector not available: Error during resolve' was 'WsnNameService properties [Root exception is org.omg.CORBA.TRANSIENT: initial and forwarded IOR inaccessible vmcid: IBM minor code: E07 completed: No] ',

I kept on digging the case of exception IBM minor code: E07 completed: No was java.net.UnknownHostException !

I observed that I was at localhost connect to a remote jmx, and the hostname of the target was not in my hosts file. I add 10.24.16.xx remotehostname to hosts file, then run the program, it works !

I hope this is useful to you!

franssu
  • 2,422
  • 1
  • 20
  • 29