Andrew Gray wrote:
>
> Hi,
>
> I have JOnAS 1.5 running and want to stop it from a different VM (but same
> machine). My code is:
>
> org.objectweb.jonas.adm.Adm adm1;
> adm1.stopServer();
>
> I always get a NullPointerException on the second line. I thought it would
> be possible to call methods directly in this manner as the UI I am writing
> will always be on the same physical machine as the EJB Server.
>
> If I have to access the "Adm" as if it existed remotely, then "Adm" will
> need to be list in the Naming Directory, which means "Adm" will require a
> stub class to be used in this way.
>
> How would you recommend I access the classes I need? Any help appreciated.
> Thanks in advance.
>
Hello Andrew,
org.objectweb.jonas.adm.Adm is a java.rmi.server.UnicastRemoteObject
and implements org.objectweb.jonas.adm.AdmInterface which extends
java.rmi.Remote.
So, you can access to the org.objectweb.jonas.adm.Adm object
by the way of the org.objectweb.jonas.adm.AdmInterface interface
and the Naming Directory.
You can see an example in the org.objectweb.jonas.adm.AdmServer
source code.
It's look like:
--------------------------------------------------
// Gets reference on Adm object
AdmInterface admI = null;
{
String admName = Env.getJonasName() + "_Adm";
try {
admI = (AdmInterface) initialContext.lookup(admName);
} catch (Exception e) {
Trace.errln ("Server.initialContext.lookup("+admName+") : " + e);
e.printStackTrace();
return;
}
}
.................
.................
////// Stops Server
if(sOption){
try{
admI.stopServer();
}catch (RemoteException ex) {
System.exit(0);
}
}
---------------------------------------------------
Best regards.
H�l�ne.
--
-=- H�l�ne JOANIN -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
mailto:[EMAIL PROTECTED] http://www-frec.bull.com
Phone: 33.4.76.29.73.53 Fax: 33.4.76.29.76.00
Download our EJB Server JOnAS at http://www.bullsoft.com/ejb
_______________________________________________________________