Re: adding a virtual host with jmx

2008-09-02 Thread Olivier Vergès
yeah i've followed it, but i'm just lost with the first lines:

* ObjectName loader = getServerLoader(); // depends on the settings and*
* version
   ObjectName registry = getRegistry(); // depends on the settings and
version
   MBeanServer server = getTCMBeansServer(); // generally the first one,
unless you (or your J2EE) are playing games
*

For now; I get a MBeanServerConnection and I can invoke the differents
methods like this:

  JMXServiceURL url = new JMXServiceURL(service:jmx:rmi:///jndi/rmi:// +
hostIPAddress + /jmxrmi);
  JMXConnector   conn = JMXConnectorFactory.connect(url);
   MBeanServerConnectionmbsc = conn.getMBeanServerConnection();


ObjectName objectName = new
ObjectName(Catalina:type=MBeanFactory);
Object[] params =
{Catalina:type=Host,host=+nameVH,/manager,/data/tomcat/server/manager};
String[] signature = {String.class.getName(),
String.class.getName(), String.class.getName()};

 mbsc.invoke(objectName, createStandardContext, params,
signature);

That's how i create a context for a given host. But like the there is no
addSSOAgentValve, that's why i'm trying to use bill's code .

O.V



2008/9/1 Martin Gainty [EMAIL PROTECTED]


 did you follow bill's code sample ?...did you have different result?also
 please display the exact structure and calls you are making to instantiate
 your javax.management.MBeanServerand which class is executing the addChild

 javadocs located at

 http://java.sun.com/j2ee/1.4/docs/api/javax/management/package-summary.htmlthanks/Martin__
  Disclaimer and
 confidentiality note Everything in this e-mail and any attachments relates
 to the official business of Sender. This transmission is of a confidential
 nature and Sender does not endorse distribution to any party other than
 intended recipient. Sender does not necessarily endorse content contained
 within this transmission.  Date: Mon, 1 Sep 2008 21:57:55 +0200 From:
 [EMAIL PROTECTED] To: users@tomcat.apache.org Subject: Re: adding
 a virtual host with jmx  hi, so i'm using tomcat 6.0.15.  I'm trying
 now to add a josso valve: Valve
 className=org.josso.tc60.agent.SSOAgentValve debug=1/ always by jmx. 
 I don't get your lines, in fact...  Could you please help me a little
 more?  O.V 2008/7/31 Bill Barker [EMAIL PROTECTED]  
 It's a lot of lines of code, but not that hard. You haven't mentioned your
  Tomcat version, so I'll give a sort of generic setup.  ObjectName loader
 = getServerLoader(); // depends on the settings and  version  ObjectName
 registry = getRegistry(); // depends on the settings and  version 
 MBeanServer server = getTCMBeansServer(); // generally the first one, 
 unless you (or your J2EE) are playing games   String hname =
 Catalina:type=Host,host=+hostName; // Assuming the  default Engine name
 of Catalina  ObjectName ohost = new ObjectName(hname);  Object host =
 server.instantiate(HOST_CLASS, loader);  server.invoke(registry,
 registerComponent,  new Object[] {host, hname, null},  new String[] 
 {java.lang.Object,java.lang.String,java.lang.String}); 
 server.setAttribute(ohost, new Attribute(appBase, appBase));  // Set
 more attributes, and aliases etc here  // Things like Realms and Contexts
 work much the same way if you follow  Tomcat's naming conventions 
 server.invoke(ohost, start, null, null);  // Start your contexts here,
 if you don't have automatic deployment set.   As long as you follow
 Tomcat's naming conventions for ObjectNames, invoking  start will
 automagically add the new elements to where they should live.  You can get
 the values for the loader and registry by hooking up a JMX  console to
 your existing Tomcat.   Olivier Vergès [EMAIL PROTECTED]
 wrote in message 
 news:[EMAIL PROTECTED]  
 hi all, I'm creating a web application for auto deploying virtual
 host through   apache and tomcat on a production server.   Everything
 is ok except for the Tomcat part:   As tomcat can't be reloaded and as i
 can't restart anytime I want, I  've   heard jmx was great cause it was
 possible to modify a running tomcat (is   the   english expression is
 on the fly?). So, Connection to Mbean server is ok...
 My problem is :   when i invoke the addChild
 (org.apache.catalina.core.Container) method of   Engine I get this
 error:   java.io.NotSerializableException:  
 org.apache.catalina.util.LifecycleSupport   at  
 java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)  
 at   
 java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)...
   So i try to create my own
 addChildByString(String;String,String,String)   which takes the appabase
 and the name of th virtual host, and path and   docBase of the first
 needed context. But i've got a problem with the   context   now,  
  GRAVE: Error getConfigured (and nothing else) i'm a little lost
 with all the classes and functions and I haven't found   any   docs
 about adding vh

