You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Mariano López <ma...@gmail.com> on 2015/05/07 18:29:14 UTC
How to know aliases defined in container in server.xml of
Tomcat 7.0.61
Hi all, I want to know all the aliases defined in <host> container in
server.xml of Tomcat 7.0.61
My server.xml has the following configuration:
..
<Service name="Catalina">
..
<Engine defaultHost="localhost" name="Catalina">
..
<Host appBase="webapps" autoDeploy="true" name="localhost"
unpackWARs="true">
<alias>alias1.server</alias>
<alias>alias2.server</alias>
<alias>alias3.server</alias>
<alias>alias4.server</alias>
..
<Context docBase="XXXX" path="/XXX" reloadable="true"
source="org.eclipse.jst.jee.server:CrystalReportWeb"/></Host>
</Engine>
</Service>
..
I want to retrieve all this posibles "alias" defined in host contanier.
I use the following code:
Server servidorTomcat = null;
MBeanServer mBeanServer =
MBeanServerFactory.findMBeanServer(null).get(0);
ObjectName catalinaNombre = null;
ObjectName hostNombre = null;
try {
catalinaNombre = new ObjectName("Catalina","type","Server");
} catch (MalformedObjectNameException e) {
this.error = true;
this.errorDescripcion = "'MalformedObjectNameException' en " +
"Jsfthis.getTomcat7Servidor(). " +
"Error: " + e.getMessage();
} catch (Exception e) {
this.error = true;
this.errorDescripcion = "'Exception' en " +
"Jsfthis.getTomcat7Servidor(). " +
"Error: " + e.getMessage();
}
try {
servidorTomcat = (Server) mBeanServer.getAttribute(
catalinaNombre, "managedResource");
StandardEngine engineTomcat = (StandardEngine)
servidorTomcat.findService("Catalina").getContainer();
Host hostTomcat = (Host) engineTomcat.findChild( "localhost" );
String[] tomcat7HostAlias = hostTomcat.findAliases();
} catch (AttributeNotFoundException e) {
this.error = true;
this.errorDescripcion = "'AttributeNotFoundException' en " +
"Jsfthis.getTomcat7Servidor(). " +
"Error: " + e.getMessage();
} catch (InstanceNotFoundException e) {
this.error = true;
this.errorDescripcion = "'InstanceNotFoundException' en " +
"Jsfthis.getTomcat7Servidor(). " +
"Error: " + e.getMessage();
} catch (MBeanException e) {
this.error = true;
this.errorDescripcion = "'MBeanException' en " +
"Jsfthis.getTomcat7Servidor(). " +
"Error: " + e.getMessage();
} catch (ReflectionException e) {
this.error = true;
this.errorDescripcion = "'ReflectionException' en " +
"Jsfthis.getTomcat7Servidor(). " +
"Error: " + e.getMessage();
} catch (Exception e) {
this.error = true;
this.errorDescripcion = "'Exception' en " +
"Jsfthis.getTomcat7Servidor(). " +
"Error: " + e.getMessage();
}
Everythings seem to work fine, but String[] tomcat7HostAlias always returns
zero length array.
I don't know what i am doing wrong.
Please help.
Regads,
Mariano
Re: How to know aliases defined in container in server.xml of
Tomcat 7.0.61
Posted by Mariano López <ma...@gmail.com>.
WOW !!!
I can't believe it.
If I was looking the code for years i wasn't able to see.
Sorry for this stupid post and thank you very much Konstantin
Mariano
2015-05-07 23:00 GMT+02:00 Konstantin Kolinko <kn...@gmail.com>:
> 2015-05-07 19:29 GMT+03:00 Mariano López <ma...@gmail.com>:
> > Hi all, I want to know all the aliases defined in <host> container in
> > server.xml of Tomcat 7.0.61
> >
> > My server.xml has the following configuration:
> >
> > ..
> > <Service name="Catalina">
> >
> > ..
> > <Engine defaultHost="localhost" name="Catalina">
> > ..
> > <Host appBase="webapps" autoDeploy="true" name="localhost"
> > unpackWARs="true">
> >
> > <alias>alias1.server</alias>
> > <alias>alias2.server</alias>
> > <alias>alias3.server</alias>
> > <alias>alias4.server</alias>
>
>
> You have no aliases defined with the above configuration, because XML
> is a case-sensitive markup language.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Re: How to know aliases defined in container in server.xml of
Tomcat 7.0.61
Posted by Konstantin Kolinko <kn...@gmail.com>.
2015-05-07 19:29 GMT+03:00 Mariano López <ma...@gmail.com>:
> Hi all, I want to know all the aliases defined in <host> container in
> server.xml of Tomcat 7.0.61
>
> My server.xml has the following configuration:
>
> ..
> <Service name="Catalina">
>
> ..
> <Engine defaultHost="localhost" name="Catalina">
> ..
> <Host appBase="webapps" autoDeploy="true" name="localhost"
> unpackWARs="true">
>
> <alias>alias1.server</alias>
> <alias>alias2.server</alias>
> <alias>alias3.server</alias>
> <alias>alias4.server</alias>
You have no aliases defined with the above configuration, because XML
is a case-sensitive markup language.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org