im using tomcat 7 , and im trying to do something nice.
i want to have a little swing program to operate my current project (a site)
i wish to have in that swing application a button to run the server , shut the server and such.
i know there is the option of running it as soon as i start the application but i dont want it. i want to have the option to click a swing button and load it.
for that , i need to run the server by code.
is there a way to load tomcat server via code?
A quick solution for this may be Using RunTime you can do this -
Runtime.getRuntime().exec("startup.bat");
similarly, to stop -
Runtime.getRuntime().exec("shutdown.bat");
Assuming both batch files exist in tomcat bin directory.
Related
I am trying to achieve the automatic update for my java web-start applicaiton. Logic: I am fetching the jnlp file from the server and comparing the timestamp with the current one. if there is difference then download the latest file and restart the application with javaws command. Now I have two problems. 1. I am not able to fetch the local jnlp file (because the location for jnlp file is different for different operating system as mentioned here 2. I am not able to find a graceful way to restart the application after killing the current running application. I would appreciate if there is any other graceful solution available. Thanks
I am trying to implement automatic update using java web start
But i am facing the following issue :
1)Not able to figure out a way to force/direct Java Web Start to check for updates in background when application is running.
2)Even,If I wrote a logic to check for updates manually in background thread , but then, I am not able to find a way to restart my application by running
my.jnlp file.
following similar questions on my issue ,I figured out Java Web Start provide some implementation as DownloadService which can be used to solve my issue.
But i didn't found any relevant example or pointer doc regarding utilisation of the DownloadService implementation.
Please Help.
I want to be able to stop my application from inside every 3 days. I just want to schedule a method that would automatically stop the application without any intervention from outside (like sitting on my desktop etc).
So far, I have these in mind:
Runtime.getRuntime().exec("rhc stop-app --app ApplicationName"); //This doesn't work. I have tried it
Or
System.exit(0) // I am told to not run this command on openshift server
Or
Runtime.getRuntime().exit(0) //I am afraid to run this command
Or
Runtime.getRuntime().halt(0) //I am afraid to run this command as well
Some of those commands I am afraid to use because I am told to not run them on openshift server as they may actually stop the whole vm. And that will stop all the applications that are hosted on that vm. And that will get me banned. I will get banned.
edit: This question is not how to stop an application generally. This question is regarding how to stop a Spring MVC wep application which is hosted on OpenShift server. And no those answers donot work in that link.
Well, I just used Runtime.getRuntime().exit(0) and it successfully stopped my application. I didn't get ban or anything. And I restarted my application to see if there are any issues. No Issues. So that command will do. Thanks
edit: This works but openshift restarts the application automatically. So this is not the answer. I will put the answer here if I find one. Thanks
I have a question regarding updating a application on websphere application server. The application is already up and running and I just want to update the code which is packaged in a .ear file. Here is what I thought I should do:
stop the application server.
go to my enterprise application, select the one I am updating, and click update.
point to my .ear file in replace the entire application radio button option.
restart my application server.
After doing this and trying out my application, it is still running the old code, which makes me really confused. The only way I managed to get it to work is to use WinSCP, manually go to the cell directly/installedapps and replace the whole .ear folder. I dont think this a viable solution moving forward.
I solved it. After some intense digging it seems the binary files were expanded into dmgr profile but not my correct node. After finishing the update instead of clicking save I click review and there is a checkbox to synchronize the nodes, which then did the trick.
To update existing enterprise application we do not have to stop the application since WAS stops the application before updating the code .
Based on the update you gave i am assuming this is a network deployment manager setup , so possibly problem is with sync is not taking place after updating the app and save .
Are you explicitly invoking sync operation after application update ? If not , i would recommend that.
Still problem persists then most likely for what ever reason nodeagent process is not invoking app expansion into installedApps folder but you can take a quick look at nodeagent systemout.log file or ffdc files to see if there is any clue about expansion process.
As a work-around you can also use EARExapnder.sh/bat tool available /profile_home/bin directory to expand the application into installedApps when the app is really updated in config/cells/cell_name/applications but not under installedApps folder.
I hope this helps.
Thanks
VT
These opinions are my own.
I have created a Java application which needs to run as a service. For service wrapper I tried using tanuki and other wrapper softwares.
Now, my application does run as a service - however, it runs as a service under SYSTEM and not under currently logged in user.
My application has a UI, which does not show when the application is running as a service. I doubt that this has happened because the service is running under SYSTEM and not under currently logged in user.
When I run the application (without installing it as a service), the UI does show up and I could see the java process running under the current user's id, whereas it runs under SYSTEM when installed as a service.
Now, there is nothing to my application if there is no UI. I need to application to run as a service when the system boots up and the UI needs to show up as well.
Has anyone tried to do what I am doing here and has faced a similar issue. If so, how did you go about resolving it?
Is there a different wrapper service that I could use and not have this issue.
Tanuki's documentation does explain setting a java application as a service, but does not talk about a java applicaiton with a UI and running it under the currently logged in user.
Update
Just so that folks here could get a bit more idea as to what is it that I am trying to accomplish - the behavior that I am trying to have with my app is similar to how Dropbox or Yahoo Messenger or any other software has which starts with Windows boot and continues to run in the background, allowing the users to interact with it using the system tray icon. So basically all of this has been built in Java/Swing. Now when it has come to deployment of the app - I can run it standalone but running the jar file or by creating and running an executable wrapper for it. However, I want the software to start with Windows boot and continue to run as a service in the background, while allowing the user to make changes and interact with it via lets say bringing up the UI from a system tray icon that it sets.
As of now, it does run as a service successfully. It performs all the actions that it ideally should - there just is no system tray icon to bring up the UI and make changes to its configuration.
Update - 2
Ok.. I tried advanced installer and it does wrap up everything for me to generate an exe installer for windows. Now all I need is to auto-start the software. Can anyone help me with this? I don't see an option in Advanced installer to automatically have the program add itself up in the auto-start.
Link to tanuki's doc http://wrapper.tanukisoftware.com/doc/english/faq.html
Rohan,
Please take a look at the following page:
http://wrapper.tanukisoftware.com/doc/english/prop-ntservice-interactive.html
You will need to mark the Service as interactive and then run as the SYSTEM user in order to get your GUI to show up on the first logged in desktop.
The problem is that Microsoft changed what services are allowed to do starting with Windows 2008 and Vista. This means that starting with these versions, the GUI will always show up on a sandboxed desktop which the user will need to switch over to.
If you want to show a GUI on all desktops, in all versions of Windows, you will need to run the JVM within the desktop.
Cheers,
Leif
I wanted to comment on your question, but I don't have enough reputation to do it. So I'm misusing the answer function now.
I have a similar problem. I used the tanuki wrapper for a while now on a Windows XP machine and the Swing GUI was shown to all users who logged in.
Now I migrated to Windows 2008 Server and configured the current version of the tanuki wrapper like this:
wrapper.ntservice.interactive=true
wrapper.ntservice.hide_console=true
(see documentation here and here)
The Windows service runs under the LOCAL SYSTEM account.
But the GUI is still not shown. Did you find any solution to the problem?
Don't think you should have a UI with a service. Put it in the startup group instead ?
What's does the UI and application do?
I'm using the Google AppEngine development server on Eclipse. My local webpage just doesn't seem to update until I do a number of restarts on the Development Server (using the Run or Debug buttons from Eclipse).
What am I doing wrong ?
The basic flow is:
Make change to .java file...
Save file
Run application (development server loading log shows in console)
Refresh web page in browser
P.S: The only way I can get it to work is to change the server port... and if I do that all the previous servers still show at their respective ports. They never stop.
You do need to restart the server to see most code changes you'll make. The easiest way to do this is with the yellow reload button that appears on the GAE pane - not the console, but the one that has the fancy "click here to launch" addresses.
If you do use the debug / run commands in eclipse, you will need to explicitly stop the previous run. You can do this from the debug menu (the stop button) or from the GAE pane or from the console pane.
You won't need to change the ports after this - the reason you have to do it now is that the first instance is still running, hogging the port. Once you stop it you'll be able to run it again on the same port... WITH your code changes! :)