Using JavaMelody on a regular (non webApp) JVM - java

My system is divided to 2 or 3 servers architecture, and only one server has a webApp
Since we use javaMelody to monitor the webApp server, is there a way to use on a regular, no-
webApp JVM, and if so, how can we access the data

I would say include your application into a webapp (a war file for example) then deploy it in a server like Tomcat or Jetty. By the way, Tomcat or Jetty can be embedded.
Otherwise, there is currently no way to do this.

Related

deployed webapps health in jetty server

I understand enabling JMX in jetty, we can fetch some information about deployed webapps.
Can Jetty also provide enough information to indicate that a given webapp is up and running, or some metrics that can be considered to identify the state of deployed webapps?
Perform a Jetty Server Dump.
https://www.eclipse.org/jetty/documentation/current/jetty-dump-tool.html
This will output the state of all relevant components within Jetty.
This can be accessed via the various "dump" methods on Server (choose the one that you want).
You can trigger this Jetty Server Dump within JMX as well.
Alternatively, you can ask each of the deployed webapps their running state.
Use the org.eclipse.jetty.util.component.LifeCycle interface, and the .isRunning() method.
The LifeCycle interface is available on all deployed webapps, even if they are an instance of WebAppContext (for war files), or ServletContextHandler for manually created webapps, or even ContextHandler for "bare metal" handling of requests.

how to configure Embedded Tomcat virtual host for Spring Boot Application?

i have a multiple domains on my centos vps (domains running on apache http server via virtual host configurations). and also same vps, i want to add my new domain but that domain will route my spring boot application (application is a jar file also inside embedded tomcat ). i couldn't find any configuration for embedded tomcat specific domains and ports.
standalone Tomcat i can make configuration via server.xml file like this image
also this short tutorial shows configuration for stadalone tomcat Tomcat Virtual Host Configuration
But how can i do that configuration for embedded Tomcat ? Any suggestion ?
With Spring Boot embedded Tomcat, you are hosting only one application per servlet container. So I don't believe that Tomcat's concept of Virtual Hosts make sense at all.
If you have to host your app on shared Tomcat instance, just build WAR without embedded container.
It depends. 2 ways to deploy your project.jar as you want to :
First way : You can use the "apache web server" and his own "mod_proxy" in order to serve as many Spring webapps you want to, each on a specific port configured with "php-fpm" and with a proxy defined to route requests from/to your namebased VirtualHost configuration.
Nowadays, with Spring Boot 2.5, all you have to do is to set the property server.port in your application.properties file, and use it accordingly with mod_proxy directives.
If you are using profile, you can either set one port to dev or prod or test or whatever properties file you need.
Another way to proceed : you can use the apache web server "mod_jk" bridge module to configure multiple load-balancers for your Virtualhosts too.
Choose your path, young Jedi ;)
This response is certainly not for the OP, 7 years later, but for other people whom are using any web search engine like Google. They will come here and see "something is impossible". It is not true.

Accessing Tomcat 8 JNDI from Standalone JVM

I have a legacy webapp recently converted to running on a Tomcat 8 server that calls a java command (Runtime.getRuntime().exec) in the contextInitialized method. This java program then needs to lookup and use the resources (database info) that are set up in the Tomcat context.xml file. It doesn't appear that Tomcat exposes these resources like Websphere.
So what is my best route to access these resources in this separate JVM? Maybe there is a context friendly way to spin off the java process?
Simply put, you can't. The JNDI context is available as read-only from within the webapp.

how to manage multiple war application in tomcat server?

I use tomcat as web server,I want to deploy many same war file in tomcat server with different config. How to do this in the best way possible manner?
So I want to run tomcat server per each war application, my means is tomcat1 handle the .war1 in webapp and ... or handle all war files with one tomcat?which one is better?
Change the names of your war files and deploy
Use the same tomcat server, but copy and rename your web application to something different. For eg, the original application name app, copy and rename as following.
webapp -> app1
app2
app3
Running a different tomcat server for each war application might not be necessary.

How to redeploy a war in tomcat seamlessly?

I just packaged my maven web application into a war file, upload it to remote server which has installed the tomcat environment. After I unpacked my war file and put all files in the /webapps/ROOT directory, I run bin/startup.sh to fire up the tomcat.
This just works fine, but when I intend to change my web application and redeploy it on the server, I don't know how to do that seamlessly, that is to say, not letting the users who is using my website lose any request.
Could anyone give me some idea? Thanks a lot!
You can always use manager app coming with tomcat to deploy a war without bringing the website down, even from a remote machine using browser.
http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html#Deploy_A_New_Application_Remotely
You may use reverse proxy as door of you site. After deploying your "second" war into Tomcat, you can change the configuration of reverse proxy and reload it. The reloading of reverse proxy is very speedy, so that it likes "seamless" re-deployment of Java web application. After the reloading of reverse proxy, you could un-deploy "first" war of application safely.
This way to re-deploy is especially useful if the application needs time for initialization(for example: including ORM, Spring Framework...).
There are few concerns about using multiple-war-at-the-same-time:
1) There will be two applications(although, temporary) running on your Tomcat concurrently, make sure there is nothing hazard about concurrent executing. For example: scheduled jobs
2) You need to confirm that there is enough memory on Tomcat to live with two web applications, or Tomcat may hang.
3) Be meticulous about Java.lang.OutOfMemory: PermGen Space problem

Categories

Resources