Hello, it's really the first time for me to post.
I'am encountering a problem with my Web Apps and cannot find any answers on the web.
My problem is that i have a Java Web
App that works on parallel with
tomcat and apache using mod_jk.
Everything works fine, but after one
day of running in tomcat, the Ajax
request i do with Jquery dosn't come
back with the data. I'm using SQL
Base (phpMyAdmin).
I'm sending a request to the servlet
in charge of the sql using Jquery Ajax but i
never get the response. Wierd thing
is that it works for a day and then
stop the next one (i must than reload
my WebApps to make it work again).
Could you gentle developpers give me a hint or two please ? :)
I think whenever you are opening the connection to take data from database then probably you are not closing those connections.And every time your application is creating new connection with database without closing old one.As sql has limited number of connections so after one day or after some time your application is not able to connect with your database.So you are not getting data from database. And when you are reloading your application that time you are restarting tomcat so that time your all connections with database are being closed.So next time again you are able get data from database.
So check whether you are closing database connections properly after every transaction or not.Might be this is your problem.
Have you looked at any error messages in the log files? Especially, do you know if the corresponding Servlet gets called at all, or is the request blocked by apache / tomcat?
Related
I know I don't have any code to show you guys, I am stuck at some point and I dont know where to start. I hope someone will help me.
I am developing a Spring MVC application, and I need to send a message to all active session users to execute a script which is available to all the clients as it is defined in a js file and included for every user.
I have looked around and found some frameworks which offers these type of functionalities like Atmosphere but I don't think it should be used in my situation as it is a big framework and the functionality required is very little. I have also gone thorough WebSockets but I cant find anything which would help me in invoking the script on client side for all the clients.
If someone can help me go to a right path or direct me to a similar example. I will be grateful
****Update****
I can also use polling if there is way that: if the controller gets a request the session should be considered idle during that, for instance, there is controller which is called every 5 minutes and in the session out time is 30 minutes. The session won't expire in this time if the controller used for polling is called every 5 minutes, I need to exclude the particular controller from calculating the idle time
No Polling Solution:
From what I gather, you need a Remote Procedure Call mechanism.
I would go with https://github.com/eriksank/rpc-websocket.
The general idea:
Your clients register themselves to your server process as "consumers".
When a message is ready, your server then goes through every registered "consumer" and sends the message which rpc-websocket can handle .
Polling Solution:
Here is a general idea, works if you have registered, logged on users.
Have a database table that stores messages, lets call it "messages".
Have a database table that keeps track of messages and users, lets call it "message_tracker". if a user has seen a message, there will be a row in this table for the messageId and UserID.
Have a javascript script poll a server url for new messages. What is a new message can be decided based on the database tables above.
If a new message is found, process it and then call another server url which inserts into the message_tracker database table
At particular page in the project, I get output on the page.
When I refresh the page then also I get the same output. This is absolutely correct.
But when I refresh the page third time it shows busy browser and never return anything on the page. I am using tomcat server, hibernate, spring.
Due to busy browser and it never show anything ever, I have to restart the tomcat server.
Now history repeats. Third refresh make browser busy which doesn't fetch anything.
Is there any problem in hibernate ?
You first question would be like, what logs you are getting?
I see nothing in the log.
I'm making a REST call via frontend to download a file. At backend I'm creating a file and giving it a response.It works fine locally. But when I try to run front end and back end at two different system I'm getting proxy timeout error because the file download request it taking time at backend and probably my proxy server at frontend is giving me timeout. I can not make an Ajax call because of security reasons. Can anybody tell me a possible solution for this?
I currently have the following situation:
I have build a client Java application, which used to communicate with the MySQL database directly. When I was inserting a lot of data, I used to do this with AutoCommit turned off. This was easy to do, because I had direct access to the Connection. I had chosen to do this, because it enabled me to rollback the changes when something went wrong during the synchronization.
Now, the application is evolving and I thought I would be better to build a server API which communicates with the MySQL database. So, at the moment, I am inserting data by doing Http requests. Each request opens and closes a new Connection.
Now, I would like to be able to rollback the changes when one of the requests goes wrong. I assume I can not work with AutoCommit, because this is based on a Connection, and that one is different for each request.
Can anyone tell me how this is done usually?
I have thought of the following:
First call an URL which sets the AutoCommit to false, and then do all the requests and check if one fails. But this would go wrong if another client is also inserting data at the same time.
Sending the data to the server with one request, but this would force me to alter my design drastically.
Note: I know some code is usually required when asking a question, but I can not see how this would improve my question. However, if it is needed, feel free to request it.
Every web request should run in it's own transaction.
Send all the data that belongs to a logical transaction in one request and call commit at the end of the request processing.
Spaning transactions accros multiple web requests is a bad idea. Think about crashing clients which never commit. This will leave you with open transactions that never close.
I am working on web based applications.
Server : Tomcat
Technology : Simple Jsp/Servlet/JQuery
I need to restart my server as an when new updates are there. And these changes are frequent almost every 1 or 2 day. I think to create some mechanism like I can say to every logged in user to save their changes and server will start in few minutes. (Timer will be there). Popup should be open though user is ideal.
Is there any direct way to do this so? Or I need to implement ajax call on every few seconds to server on every jsp page to check if any message is there on server???
Any idea will be appreciated.
Thanks in advance.
For the approach you are taking, I would suggest you to use Async Serlvets(Req. min Servlet API 3.0) or Apache Tomcat's comet technology(Kind of Async Servlet).
You will make ajax call on every page when it(page) loads(ajax onload() for eg.) to Async Servlet and will idle until response from server comes. This Async servlet should send Server Restart notification to all connected clients- whenever you trigger notification manually. Once ajax client gets notification, it will display the Warning(or user friendly message).
This will remove the need to make unnecessary polling to server after fixed internal - A big plus resource wise.
Personally I wont suggest this way, better get agreed on specific timeframe for deployment everyday(every two days) with clients and perform deployments in this time.
If you are from India- You must be aware about IRCTC website- Which is not available for train reservation every night for 1 hour.