crabhit
crabhit

Reputation: 139

How to get weblogic managed server listen port in runtime?

I deployed two weblogic managed instance in one server. These two instance using different port number, let say 7001 and 7002. My question is how to get port number in runtime? For example, if in intance1, I want to get 7001, if in instance2, I want to get 7002.

Upvotes: 3

Views: 24638

Answers (3)

Marc
Marc

Reputation: 41

You can use a script like this

export IDM_WLS_DOMAIN=IDMDomain 
export IDM_DOMAIN_HOME="$FMW_HOME/user_projects/domains/$IDM_WLS_DOMAIN"
...
export IDM_WLS_ADMIN_PORT=`cat $IDM_DOMAIN_HOME/bin/startManagedWebLogic.sh | grep 'ADMIN_URL="http' | cut -d '"' -f2 | cut -d ':' -f3`

-> IDM_WLS_ADMIN_PORT will be equal to 7001 or 7002, ...

Upvotes: 4

sweetfa
sweetfa

Reputation: 5845

A simple solution is to use WLST. The script below will get the port numbers of all servers within your WebLogic server domain.

#!/usr/bin/python

connect('weblogic','password','t3://localhost:7001')
domainConfig()
servers = cmo.getServers()
print "Server\t\tPort\tSSL"
for server in servers:
        print server.name + "\t" + str(server.getListenPort()) + "\t" + str(server.getSSL().getListenPort())
disconnect()

NOTE: You will probably have to replace the spaces at the beginning of the second last line with a tab character.

This script will work equally on Unix or Windows environments.

From a command prompt wlst scriptName

The output of such a script resembles:

Server          Port    SSL
AdminServer     7001    7002
bam_server1     9001    9002
osb_server1     7003    7004
soa_server1     8001    8002

Upvotes: 7

JoseK
JoseK

Reputation: 31371

Use JMX.

you can write a java program which will look up the RuntimeService MBean

"com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean"

and from this you can look up all the members of the cluster including the Admin.

and find their complete IP Address / DNS and port numbers

Here is a starter example

http://middlewaremagic.com/weblogic/?p=210

Upvotes: 2

Related Questions