I tested the following code for JBOSS-6.0.0.M2
package com.sudipta.jboss.conf;
import org.jboss.Main;
public class JbossOperation {
public static Main ob;
static Class jbossMain;
static{
try {
jbossMain=Class.forName("org.jboss.Main");
ob = (Main)jbossMain.newInstance();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
/**
* START JBOSS SERVER
* @return true if started successfully
*/
public static boolean startServer(){
boolean status=true;
String str[]={"-c","default"};
try {
ob.boot(str);
} catch (Exception e) {
e.printStackTrace();
return false;
}
return status;
}
/**
* STOP JBOSS SERVER
* @return true if started successfully
*/
public static boolean stopServer(){
boolean status=true;
try {
ob.shutdown();
} catch (Throwable e) {
e.printStackTrace();
}
return status;
}
/**
* Main method
* @param args
*/
public static void main(String args[]){
System.out.println("---------------------Strating the server------------------");
startServer();
System.out.println("---------------------Stoping the server------------------");
stopServer();
System.out.println("---------------------SERVER STOPPED------------------");
}
}
scrolling="no" frameborder="0"
style="border:none;" width="90px" height="20px">
i have written the code but it is not working please help
ReplyDeletei have written it in zul file in eclipse it is zk file
import org.jboss.Main;
public boolean startJboss()
{ boolean stat=true;
try
{
String[] str={"-c","default"};
Class c = Class.forName("org.jboss.Main");
Main ob=(Main)c.newInstance();
ob.main(str);
}
catch(Exception e)
{
System.out.print(""+e.getMessage());
stat=false;
}
return stat;
}
Can you please mention the error or exception you are getting.
ReplyDeleteob.main(str);here try ob.boot(str);
How can you do it remotely? Where can I specify which host do I want to start/stop?
ReplyDeleteHi. Thanks for this. It's just what I need, excep that I get the following exceptin on startup. We're running JBoss 6. Any ideas would be greatly appreciated. Thanks.
ReplyDelete19:38:30,796 ERROR [AbstractKernelController] Error installing to Configured: name=ServiceMetaDataICF state=Instantiated: java.lang.RuntimeException: Error configuring property: controller for ServiceMetaDataICF
at org.jboss.kernel.plugins.dependency.ConfigureAction.dispatchSetProperty(ConfigureAction.java:112) [jboss-kernel.jar:2.2.0.Alpha10]
I know it has been a while since you posted this, but I tried to use this code using JBOSS-6.0.0.M2 and it didn't work. I get the following error:
ReplyDelete16:31:44,412 ERROR [AbstractKernelController] Error installing to Configured: name=ServiceMetaDataICF state=Instantiated: java.lang.RuntimeException: Error configuring property: controller for ServiceMetaDataICF
at org.jboss.kernel.plugins.dependency.ConfigureAction.dispatchSetProperty(ConfigureAction.java:112)
...
Caused by: java.lang.IllegalArgumentException: No such property controller for bean org.jboss.system.deployers.managed.ServiceMetaDataICF available [type, class, mbeanServer]
at org.jboss.beans.info.plugins.AbstractBeanInfo.getProperty(AbstractBeanInfo.java:147)
That I believe is the same error Calvin had. I was wondering if you did something else to make it work.
Thank you very much