Re: adding a virtual host with jmx

2008-09-02 Thread Olivier Vergès
I've found these

*  ObjectName loader = new
ObjectName(Catalina:type=ServerClassLoader,name=common);
**
   MBeanServer server =
java.lang.management.ManagementFactory.getPlatformMBeanServer();
  *
but registry is not in my JMX.

O.V

2008/9/2 Olivier Vergès [EMAIL PROTECTED]


 yeah i've followed it, but i'm just lost with the first lines:

 * ObjectName loader = getServerLoader(); // depends on the settings and*
 * version
ObjectName registry = getRegistry(); // depends on the settings and
 version
MBeanServer server = getTCMBeansServer(); // generally the first one,
 unless you (or your J2EE) are playing games
 *

 For now; I get a MBeanServerConnection and I can invoke the differents
 methods like this:

   JMXServiceURL url = new JMXServiceURL(service:jmx:rmi:///jndi/rmi:// +
 hostIPAddress + /jmxrmi);
   JMXConnector   conn = JMXConnectorFactory.connect(url);
MBeanServerConnectionmbsc = conn.getMBeanServerConnection();


 ObjectName objectName = new
 ObjectName(Catalina:type=MBeanFactory);
 Object[] params =
 {Catalina:type=Host,host=+nameVH,/manager,/data/tomcat/server/manager};
 String[] signature = {String.class.getName(),
 String.class.getName(), String.class.getName()};

  mbsc.invoke(objectName, createStandardContext, params,
 signature);

 That's how i create a context for a given host. But like the there is no
 addSSOAgentValve, that's why i'm trying to use bill's code .

 O.V



 2008/9/1 Martin Gainty [EMAIL PROTECTED]


 did you follow bill's code sample ?...did you have different result?also
 please display the exact structure and calls you are making to instantiate
 your javax.management.MBeanServerand which class is executing the addChild

 javadocs located at

 http://java.sun.com/j2ee/1.4/docs/api/javax/management/package-summary.htmlthanks/Martin__
  Disclaimer and
 confidentiality note Everything in this e-mail and any attachments relates
 to the official business of Sender. This transmission is of a confidential
 nature and Sender does not endorse distribution to any party other than
 intended recipient. Sender does not necessarily endorse content contained
 within this transmission.  Date: Mon, 1 Sep 2008 21:57:55 +0200 From:
 [EMAIL PROTECTED] To: users@tomcat.apache.org Subject: Re:
 adding a virtual host with jmx  hi, so i'm using tomcat 6.0.15.  I'm
 trying now to add a josso valve: Valve
 className=org.josso.tc60.agent.SSOAgentValve debug=1/ always by jmx. 
 I don't get your lines, in fact...  Could you please help me a little
 more?  O.V 2008/7/31 Bill Barker [EMAIL PROTECTED]  
 It's a lot of lines of code, but not that hard. You haven't mentioned your
  Tomcat version, so I'll give a sort of generic setup.  ObjectName loader
 = getServerLoader(); // depends on the settings and  version  ObjectName
 registry = getRegistry(); // depends on the settings and  version 
 MBeanServer server = getTCMBeansServer(); // generally the first one, 
 unless you (or your J2EE) are playing games   String hname =
 Catalina:type=Host,host=+hostName; // Assuming the  default Engine name
 of Catalina  ObjectName ohost = new ObjectName(hname);  Object host =
 server.instantiate(HOST_CLASS, loader);  server.invoke(registry,
 registerComponent,  new Object[] {host, hname, null},  new String[] 
 {java.lang.Object,java.lang.String,java.lang.String}); 
 server.setAttribute(ohost, new Attribute(appBase, appBase));  // Set
 more attributes, and aliases etc here  // Things like Realms and Contexts
 work much the same way if you follow  Tomcat's naming conventions 
 server.invoke(ohost, start, null, null);  // Start your contexts here,
 if you don't have automatic deployment set.   As long as you follow
 Tomcat's naming conventions for ObjectNames, invoking  start will
 automagically add the new elements to where they should live.  You can get
 the values for the loader and registry by hooking up a JMX  console to
 your existing Tomcat.   Olivier Vergès [EMAIL PROTECTED]
 wrote in message 
 news:[EMAIL PROTECTED]  
 hi all, I'm creating a web application for auto deploying virtual
 host through   apache and tomcat on a production server.   Everything
 is ok except for the Tomcat part:   As tomcat can't be reloaded and as i
 can't restart anytime I want, I  've   heard jmx was great cause it was
 possible to modify a running tomcat (is   the   english expression is
 on the fly?). So, Connection to Mbean server is ok...
 My problem is :   when i invoke the addChild
 (org.apache.catalina.core.Container) method of   Engine I get this
 error:   java.io.NotSerializableException:  
 org.apache.catalina.util.LifecycleSupport   at  
 java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)  
 at   
 java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)...
   So i try to create my own
 addChildByString(String;String,String,String)   which takes

