GWT - Gracefully detect that Tomcat is restarting - java

I have a enterprise GWT product that runs on Tomcat8 on a retail store's local server. I have an independent daemon running that check for and installs updates The update process consists of downloading the file, stopping Tomcat, putting the updated file in place, and restarting Tomcat.
Now, if the user has this scheduled for 2 in the morning when no one is using the app, that's fine.
But, they also have the option to go into the admin settings and manually click a button to apply the update. When they do this, I'd like to be able to put up some sort of page when someone tries to access the app saying it's upgrading, and then have the browser refresh when it's back online (if they are sitting on the temp page.)
Does Tomcat facilitate this somehow? I don't feel like GWT can, because Tomcat isn't serving it up for it to be able to do anything. My app can be installed on Windows or CentOS, if that matters.

To address your issue we can do any one of the following
Once user click on upgrade button start showing him some masked view. Behind this view you can write down a timer which will keep hitting some dummy serivce/rpc call from server after specific time interval. Based on the response code you can understand whether tomcat is up or not.
We can write down some kind of web socket. Which do above job for us and try to connect automatically once server is up and running. Using events from such socket we can hide our upgrading view and take back user to required screen.

Related

Changes in HTML not reflected as long as I am using proxy

I shifted from Eclipse to Jdeveloper. I had a weird problem that I was able to solve but not able to understand.
Whenever I made any changes in HTML in Jdeveloper's web projects the changes were not reflected when I ran the HTML again. The old webpages kept coming in the webbrowser. Same source code. Same CSS/JS. I found that as long as there were proxy settings in my web browser the changes were not reflected. But if I switched off the proxy the changes made in HTML were reflected i.e webpage were displayed with the changes made from last time.
By proxy set I mean proxy setting placed at the following
Window -> Start Menu -> internet options -> Connections -> LAN Settings -> Proxy Server
I have tried to run the resulting URL on Google chrome, Firefox and internet explorer. As long as the web browser was using proxy the changes made in HTML were not shown by running it again.
In Eclipse Juno I simply had to clean Tomcat's directory to get changes reflected.
Anyone can explain why this happens?
Web servers return HTTP headers with every response, and usually those headers specify how long the response can be cached for. Proxy servers read those headers and make a decision whenever they see the same request again -- whether to propagate that request to the server again, or to simply return the cached copy of the response.
You can modify your server's configuration so that it the next time it tells the proxy server not to cache pages. However, some proxy servers are mis-configured or broken, and will cache pages that they are not supposed to cache.
For those cases, one ugly solution that works is to give your JS and CSS files new names whenever you change them. For example, if your index.html file includes index.css and index.js, and you make a change to index.js, you can save the changed file as index.2.js and change the tag in your index.html file to point to index.2.js from now on.
That's a bit drastic, but it works. A simpler solution to start with is to refresh your page using Shift-F5 rather than just F5 (in your browser). That tells the browser to force a refresh of all cached pages, whenever possible.
This seems tied to your proxy server type. There are several proxy server types, one of which is a "Caching Proxy Server". Which, if many users are connected to it, allows static pages to be stored locally on the server for repetitive requests from the client(you). When you change the proxy it is most likely just sending you an updated copy due to not having you as an active client, or being that you are a new user.
I would assume that the content on the new software you are building is precaching saved page names where as Eclipse Juno is was generating real time screens on the fly, bypassing the cached server option.

Session id changes between two requests

I am using session id to store files uploaded by a particular user and when user clicks on a button, these files get downloaded. However, there is a problem that I am facing. When I am creating the file, the session id which comes in is different than any other request within same session by same user. Which results in two different session ids and due to which user faces problem in downloading that file. Same thing works file in IE. This happens only in Firefox. Jaxb is used for web services and flex for GUI. Can someone help determining what is going wrong here and in which layer?
The problem may occur based on the fact that file-upload (and maybe download, too) in ActionScript will generate a separate session with its own lifecycle. I faced this problem in one of my Flex-based applications where I used PHP for the backend.
The problem was that a user had to have the ability to upload media files but only when he is logged in to the application. When starting a new file upload ActionScript will process the upload under a separate session with its own session ID. I figured it out only because the user has been redirected back to the login-screen when the upload started due to conflicting sessions for user and file upload.
You should consult the API documentation of ActionScript's FileReference class to get a starting point what exactly will happen during file upload/download.
The problem that you have that issue only in Firefox can be originating from your Flash Player version installed for Firefox. Maybe there are some bugs or other issues which are browser-specific.

how to debug web services with eclipse

