How to switch with another application when redeploying a WAR? - java

Sorry if this question was asked before, if it was, I didn't find it.
I'm using GlassFish 4.
When I need to redeploy an application (for fixing a bug for exemple), its URL will return temporarily a 404 NOT FOUND error until the application is fully redeployed.
My question is: do you know a way to redirect the URL to another application or a web page ("Application not available for the moment...") during the time the URL is inaccessible?
I heard of load balancer but it's between 2 servers (which I don't have).
Thank you.

You can use rolling updates to update an application without any downtime, by using the :version suffix. For full information on how to do it, see the blog post at http://blog.payara.fish/payara-server-rolling-upgrades.

Related

Tomcat 9 Application causing 502 error after logging in

I manage a few Tomcat 9 applications that are run on a remote server that also use IIS 8.5. Each site has three environments (DEV, TEST, and PROD). All of the environments are the same but on different servers. Their databases (Oracle DB) are also on separate remote servers. I do not use any other third party frameworks for the sites (such as Maven or Gradle).
One of my applications had an issue where an attacker could access the web.xml through a Multiple Directory Traversal Vulnerability. Some brief information can be found here: https://www.securityfocus.com/bid/63052/exploit
However, I discovered on the DEV and TEST (I thought PROD as well) that the filter we put in place was actually causing the site to not work correctly. You'd put in your user and password and click login and nothing would happen. I seemed to have fixed it on the DEV and TEST environment by fixing the regular expression that my code was testing the URI against. Code:
final String REGEX_INCLUDED = ".*\\/WEB-INF\\/web.xml.jsf.*";
...
if (Pattern.matches(REGEX_INCLUDED, URI)) {
log.debug("SecurityFilter redirect");
resp.sendRedirect("/errors/403.html"); // /login.jsf OR /index.html
} else
chain.doFilter(request, response);
I deployed the new war onto PROD, entered my user and password and it would load. The site redirects to the homepage after login, BUT it doesn't actually load if that makes sense. The response is a generic 502 error (shown below) but the URL does, in fact, say /home.jsp where it should respond with the homepage.
502 Error
I've checked the catalina log and I've not found a stack trace or any sign of an error being output. No other logs are useful either in showing what the issue is. I've tried just clearing my cache and retrying, using a different browser, restarting the tomcat service, restarting the site in IIS and nothing.
If there is something I'm missing that you wish to see let me know. BTW, I've tried removing the filter that blocks access to the web.xml just to make sure it wasn't the issue and both with and without the filter, it results in the 502 error.
Thanks in advance for any help.
Answering my own question: I had looked around everywhere and only after posting I found a related post:
502 proxy error on deployment
Their answer helped. The difference between my PROD environment and my DEV/TEST environments is that PROD is on a Proxy. I went to IIS on the server and found the server farm that the site used. I then clicked on the Proxy option and changed my timeout from 30 seconds to 60 seconds. Looks like my proxy was timing out. Hope this helps someone in the future.

Resource Not Found?

There's this dynamic web project (java) that I'm working on, which requires me to access the web-page it'll redirect me to. So usually when i start the server and run it from chrome, i go to the desired page. But since a couple of days, my project is misbehaving. The same URL which it earlier used to run properly, now shows
Not Found : HTTP Error 404. The requested resource is not found"
After starting the tomcat server many times, on one run it randomly connects to the URL.
Does anyone know why this happens? And without any fix how am i able to reconnect to the URL again? And if you know, how to fix this issue?

Spring Oauth application not working in Microsoft Azure App

I created spring application implemented with oauth2.0 (authentication_code flow) and deployed into Azure App service. When I run it in my local machine its working properly and getting oauth token properly. But I deployed the same code in Azure App, its not working it showing ******.com redirected you too many times.
When I trace the traffic in "Network Sniffer", there is no cookie information in the response.
For reference i attached error screenshots.
Per my knowledge, ******.com redirected you too many times error is different variation of error ERR_TOO_MANY_REDIRECTS(also known as a redirect loop) in Google Chrome browser.
You could refer to below recommendations and things to check to fix the error.
1.Delete cache and cookies on that specific site
Cookies can sometimes contain faulty data in which could cause the ERR_TOO_MANY_REDIRECTS error.Due to the fact that cookies retain your “logged in” status on sites and other settings, we recommend simply deleting the cookie(s) on the site that is having the problem. This way you won’t impact any of your other sessions or websites that you frequently visit.
2.Determine nature of redirect loop
The free online Redirect Checker tool can help provide some further analysis into what might be going on. This could also be done via cURL.
3.Check your extensions by typing chrome://extensions
Disable each of your extensions one by one while checking and refreshing your page, if the page starts working while a particular extension is disabled, that extension is faulty and you should delete it.
4.Check Your HTTPS Settings
If you have an SSL certificate on your domain host, you may deactivate it.
Hope it helps you.

OAuth Callback in the Glass Quick Starter Java App

Got my Glass last week. Working on running the Java version of the Quick Starter Glassware demo. I am having trouble with the OAuth callback. Do I need set this up myself? Or is there source included in the sample somewhere? Please help!
Clarification: I have set up my own project with the Java Quick Starter app's code, deployed it in EC2 and have set up the Client-ID and Client-secret in the Google APIs Console. I set the Redirect URI as http://<my server>/<my-app>/oauth2callback. When I visit the app in the browser, I get a 404 error that /oauth2callback is not found. I also tried setting the Redirect URI to just my app's root, i.e. http://<my server>/<my app>. Strangely, I still get the same error that /oauth2callback is not found.
Additional questions: Can you please clarify what the callback URL needs to be set to? Is the handler code already included in the quick-start-demo app or do I need to provide that code?
I think the problem is that you're not using a URL that actually maps to your server and servlet container. Try hitting the URLs directly from a browser and make sure they show up in your server and servlet container logs.
The callback url needs to be set to the oauth2callback servlet, relative to the path that leads to the server and servlet container. I don't know how you've set these up, so I can only guess, but it sounds like the <my app> portion isn't correct.
The handler code is included as part of the webapp. See the web.xml file to see the path mapping and the servlet object that it maps to. In this case, around line 53, oauth2callback is mapped to the com.google.glassware.AuthServlet class.
Update: See also the answer posted at Java Google glass starter project mapping in AWS EC2

HTTP 500 internal error in jdeveloper

I'm working on an assignment. An online order system using EJB 3.0. im using jDeveloper 10 and oracle 10g for the database. i have coded around 20%, now i need to check the system that i have developed so far. so when i run the web client it does not show me any error and it runs successfully. but when the browser tries to open the page it says. HTTP 500 internal error on the browser. My jsp page is under web directory anyway. output pic is attached.
how could solve this issue?
Are there any log files on your web server ?
Put in your code some statement to log to file what is doing.
Use a browser with developer support, like Firefox with Firebug, and watch the HTTP transactions.
Which other conditions change between web client and browser mode ?
how could solve this issue?
Look at the log files in your EJB server. There will probably be an entry or entries corresponding to your browser's attempting to fetch the page that resulted in the 500 error. They should give some information about what is happening, and may even give you a stack trace. Also check the SEVERE / ERROR / WARNING entries prior to the event.
If that doesn't give you an answer, you need to investigate what is different about the requests when they come from your web client versus from your browser. If your EJB implementation has a way to capture the incoming request headers, use that. Otherwise, you could use wireshark or tcpdump to capture them.
Thanks for your contributions.
I guess it was something wrong with my jdeveloper 10. i installed the jdeveloper 11 n i started running on it. the project started to run successfully.

Categories

Resources