Re: adding a virtual host with jmx

2008-09-02 Thread Olivier Vergès
it works in part, i have done  this to add a ssoagentvalve:
*
String vname = Catalina:type=Valve,name=SSOAgentValve,host= + nameVH;
ObjectName ovalve = new ObjectName(vname);

Object valve =
server.instantiate(org.josso.tc60.agent.SSOAgentValve);


org.apache.tomcat.util.modeler.Registry.getRegistry().registerComponent(valve,
vname, null);

  *
but the *controller* and *containerName* stay empty. So I've tried to use
that :
* server.setAttribute(ovalve, new
Attribute(containerName,Catalina:type=Host,host= + nameVH ));

  *And it doesn't work for both of them cause theses are not writable.
I'm going to try to use the host's function addchild  but that was my first
problem: this function doesnt' seem to work and i'm not sure that it will
fill the two missing parameters on the valve...

So, anyone got an idea?

O.V


Re: adding a virtual host with jmx

2008-09-01 Thread Olivier Vergès
hi,
 so i'm using tomcat 6.0.15.

I'm trying  now to add a josso valve:  Valve
className=org.josso.tc60.agent.SSOAgentValve debug=1/ always by jmx.

I don't  get your lines, in fact...

Could you please help me a little more?

O.V




2008/7/31 Bill Barker [EMAIL PROTECTED]

 It's a lot of lines of code, but not that hard.  You haven't mentioned your
 Tomcat version, so I'll give a sort of generic setup.
ObjectName loader = getServerLoader(); // depends on the settings and
 version
ObjectName registry = getRegistry(); // depends on the settings and
 version
MBeanServer server = getTCMBeansServer(); // generally the first one,
 unless you (or your J2EE) are playing games

String hname = Catalina:type=Host,host=+hostName; // Assuming the
 default Engine name of Catalina
ObjectName ohost = new ObjectName(hname);
Object host = server.instantiate(HOST_CLASS, loader);
server.invoke(registry, registerComponent,
new Object[] {host, hname, null},
new String[]
 {java.lang.Object,java.lang.String,java.lang.String});
server.setAttribute(ohost, new Attribute(appBase, appBase));
//  Set more attributes, and aliases etc here
// Things like Realms and Contexts work much the same way if you follow
 Tomcat's naming conventions
server.invoke(ohost, start, null, null);
// Start your contexts here, if you don't have automatic deployment set.

 As long as you follow Tomcat's naming conventions for ObjectNames, invoking
 start will automagically add the new elements to where they should live.
 You can get the values for the loader and registry by hooking up a JMX
 console to your existing Tomcat.

 Olivier Vergès [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  hi all,
 
  I'm creating a web application for auto deploying virtual host through
  apache and tomcat on a production server.
  Everything is ok except for the Tomcat part:
  As tomcat can't be reloaded  and as i can't restart anytime I want,  I
 've
  heard jmx was great cause it was possible to modify a running tomcat (is
  the
  english expression is on the fly?).
 
  So, Connection to Mbean server is ok...
 
  My problem is :
  when i invoke the addChild (org.apache.catalina.core.Container) method of
  Engine I get this error:
  java.io.NotSerializableException:
  org.apache.catalina.util.LifecycleSupport
   at
  java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
   at
 
 java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)...
 
 
  So i try to create my own addChildByString(String;String,String,String)
  which takes the appabase and the name of th virtual host, and path and
  docBase of the first needed context. But i've got a problem with the
  context
  now,
   GRAVE: Error getConfigured (and nothing else)
 
  i'm a little lost with all the classes and functions and I haven't found
  any
  docs about adding vh by jmx.
 
  has anyone tried to add and directly make worked a virtual host and a
  context on a running tomcat ?
 
  thx,
  Olivier
 




 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




RE: adding a virtual host with jmx

2008-09-01 Thread Martin Gainty

did you follow bill's code sample ?...did you have different result?also please 
display the exact structure and calls you are making to instantiate your 
javax.management.MBeanServerand which class is executing the addChild
 
