Question

I am running tomcat 7 and I have 2 virtual host configured on a testing server. Call them "hostA" and "hostB".

Works just fine but I now want to use javamelody to monitor both apps. Using javamelody on just 1 app works as expected. but when deploying javamelody to both app at the same time there are problems.

Looking in tomcat/temp/javamelody/ I see that there are different directory's created for each context. Unfortunately javamelody is seeing hostA and hostB as both the same context (ROOT).

In short javamelody cant tell the difference between hostA and hostB, because both are ROOT contexts even though there are configured as different virtual hosts javamelody ignores this.

I am looking for a way to monitor the apps, but for production purposes I need them to be ROOT contexts or the user will see the URL incorrect.

eg must be

www.hostA.co.uk

www.hostB.co.uk

Not

www.hostA.co.uk/contextA/

www.hostB.co.uk/contextB/

Thanks

Was it helpful?

Solution

I have resolved this problem, I found a setting in javamelody that lets you set a custom storage directory, Now both contexts are root but the data is separate so there is no conflict.

changed part of server.xml follows

<Host name="localhost"  appBase="webappsA/">
  <Context docBase="ROOT" path="" reloadable="false" >
    <Parameter name='javamelody.storage-directory' value='storeA'/>
  </Context>
</Host>

<Host name="127.0.0.1"  appBase="webappsB/"> 
  <Context docBase="ROOT" path="" reloadable="false" >
    <Parameter name='javamelody.storage-directory' value='storeB'/>
  </Context>
</Host>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top