Spring Boot App losing session data in chrome - java

Whenever I use google chrome to hit my application, almost any requests that I make are not hitting the rest service. However, I can login and hit the rest service, the problem is once I get to the home page, any requests after the initial login all fail. Instead it seems like the session is becoming invalidated. I checked some other stack overflow threads and saw this may have to do with a 302 error occurring when the browser is trying to load the favicon.ico. I can see in the network tab of my developer tools that this is infact getting a 302. I am unsure if this is the actual issue and or is there is another issue.

Related

Servlet Filter is not being hit intermittently

I am facing a very strange issue.
Issue is we have a web application (war)which is built using angular 4 and it also has a "Servlet filter" which scans each and every request for a token and if that token is not available servlet filter will navigate to third party login page.
If token is available , it simply loads index.html and other data.
Token and some other params will be available as session cookies to current web app.
I have accessed the app URL and logs in to app and performs some actions in app and closes the browser window without logging out and I tried to open the same URL again , Servlet filter is not getting called.
If I refresh the browser window, filter is getting called.
If I clear the browser cache Servlet filter is getting called . I have observed same behavior in chrome and firefox.
I did check localhost access log, I don't see my request there.
Can anyone have any ideas on what is the issue and how to fix this issue ?
Reason is Google Chrome is caching so request is not all going to server. But when I refresh chrome is sending the request to Server. When I disable cache , everything is working fine. A good lesson about caching.

Prerender.io not caching pages - followed all steps as per documentation

We are trying to use pretender.io to our application which developed in AngularJS, Spring and Hibernate konnectnow.com which hosted at amazon server.
Here are the steps I followed:
Signup at prerender.io and got token: cFeRZcsv3JnAftreuhMO
Checked documentation and understood that I need to install middleware and decided to use Spring one.
In web.xml added pom added as mentioned https://github.com/greengerong/prerender-java
Added !# to the URL in all the pages.
Restarted tomcat server.
Logged into pretender.io with login details and found that nothing getting crawl.
For testing purpose the url konnectnow.com/#!/planpage changed to konnectnow.com/?_escaped_fragment_=/planpage
Nothing comes up, got error page isn’t working.
Checked Crawl Stats at pretender.io and found that as:
Status Code: 505, Cache Hit: Miss, Response Time(sec): 1.51sec, URL:
http://localhost:8080/#!/planpage
Not sure why it takes local host.
Can some one help me how to make this work.
We recommend using html5 push state instead of the #! in your URLs if possible. Html5 push state is better since nothing after a # is sent to the server, which can lead to issues for the crawlers that are checked by their user agent (Facebook, Twitter, etc).
You should set the forwardedURLHeader in order to have the Prerender Java middleware use a different host for your website instead of your proxy URL.
https://github.com/greengerong/prerender-java#forwardedurlheader
I also see that you posted your prerender token publicly so we regenerated your token to prevent someone else from using it. Please find your new token when you log into your Prerender.io account. I've also emailed you there.

Https requests from Ionic app returns 403 first time then it works

I implemented an app with Ionic.
This app makes https requests to my server app that is done with Java8 and Spring Boot. In the browser everything works well but when I launch the app on my phone every request gets rejected with 403 Forbidden status only the first time. The same request succeeds the second time.
For example: When I try to login with username and password, I press login and I get 403 Forbidden. I press it again, without changing anything and it succeeds. This behaviour is the same for all the requests that I make.
What can be the problem? I don't even know where to begin.
Update: Can this be because I am using an untrusted certificate for https requests? But if so, how come second time works?
As far as I know this is normal behaviour by the browser and shouldn't worry you.
The browser just sends a normal http request, and the remote system sends back a 403 to say that it needs credentials. If it already has them, it sends the request again with the credentials, and if not it requests login credentials from the user.
All in a normal day's work.

In Safari, the session are not maintained between subsequent POST and GET

i have an application running on Tomcat 7.0.27 which is our organization network and second application which is running on Amazon Web services( which is nothing but Tomcat 7.0.42). The application that is running on amazon is inside the iframe of the first application. The application running on the Amazon is self contained i.e all the files that it needs resides inside of the same tomcat container and don't communicate with the first application.I see that entire site works fine in FireFox and chrome. But having problems in safari. In Safari the launch of the second application is Successful( which is nothing but a POST) but the subsequent Request( which is GET) fails. So in code what we are doing is that after the POST we are putting a Java Object in the session like this
SessionData result = new SessionData(request,oauthCredentials);
request.getSession().setAttribute(SESSION_ATTR_TC_DATA, result);
So after the POST the first request that come is GET, when this request come in we try to get the Java object that we put in the session like below.
SessionData result = (SessionData) request.getSession().getAttribute(SESSION_ATTR_TC_DATA);
request.setAttribute(SESSION_ATTR_TC_DATA, result);
But in Safari i see that the session id(JSESSIONID) in POST is different From that in GET and the soSessionData=null; I see that the Session Id is same in case of FIREFOX/CHROME.
I see that from a URL/IPAddress
http://one.roses.flowers.org/ #IpAddress=141.21.19.87
http://test-dev.elasticbeanstalk.com/ #IpAddress=64.261.831.97
I am not creating any sessions by writing the code. Tomcat is handling it.
But this Whole Thing work across all the browsers when the First tomcat/second tomcat running inside our organization Network. I see that from a URL/IPAddress
http://one.roses.flowers.org/ #IpAddress=141.21.19.87
http://five.oranges.flowers.org/ #IpAddress=141.21.19.88
Why would Safari behaves indifferently in this case?
What made it work in Safari is by turning off cookie restriction to accept from Third party. Same is true for the IE as well.The default setting is not to acccept 3rd party cookie. For FF/Chrome the default option is to accept 3rd party cookies.
I have used Webscarab tool to debug this issue.
The application that was inside of the iframe was on AmazonWebservices the URL pattern was totally different from the origination Site. so that made browser think that these calls are made from/to some external site. So based on the Browser cookie setting the browser severed up the Application inside of the iframe.
Also, the 2 URL look like this to the browser.
http://one.roses.flowers.org/
http://test-dev.elasticbeanstalk.com/
We added the Alias/cname to the project on the AmazonWebservice(AWS) server in the higher environment(QA/PROD) something shown below. By adding alias to the url browser don't consider the URL coming from 3rd party as both has same domain name. Now the solution is independent of the browser cookie settings.
http://test-dev.elasticbeanstalk.com/ ---> http://aws.newsite.flowers.org

IE8 losing session details

I have a Java web app that intermittently loses session data. The problem only occurs with users on IE8. I have used IEWatch to monitor the http traffic, and it seems that the correct session cookies are being sent (JSESSIONID2).
When the request gets to the server the session has become unbound from the custom session monitor (this uses HttpBindingListener).
As I have mentioned this problem is intermittent and I have even gone through a transaction with the customer doing exactly the same thing on my machine - however I was unable to replicate their problem. It should also be noted that the transaction fails at the same point every time for all users experiencing this - it one the second page of a 4 page wizard type transaction.
Any help will be gratefully received.
Nige
Yep, I did find the problem.
I use DWR for AJAX stuff and there is an issue with DWRUtil.useLoadingMessage().
See http://directwebremoting.org/dwr/browser/util/useLoadingMessage.html
So this caused an execption, which went to an error page (jsp) which had an invalidate session statement on it.
Took me bloody ages to find it.
I hope this helps you, but I somehow doubt it :)
Nige

Categories