cancel
Showing results for 
Search instead for 
Did you mean: 

find host and port

Former Member
0 Kudos

My J2EE application has an EJB module and web module. I need to call the servlet in the web module from EJB module, via HTTPUrl connection. To make the web application portable and not-hardcoded, is there any way for EJB module to find out programatically the host and port number of where my J2EE application is deployed?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I don't know weather it helps you or if you need the information now:

I have a "half" solution for it: With the instance-number you can calculate all standard(!)-ports. I saw this calculating-ports-stuff in a word-doc.

//HTTP-Port = 50000InstanceNumber*1000

String InstanceNumber = java.lang.System.getProperty("SAPSYSTEM");

int temp = 50000 + Integer.valueOf(InstanceNumber).intValue() * 100;

String port = String.valueOf(temp);

For the IP...maybe you can use "localhost"? But my problem with this solution is: I don't know weather the standard ports can be changed manually. When yes: this solution can have a problem...

regards,

Remo

Former Member
0 Kudos

check out the JMX(Java Management eXtension) APIs...might help you

Former Member
0 Kudos

JMX API cannot be found in the sdn. Can someone provide the url? I did the jmx connection before, with guidance from someone in the forum. I was wondering where are these BALDed SAP-specific info getting from?

InitialContext initcontx = new InitialContext();

MBeanServerConnection mbsc = (MBeanServerConnection)initcontx.lookup("jmx");

ObjectName LICENSING_SERVICE_ON = ObjectNameFactory.getNameForServerChildPerNode<b>("SAP_J2EEServiceRuntimePerNode", "licensing"</b>, null, null);

installationNumber = (String)mbsc.getAttribute(<b>LICENSING_SERVICE_ON, "InstNo"</b>);