I have a very basic web service that I think is running correctly from Eclipse. Now I want to add in connections to a DB -- so I want to step thru the code to try out JDBC connections (I'm a .NET developer working this out in java).
Here is the (very) basic code:
public class PositionSkillManagementService {
private String t;
public void addSkill(String s){
t="s"; //I want to add a breakpoint here.
}
}
I think the webservice is working because when I go to this URL"http://localhost:8080/TrainingSystem/services/PositionSkillManagementService" I get a screen that says "Hi there, this is an AXIS service! Perhaps there will be a form for invoking the service here..."
I want to add a breakpoint in the addskill method so I can then debug connections to the db. I have added the breakpoint in eclipse and I see the little dot showing the breakpoint is set. But I don't know how to 'get' to the breakpoint? I don't know how to tell eclipse to execute the method so I can get to the breakpoint. I'm sure this is a basic question but I'm new to the environment.
What do I do?
Complete these few steps
Start your Web Application Server (Tomcat, JBoss, GlassFish, etc) in debug mode.
Deploy the component that contains your web service (usually a Web Application).
Invoke your Web Service somehow, for example, using the Web Service Explorer, the application would stop in your breakpoint.
This might be a bit late, but just in case.
I followed the steps from Luiggi Mendoza and worked great. The only thing, I had got the error "Source not found" and added the project to the look up path. Here are the steps I followed:
Debug Web Services & Deployed EJBs
Complete these few steps:
Start your Web Application Server (JBoss) in debug mode.
Deploy the component that contains your web service (MyTest.ear).
Insert a breakpoint at the line you wish in your code.
Invoke your Web Service somehow, for example, SoapUI, calling the REST endpoint through a browser, or using a service tester.
When the breakpoint hits, you will most likely get an error message in Eclipse saying Source not found.
Click the button Edit Source Lookup Path
Click the Add button in the next dialog
Select Project type and click OK on the next dialog.
Select the project(s) that have the code under investigation. Make sure you select checkbox to Add required projects if required
Click OK, and OK again. You debug breakpoint will hit. Stepping through the code will load the code files from the projects you selected for code lookup.
Follow regular Eclipse/Java debugging procedures.
You need to go to /PositionSkillManagementService/addSkill if you're using Axis. I'd recommend using SOAPUI to parse the endpoint if you do go down the SOAP route.
As soon as that line of code gets fired and providing your server is running from debug (click this icon ) it will fire the breakpoint when it hits it and go into debug mode so you can step over / step into the method.

Beginner-jJava- Amazon Elastic Beanstalk- Unable to correctly specify health check url-also,what is base url

I have created a sample web application in Java. It has no errors, and I was able to create a WAR archive successfully. I also tested this successfully in local Tomcat 7 server.
Now, this sample web app has 2 servlets- "home" and "runsinglecrawljob". The name of the war archive is "sparkcrawler0.12.war".
So, in local Tomcat, I access the web app at
http://localhost:8080/SparkCrawler0.12/runsinglecrawljob
And the other servlet is
http://localhost:8080/SparkCrawler0.12/home
Now, when I created an Elastic Beanstalk environment, I specified health check url="/home"
But I am getting error that health check url is not responsive, and because of this the application is not running in Elastic Beanstalk- it is showing a 503 error- as per Google Chrome this is the exact message --
"HTTP Error 503 (Service Unavailable): The server is currently unable to handle the request. This code indicates this is a temporary condition, and the server will be up again after a delay."
Now, what is the correct value of health check URL?
Also, if my URL is
http://spark.elasticbeanstalk.com
as defined in Elastic Beanstalk, then do I access the web app at
http://spark.elasticbeanstalk.com/SparkCrawler0.12/runsinglecrawljob
Or do I access the web app at
http://spark.elasticbeanstalk.com/runsinglecrawljob ?
I don't know if this is related or not, but I have a very similar issue but with a PHP codeigniter application.
I uploaded the application, and 'index.php' is the normal starting point of the application.
I also have a simple "phpinfo.php" that sits parallel to the index.php.
So, the URL is myApp.elasticbeanstalk.com which hits index.php and it is fine.
However, for my health check, I set it to /phpinfo.php because I want myApp.elasticbeanstalk.com/phpinfo.php to be used as the health check.
If I do this, the health check always fails, and so my application does not run and I see the glaring red box of doom.
This has been driving me crazy.
(Why do I want to do this? -- it's because I wanted to add an .htaccess file to the application root that requires a password for everything except the phpinfo.php file, and I tested this locally and it works. I did not add the .htaccess file yet -- I just wanted to see if I could point the health check to something besides "/" and have it work.
UPDATE --
I sorted out my issue. It turns out that when I launch one of these elastic beanstalk environments, I have to set up the healthcheck url right then and there to be /phpinfo.php and then upload my application. When I was fussing with this earlier, I would try to edit the configuration later to change the health check url and that never worked and the instance would never come alive again.

Why doesn't the WebSphere 7 console "_Save_ directly to master configuration" appear when I make a change?

I'm using WebSphere 7 (running my web app from within IBM RAD 7).
I'm trying to enable application security for my web app.
In the console, when I select Security > Global Security > Administrative Security, check "Enable administrative security" and click "Apply" ... there appears a box at the top of the console that says (among other things) "Save directly to the master configuration". I click "Save" and the changes are saved.
However, when I select Applications > Application Types > WebSphere enterprise applications > "MyAppEAR" > Security role to user/group mapping, and map my user group to my user, the "Save directly..." link never appears.
I can't figure out how to save my user-to-group mappings. While they appear in the on screen table of mappings, as soon as I click away and come back, they are gone.
Any help on this is greatly appreciated, thanks!
Rob
Within RAD, edit your server definition (double click on WebSphere Application Server in the Servers view). Under the section "Publishing settings for WebSphere Application Server", check "Run server with Resources on Server" (versus within the workspace).
Restart everything and retry your role mapping.
Also note that user/group mapping via the WebSphere console is a multi-step process. You must click OK on the "Security role to user/group mapping" after returning from the panel on which you actually map roles. (That is, you must click OK twice to get the role mappings to stick.)
I can't think of any answer. Can i suggest that you try another browser (you might think i am crazy but when i see things not working as expected i would try something like this).
If you make changes and the Server has recognized that there are changes it should give you the option to save.
In this case, it doesn't provide this information implies the server is not receiving the changes hence the suggestion to try and use another browser.
I have seen crazy stuff when i use Chrome (which is my preferred browser) and i switch to FF when the web application behaviour is bizzare.
HTH
Turns out my problem is exactly this same at this guy's problem:
Security role to user/group mapping in WebSphere 7 with file-based user registry
I used his solution to work around the missing "OK"/"Save" buttons.

Categories

Resources