}
------------------------------------------------------------------------------
try{
childprocesslist =(java.util.List)_soapClient.invoke (discoverybean,"getChildren", new Object[] {}, new String[] {});
}
catch (Exception e)
{
System.out.println("Exception invoking launchProcess: " + e);
}
------------------------------------------------------------------------------
error
DiscoveryBean found WebSphere:platform=common,cell=195al-purifyNetwork,version=5.0,name=Discovery,mbeanIdentifier=Discovery,type=Discovery,node=195al-purify,process=nodeagent
Exception invoking launchProcess: com.ibm.websphere.management.exception.ConnectorException: ADMC0009E: Failed to make the SOAP RPC call: invoke
-------------------------------------------------------------------------------------------
if i pass empty string in params and signature as fallows :
childprocesslist =(java.util.List)_soapClient.invoke (discoverybean,"getChildren", new Object[] {""}, new String[] {""});
its throwing fallowing error :
Exception invoking launchProcess: javax.management.RuntimeOperationsException: JMXmd0011E Operation getChildren not found
can any one help me out
thanks in advance
try this syntax if your operation doesn't take parameters:
try{
childprocesslist =(java.util.List)_soapClient.invoke (discoverybean,"getChildren",null, null);
}
catch (Exception e)
{
System.out.println("Exception invoking launchProcess: " + e);
}
Ken
import java.util.Date;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import javax.management.Notification;
import javax.management.NotificationFilterSupport;
import javax.management.NotificationListener;
import javax.management.ObjectName;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.ibm.websphere.management.AdminClient;
import com.ibm.websphere.management.AdminClientFactory;
import com.ibm.websphere.management.AdminService;
import com.ibm.websphere.management.AdminServiceFactory;
import com.ibm.websphere.management.application.AppConstants;
import com.ibm.websphere.management.application.AppManagement;
import com.ibm.websphere.management.application.AppManagementProxy;
import com.ibm.websphere.management.application.client.AppDeploymentController;
import com.ibm.websphere.management.application.client.AppDeploymentTask;
import forms.installForm;
/**
* @version 1.0
* @author
*/
public class InstallAction extends Action implements NotificationListener {
private AdminClient adminClient;
private ObjectName discoverybean;
private long ntfyCount = 0;
String installmessage ="setup" ;
java.util.List childprocesslist;
Vector applist2;
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward(); // return value
installForm instalForm = (installForm)form;
try {
///////////////////////////install/////////////////////////////////
String host="15.56.345.254";
String port = "8889";
String target ="WebSphere:cell=195-sadvanNetwork,node=195-advan,server=server1";
System.out.println("step 1");
Properties config = new Properties();
config.put (AdminClient.CONNECTOR_HOST, host);
config.put (AdminClient.CONNECTOR_PORT, port);
config.put (AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP);
System.out.println ("Config: " + config);
AdminClient _soapClient = AdminClientFactory.createAdminClient(config);
System.out.println("step 2");
// Create the application management proxy, AppManagement.
AppManagement proxy = AppManagementProxy.getJMXProxyForClient (_soapClient);
System.out.println("step 3");
// If code for the preparation phase has been run, then you already have the options table.
// If not, create a new table and add the module-to-server relationship to it by uncommenting
// the next statement.
Hashtable options2 = new Hashtable();
options2.put (AppConstants.APPDEPL_LOCALE, Locale.getDefault());
// Uncomment the following statements to add the module to the server relationship table if
// the preparation phase does not collect it.
Hashtable module2server = new Hashtable();
module2server.put ("*", target);
options2.put (AppConstants.APPDEPL_MODULE_TO_SERVER, module2server);
System.out.println("step 4");
String query = "WebSphere:*,type=Discovery";
ObjectName queryName = new ObjectName(query);
Set s = _soapClient.queryNames(queryName, null);
if (!s.isEmpty()){
System.out.println("Node agent if condition " );
discoverybean = (ObjectName)s.iterator().next();
System.out.println("Node agent MBean found" + discoverybean.toString());
String opName = "getChildren";
String signature[] = { null };
String params[] = { null };
try
{
childprocesslist =(java.util.List)_soapClient.invoke(discoverybean,"getChildren",null, null);
System.out.println(" invoked discoveryProcess: " );
}
catch (Exception e)
{
System.out.println("Exception invoking discovery: " + e.fillInStackTrace());
}
}
else
{
System.out.println("Discovert MBean was not found");
}
Vector applist= proxy.listApplications(options2,null);
for(int i=0;i < applist.size();i++){
String application = (String)applist.get(i);
System.out.println("applications are"+application);
}
System.out.println("after step 5");
System.out.println ("After install App is called..");
// Wait for some timeout. The installation application programming interface (API) is
// asynchronous and so returns immediately.
// If the program does not wait here, the program ends.
// Wait so that the program does not end.
// do something here
} catch (Exception e) {
// Report the error using the appropriate name and ID.
errors.add("name", new ActionError("id"));
}
// If a message is required, save the specified key(s)
// into the request for use by the <struts:errors> tag.
if (!errors.isEmpty()) {
saveErrors(request, errors);
// Forward control to the appropriate 'failure' URI (change name as desired)
// forward = mapping.findForward("failure");
} else {
// Forward control to the appropriate 'success' URI (change name as desired)
// forward = mapping.findForward("success");
}
// Finish with
return (mapping.findForward("success"));
}
public void handleNotification(Notification ntfyObj, Object handback)
{
// Each notification that the NodeAgent MBean generates will result in
// this method being called
ntfyCount++;
System.out.println("***************************************************");
System.out.println("* Notification received at " + new Date().toString());
System.out.println("* type = " + ntfyObj.getType());
System.out.println("* message = " + ntfyObj.getMessage());
System.out.println("* source = " + ntfyObj.getSource());
installmessage= (String)ntfyObj.getMessage();
System.out.println(
"* seqNum = " + Long.toString(ntfyObj.getSequenceNumber()));
System.out.println("* timeStamp = " + new Date(ntfyObj.getTimeStamp()));
System.out.println("* userData = " + ntfyObj.getUserData());
System.out.println("***************************************************");
}
}
----------------------------------
appreciate your prompt responces
>i am getting one line of error ..this is the code i am using
>
>
It would have been nice to see the one line of error.
>----------------------------------------------
>package actions;
>
>
>
[snip]
I get
InstallAction.execute() threw
com.ibm.websphere.management.exception.AdminException: ADMA0089E: The
AppManagement MBean is not found.
com.ibm.websphere.management.exception.AdminException: ADMA0089E: The
AppManagement MBean is not found.
on the following line.
> AppManagement proxy = AppManagementProxy.getJMXProxyForClient (_soapClient);
>
> System.out.println("step 3");
>// If code for the preparation phase has been run, then you already have the options table.
>// If not, create a new table and add the module-to-server relationship to it by uncommenting
>// the next statement.
> Hashtable options2 = new Hashtable();
> options2.put (AppConstants.APPDEPL_LOCALE, Locale.getDefault());
>
>// Uncomment the following statements to add the module to the server relationship table if
>// the preparation phase does not collect it.
> Hashtable module2server = new Hashtable();
> module2server.put ("*", target);
> options2.put (AppConstants.APPDEPL_MODULE_TO_SERVER, module2server);
> System.out.println("step 4");
>
>
>
>
It is _very_ unusual to connect to a node agent - your changes will be
overwritten by the next synch from the Deployment Manager. You typically
want to connect to the DM.
>
> String query = "WebSphere:*,type=Discovery";
> ObjectName queryName = new ObjectName(query);
> Set s = _soapClient.queryNames(queryName, null);
> if (!s.isEmpty()){
> System.out.println("Node agent if condition " );
> discoverybean = (ObjectName)s.iterator().next();
> System.out.println("Node agent MBean found" + discoverybean.toString());
>
>
>
[snip]
>----------------------------------
>appreciate your prompt responces
>
>
>
Ken
sorry for not being clear in my presentation;-
error at AppManagement i am not getting may be port address u need to give appropriate one the one i have given may not be valid!
regarding looking at nodeagent comment in the debugging statement i mentioned by mistake as nodeagent actually i am looking at DM level only
thanks
There is no standard MBean with type=Discovery in version 6. What
version are you using?
Ken
>1) i am using version 5.1 i could see the MBean in MBean inspector is it the same as i seen in MBean inspector ?
>2) as well i am curious about the error u got(AppManager not found exception ) while running my code ,when i tried on my friends system i faced about the same problem if i run on my machine no problems and the version of WAS on both of our systems same ?
>
>
Sorry, I don't have a 5.1 system I can easily play with.
Check the port numbers between your system and your friend's - you may
be connecting to app servers vs. node agents vs. DM's.
Ken
This code works for me on version 6:
package foo;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
import javax.management.ObjectName;
import com.ibm.websphere.management.AdminClient;
import com.ibm.websphere.management.AdminClientFactory;
import com.ibm.websphere.management.application.AppManagement;
import com.ibm.websphere.management.application.AppManagementProxy;
import com.ibm.websphere.management.exception.ConnectorException;
/**
* @version 1.0
* @author
*/
public class InstallAction {
private AdminClient _adminClient = null;
private String _host = null;
private String _port = null;
private ObjectName discoverybean;
java.util.List childprocesslist;
Vector applist2;
public static void main(String[] args) throws Exception {
String host = "localhost";
String port = "8879";
InstallAction self = new InstallAction(host,port);
self.execute();
}
public InstallAction(String host, String port) {
_host = host;
_port = port;
}
public void execute() throws Exception {
try {
_adminClient = getAdminClient(_host, _port);
String query = "WebSphere:*,type=Discovery,process=dmgr";
ObjectName queryName = new ObjectName(query);
Set s = _adminClient.queryNames(queryName, null);
if (!s.isEmpty()) {
discoverybean = (ObjectName) s.iterator().next();
try {
childprocesslist = (java.util.List) _adminClient.invoke(
discoverybean, "getChildren", null, null);
if (childprocesslist != null) {
System.out.println("getChildren():");
for (Iterator iter =
childprocesslist.iterator(); iter.hasNext();)
System.out.println("\t" + (String)iter.next());
}
} catch (Exception e) {
System.out.println("Exception invoking discovery: "
+ e.fillInStackTrace());
}
} else {
System.out.println("Discovery MBean was not found");
}
// Create the application management proxy, AppManagement.
AppManagement proxy =
AppManagementProxy.getJMXProxyForClient(_adminClient);
Vector applist = proxy.listApplications(null, null);
System.out.println("applications:");
for (int i = 0; i < applist.size(); i++) {
String application = (String) applist.get(i);
System.out.println("\t" + application);
}
} catch (Exception e) {
System.err.println(getClass().getName() + ".execute() threw
" + e);
e.printStackTrace(System.err);
}
}
private AdminClient getAdminClient(String host, String port) throws
ConnectorException {
if (_adminClient == null) {
Properties config = new Properties();
config.put(AdminClient.CONNECTOR_HOST, host);
config.put(AdminClient.CONNECTOR_PORT, port);
config.put(AdminClient.CONNECTOR_TYPE,
AdminClient.CONNECTOR_TYPE_SOAP);
_adminClient = AdminClientFactory.createAdminClient(config);
}
return _adminClient;
}
}
------------------------------------------
Output is:
getChildren():
node1
applications:
MBeansBrowserEAR
-----------------------
the error
java.lang.UnsupportedClassVersionError: com/ibm/websphere/management/AdminClientFactory (Unsupported major.minor version 48.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:703)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:133)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:320)
at java.net.URLClassLoader.access$400(URLClassLoader.java:93)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:239)
at java.lang.ClassLoader.loadClass(ClassLoader.java:516)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:460)
at java.lang.ClassLoader.loadClass(ClassLoader.java:448)
at InstallAction.getAdminClient(InstallAction.java:103)
at InstallAction.execute(InstallAction.java:53)
at InstallAction.main(InstallAction.java:41)
Exception in thread "main"
--------------------------------------------
thank you for the responces you are providing
> i am using version 6 was libraries and trying to execute ur code i am getting fallowing error :- will there be any run time conflict with libraries and jre ?
> ----------------------------------
> the jre i am using
> java version "1.4.0_01"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
> Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)
>
> -----------------------
WAS is *only* supported with the JDK that we deliver with the product.
>thanks for the clarification here is the exception i am getting :-
>Exception invoking discovery: javax.management.JMRuntimeException: ADMN0022E: Access denied for the getChildren operation on Discovery MBean due to insufficient or empty credentials.
>
>
www.google.com, 'adminclient site:ibm.com', and take the first link.
Ken