javadocs located at
http://java.sun.com/j2ee/1.4/docs/api/javax/management/package-summary.htmlthanks/Martin
 __ Disclaimer and confidentiality 
note Everything in this e-mail and any attachments relates to the official 
business of Sender. This transmission is of a confidential nature and Sender 
does not endorse distribution to any party other than intended recipient. 
Sender does not necessarily endorse content contained within this transmission. 
 Date: Mon, 1 Sep 2008 21:57:55 +0200 From: [EMAIL PROTECTED] To: 
users@tomcat.apache.org Subject: Re: adding a virtual host with jmx  hi, so 
i'm using tomcat 6.0.15.  I'm trying now to add a josso valve: Valve 
className=org.josso.tc60.agent.SSOAgentValve debug=1/ always by jmx.  I 
don't get your lines, in fact...  Could you please help me a little more?  
O.V 2008/7/31 Bill Barker [EMAIL PROTECTED]   It's a lot of lines 
of code, but not that hard. You haven't mentioned your  Tomcat version, so 
I'll give a sort of generic setup.  ObjectName loader = getServerLoader(); // 
depends on the settings and  version  ObjectName registry = getRegistry(); 
// depends on the settings and  version  MBeanServer server = 
getTCMBeansServer(); // generally the first one,  unless you (or your J2EE) 
are playing games   String hname = Catalina:type=Host,host=+hostName; // 
Assuming the  default Engine name of Catalina  ObjectName ohost = new 
ObjectName(hname);  Object host = server.instantiate(HOST_CLASS, loader);  
server.invoke(registry, registerComponent,  new Object[] {host, hname, 
null},  new String[]  
{java.lang.Object,java.lang.String,java.lang.String});  
server.setAttribute(ohost, new Attribute(appBase, appBase));  // Set more 
attributes, and aliases etc here  // Things like Realms and Contexts work 
much the same way if you follow  Tomcat's naming conventions  
server.invoke(ohost, start, null, null);  // Start your contexts here, if 
you don't have automatic deployment set.   As long as you follow Tomcat's 
naming conventions for ObjectNames, invoking  start will automagically add 
the new elements to where they should live.  You can get the values for the 
loader and registry by hooking up a JMX  console to your existing 
Tomcat.   Olivier Vergès [EMAIL PROTECTED] wrote in message  
news:[EMAIL PROTECTED]   hi all, I'm creating a web application 
for auto deploying virtual host through   apache and tomcat on a production 
server.   Everything is ok except for the Tomcat part:   As tomcat can't 
be reloaded and as i can't restart anytime I want, I  've   heard jmx was 
great cause it was possible to modify a running tomcat (is   the   
english expression is on the fly?). So, Connection to Mbean server 
is ok... My problem is :   when i invoke the addChild 
(org.apache.catalina.core.Container) method of   Engine I get this error:  
 java.io.NotSerializableException:   
org.apache.catalina.util.LifecycleSupport   at   
java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)   at 
   
java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)...
   So i try to create my own 
addChildByString(String;String,String,String)   which takes the appabase and 
the name of th virtual host, and path and   docBase of the first needed 
context. But i've got a problem with the   context   now,GRAVE: 
Error getConfigured (and nothing else) i'm a little lost with all 
the classes and functions and I haven't found   any   docs about adding 
vh by jmx. has anyone tried to add and directly make worked a virtual 
host and a   context on a running tomcat ? thx,   Olivier   
 
-  To 
start a new topic, e-mail: users@tomcat.apache.org  To unsubscribe, e-mail: 
[EMAIL PROTECTED]  For additional commands, e-mail: [EMAIL PROTECTED]  
_
Talk to your Yahoo! Friends via Windows Live Messenger.  Find out how.
http://www.windowslive.com/explore/messenger?ocid=TXT_TAGLM_WL_messenger_yahoo_082008

Re: adding a virtual host with jmx

2008-07-31 Thread Olivier Vergès
oh sorry I've forgot, i'm using tomcat 6.0.
Thx for your help... but like i didn't know the english expression on the
fly, i wasn't able to find docs.
now, yes... and i've found.

