cancel
Showing results for 
Search instead for 
Did you mean: 

How to get WAS Installation Number and System Id?

Former Member
0 Kudos

Anyone knows how to get Netweaver WAS Installation number and system id using java? I need these numbers to generate a unique key.

Any help would be much appreciated. Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi Julius,

There's the most trivial and easiest way to obtain the SID:

String systemID = System.getProperty("SAPSYSTEMNAME"); 

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maxim,

Thanks. It works.

Do you also happened to know how to get WAS installation number?

former_member182372
Active Contributor
0 Kudos

Hi Julius,

Try this


import javax.naming.InitialContext;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import com.sap.jmx.ObjectNameFactory;

.....
InitialContext ctx = new InitialContext();
MBeanServerConnection mbsc = (MBeanServerConnection)ctx.lookup("jmx");
ObjectName LICENSING_SERVICE_ON = LICENSING_SERVICE_ON = ObjectNameFactory.getNameForServerChildPerNode("SAP_J2EEServiceRuntimePerNode", "licensing", null, null);
String number = (String)mbsc.getAttribute(LICENSING_SERVICE_ON, "InstNo");
.....

Don`t forget to add reference to jmx service.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

System.getProperty("SAPSYSTEM");

regards

Sebastian

Former Member
0 Kudos

hi Maksim,

btw, what is the name of the external jar file needed for jmx service, where to find it?

former_member182372
Active Contributor
0 Kudos

Hi Julius,

<ROOT>/SAP/JDT/eclipse/plugins/com.sap.tc.ap/comp/SAP-JEE/DCs/sap.com/tc/jmx/_comp/gen/default/public/default/lib/java/com_sap_pj_jmx.jar

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim,

Thanks again for your prompt reply. From the SDN library, to add the reference, i believe i need to alter provider.xml located in the application server's folder, but that has defeated the purpose of getting the NW installation number, in my case.

Sorry if i didnt explain the purpose of getting the installation number in the first place. The purpose is to generate a unique license key for my j2ee product for a single NW WAS instance, based on system id, installation number, etc. Therefore, altering provider.xml will not serve the purpose as i couldnt expect the user to do that.

Do you by any chance came across of other way to get the installation number? Or know of any system info. that can be uniquely identified a NW WAS instance?

former_member182372
Active Contributor
0 Kudos

Hi Julius,

1) Add mentioned above jar file to class path of your application

2) In enterprise application project folder META-INF find application-j2ee-engine.xml and add


	<reference 
		reference-type="weak">
		<reference-target 
			provider-name="sap.com" 
			target-type="service">jmx</reference-target>
	</reference>

3) Use mentioned above code to get installation number.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim,

I got java.lang.ClassCastException exception at point 3) for either

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

or

MBeanServer mbsc = (MBeanServer)ctx.lookup("jmx");

Any idea?

former_member182372
Active Contributor
0 Kudos

Hi Julius,

Add

	<reference 
		reference-type="weak">
		<reference-target 
			provider-name="sap.com" 
			target-type="library">tc~jmx</reference-target>

too.

Best regards, Maksim Rashchynski.

Former Member
0 Kudos

Hi Maksim,

Thanks again for your reply.

I'm getting this exception after add the second reference:

com.sap.engine.services.jmx.exception.JmxSecurityException: Caller J2EE_GUEST not authorized, only role administrators is allowed to access JMX , com.sap.engine.services.jmx.exception.JmxSecurityException: Caller J2EE_GUEST not authorized, only role administrators is allowed to access JMX#

Anything else to be configured?

former_member182372
Active Contributor
0 Kudos

But here is the description of problem: you need to have administrator role to run this piece of code. From where are you trying to run it: web, ejb , wd?

Former Member
0 Kudos

Hi Maksim,

i'm now running in EJB. Do i need to change anything in order to run it there?

p/s: Anyway, if it's not possible to run it in EJB, i can run it in WebDynpro or Web.

Former Member
0 Kudos

From SAP Note Number 948970:

5. If the Exception is similar to "Caller MY_USER not authorized, only role administrators..." then make sure the user MY_USER has the required administrative privileges for the requested operation (configured using Visual Administrator).

In my case, <b>how do i change the default user J2EE_GUEST to J2EE_ADMIN</b>? I guess J2EE_ADMIN should have enough privilege to do JMX operation.

Thanks.

former_member182372
Active Contributor
0 Kudos

Hi Julius,

If you are running EJB, it is actually piece of cake. Check http://help.sap.com/saphelp_nw04/helpdata/en/60/bbfc3eea4d2e5ae10000000a114084/frameset.htm

Instead of "carCustomer" and "customer" specify "administrators".

Best regards, Maksim Rashchynski.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Maksim,

I'm trying to do the same thing in webdynpro, but every time I get the 'ClassCastException'.

InitialContext initialCtx = new InitialContext();

MBeanServer mbs = (MBeanServer)initialCtx.lookup("jmx");

<property name="ServicesReference" value="sap.com/jmx"/>

<property name="LibrariesReference" value="sap.com/tc~jmx"/>

the JNDI look up has this entry -

+ jmx

+ [Class Name] : com.sap.pj.jmx.server.interceptor.MBeanServerInterceptorChain

+ [Object Value] : NON Serializable Object

J2EE Engine is 6.40.

could you please tell me what I'm missing.

Thanks in advance,

Rajiv.