so org.apache.catalina.Mbeans is full of useful functions (like
createStandardHost...)
(I've spent a lot of time to find something  under my nose ...)

thx again, i keep your code in case (and better understand all of that).

Regards,

O.V.

2008/7/31 Bill Barker [EMAIL PROTECTED]

 It's a lot of lines of code, but not that hard.  You haven't mentioned your
 Tomcat version, so I'll give a sort of generic setup.
ObjectName loader = getServerLoader(); // depends on the settings and
 version
ObjectName registry = getRegistry(); // depends on the settings and
 version
MBeanServer server = getTCMBeansServer(); // generally the first one,
 unless you (or your J2EE) are playing games

String hname = Catalina:type=Host,host=+hostName; // Assuming the
 default Engine name of Catalina
ObjectName ohost = new ObjectName(hname);
Object host = server.instantiate(HOST_CLASS, loader);
server.invoke(registry, registerComponent,
new Object[] {host, hname, null},
new String[]
 {java.lang.Object,java.lang.String,java.lang.String});
server.setAttribute(ohost, new Attribute(appBase, appBase));
//  Set more attributes, and aliases etc here
// Things like Realms and Contexts work much the same way if you follow
 Tomcat's naming conventions
server.invoke(ohost, start, null, null);
// Start your contexts here, if you don't have automatic deployment set.

 As long as you follow Tomcat's naming conventions for ObjectNames, invoking
 start will automagically add the new elements to where they should live.
 You can get the values for the loader and registry by hooking up a JMX
 console to your existing Tomcat.

 Olivier Vergès [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  hi all,
 
  I'm creating a web application for auto deploying virtual host through
  apache and tomcat on a production server.
  Everything is ok except for the Tomcat part:
  As tomcat can't be reloaded  and as i can't restart anytime I want,  I
 've
  heard jmx was great cause it was possible to modify a running tomcat (is
  the
  english expression is on the fly?).
 
  So, Connection to Mbean server is ok...
 
  My problem is :
  when i invoke the addChild (org.apache.catalina.core.Container) method of
  Engine I get this error:
  java.io.NotSerializableException:
  org.apache.catalina.util.LifecycleSupport
   at
  java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
   at
 
 java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)...
 
 
  So i try to create my own addChildByString(String;String,String,String)
  which takes the appabase and the name of th virtual host, and path and
  docBase of the first needed context. But i've got a problem with the
  context
  now,
   GRAVE: Error getConfigured (and nothing else)
 
  i'm a little lost with all the classes and functions and I haven't found
  any
  docs about adding vh by jmx.
 
  has anyone tried to add and directly make worked a virtual host and a
  context on a running tomcat ?
 
  thx,
  Olivier
 




 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




Re: adding a virtual host with jmx

2008-07-30 Thread Bill Barker
It's a lot of lines of code, but not that hard.  You haven't mentioned your 
Tomcat version, so I'll give a sort of generic setup.
ObjectName loader = getServerLoader(); // depends on the settings and 
version
ObjectName registry = getRegistry(); // depends on the settings and 
version
MBeanServer server = getTCMBeansServer(); // generally the first one, 
unless you (or your J2EE) are playing games

String hname = Catalina:type=Host,host=+hostName; // Assuming the 
default Engine name of Catalina
ObjectName ohost = new ObjectName(hname);
Object host = server.instantiate(HOST_CLASS, loader);
server.invoke(registry, registerComponent,
new Object[] {host, hname, null},
new String[] 
{java.lang.Object,java.lang.String,java.lang.String});
server.setAttribute(ohost, new Attribute(appBase, appBase));
//  Set more attributes, and aliases etc here
// Things like Realms and Contexts work much the same way if you follow 
Tomcat's naming conventions
server.invoke(ohost, start, null, null);
// Start your contexts here, if you don't have automatic deployment set.

As long as you follow Tomcat's naming conventions for ObjectNames, invoking 
start will automagically add the new elements to where they should live. 
You can get the values for the loader and registry by hooking up a JMX 
console to your existing Tomcat.

Olivier Vergès [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 hi all,

 I'm creating a web application for auto deploying virtual host through
 apache and tomcat on a production server.
 Everything is ok except for the Tomcat part:
 As tomcat can't be reloaded  and as i can't restart anytime I want,  I 've
 heard jmx was great cause it was possible to modify a running tomcat (is 
 the
 english expression is on the fly?).

 So, Connection to Mbean server is ok...

 My problem is :
 when i invoke the addChild (org.apache.catalina.core.Container) method of
 Engine I get this error:
 java.io.NotSerializableException:
 org.apache.catalina.util.LifecycleSupport
  at
 java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
  at
 java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)...


 So i try to create my own addChildByString(String;String,String,String)
 which takes the appabase and the name of th virtual host, and path and
 docBase of the first needed context. But i've got a problem with the 
 context
 now,
  GRAVE: Error getConfigured (and nothing else)

 i'm a little lost with all the classes and functions and I haven't found 
 any
 docs about adding vh by jmx.

 has anyone tried to add and directly make worked a virtual host and a
 context on a running tomcat ?

 thx,
 Olivier
 




-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]