Ajax call encounters 404 error but successfully executes upon manual page refresh (F5)

I am encountering a frustrating issue with my javascript portal-like application (built on JPolite) where modules are loaded using the $.ajax jquery call.

However, the initial request fails with a 404 error when a user first opens their browser. The app is hosted at https://localhost:8443/context. Firebug reveals that the request is made to /:8443/context/file.html, which is incorrect.

Oddly enough, after refreshing the browser (F5), everything works perfectly fine and the requests are well-formed. I experienced a similar issue in another app based on JBoss portal, but it was resolved after migrating to the latest version.

I suspect this problem may be related to caching or something of that sort. Unfortunately, my search on Google did not yield any helpful solutions, so any insights would be greatly appreciated.

Answer №1

After searching for a solution, I was able to identify the problem on my own. It turned out that the log configuration was incorrect and I had overlooked a crucial error message:

ERROR: org.hibernate.util.JDBCExceptionReporter - Already closed
.
Due to periods of inactivity, the MySQL server was closing the current connection which was causing requests to fail with an AlreadyClosedException. By adding validationQuery="select 1" to my context.xml file, I was able to resolve this issue.

Answer №2

When there has been no activity for a while, the mysql server will automatically close the current connection.

It is best practice to always close connections as soon as you are done with your database operations. Don't just leave them idle and wait for the SQL server to close the connection for you.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Change a comma delimited string into a JSON formatted array

Is there a way to convert a string of comma separated values into valid JSON format using either PHP or jQuery? The comma separated strings are currently stored in a database and have the following structure: Singapore,Andora,Australia The desired outpu ...

What is the best way to define one API route that accommodates two different query combinations?

Is it possible to define 1 API route with 2 different query combination options? We have 2 routes: GET /api/v1/resource?filter=byName&key=restaurant&city=chicago GET /api/v1/resource?filter=byLocation&lat=34&long=78 In soaJS, schema ...

Transmit information from the frontend to the backend using JavaScript and the Express framework

After creating a custom variable in my frontend to store data, I needed to access the same data in my Express backend. The JavaScript variable and the POST request code snippet are as follows: const dataPush = { urlSave: urlSave, ...

Implementing Ajax functionality in Ruby on Rails

I wish to send the selected drop-down menu value to a controller using ajax panel_controller.rb class PanelController < ApplicationController def insert @selected_city_ids = params[:city] end panel.js.erb $(document).ready(fun ...

Using JavaScript and the Firefox browser, learn how to easily highlight an element with Selenium-WebDriver

I am struggling with creating a valid function to highlight specific elements on a webpage. As a beginner in coding, I suspect that the issue may either be related to my environment setup or a lack of knowledge about JavaScript/Selenium features. I am wri ...

Completing a form and saving data to a document

I have a form that successfully writes to a text file using PHP. However, after submitting the form, the page reloads and shows a blank page. Currently, there is a message that appears using jQuery after the form is submitted. My goal is to prevent the pa ...

Combining multiple JSON objects into a single array in AngularJS

Currently, I am facing a challenge in merging two API calls. The first call involves fetching data by filtering the account_id on the backend, while the second call retrieves data based on the test_id. Let's start with the JSON response for /api/test ...

Implement the click event binding using classes in Angular 2

If I have the template below, how can I use TypeScript to bind a click event by class? My goal is to retrieve attributes of the clicked element. <ul> <li id="1" class="selectModal">First</li> <li id="2" class="selectModal">Seco ...

Maintain dropdown menu visibility while navigating

I'm having an issue with my dropdown menu. It keeps sliding up when I try to navigate under the sub menu. I've spent all day trying to fix it, testing out various examples from the internet but so far, no luck. Any help would be greatly apprecia ...

Backbone.js: Navigating the Default Path Issue

I've embarked on creating my very first BB app. Progress is decent, but I've hit a roadblock. My router implementation appears as follows: var PlayersAppRouter = Backbone.Router.extend({ routes: { '': 'index', ...

Tips for properly implementing a bcrypt comparison within a promise?

Previously, my code was functioning correctly. However, it now seems to be broken for some unknown reason. I am using MariaDB as my database and attempting to compare passwords. Unfortunately, I keep encountering an error that says "Unexpected Identifier o ...

The button in my form, created using React, continuously causes the page to refresh

I tried to create a chat application using node.js and react.js. However, I'm facing an issue where clicking the button on my page refreshes the entire page. As a beginner in web development, please forgive me if this is an obvious problem. You can fi ...

What is the best way to serialize form data while also including a child collection?

Currently, I have a webpage within my web application where I am in the process of creating a Person object using an AJAX POST request. The required JSON format that needs to be sent to the API endpoint is as follows: { "categoryId": "string", "na ...

How to execute an executable file using Java on a Mac computer

Currently, my objective is to launch a server using bash, and I've already crafted an UNIX shell script for this purpose. However, I'm encountering difficulties in executing it through Java within Eclipse. Below is the code snippet that I attemp ...

Creating a Selectable Child Form in ReactJS that Sends Data to Parent Form

Sorry for the lack of details, I'm struggling to explain this situation clearly. I'm currently learning ReactJS and JS. In a project I am working on, I have the following requirements: There is a form where users can input text and numbers. The ...

Converting the response to a class in Spring Rest operations

Here is the code snippet for my rest call: RestOperations operations; UserIdentifier resourceResponse = operations.postForObject("...", entity, UserIdentifier.class); The structure of the UserIdentifier class used in the call: public class UserIdentifie ...

What are some effective ways of using the parent, before, and children selectors?

<table> <tr><td><input type="text" value="123"></td><td><input class="here" type="text"></td></tr> <tr><td><input type="text" value="333"></td><td><input class=" ...

Interacting with jQuery mouse events on elements below the dragged image

I'm attempting to create a drag-and-drop feature for images using jQuery. While dragging, I generate a thumbnail image that follows the mouse cursor. However, this is causing issues with detecting mouseenter and mouseleave events on the drop target pa ...

Several jquery libraries are experiencing malfunctions

<head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $(".slidingDiv").hide(); $(".show_hide").show().click ...

The issue with the full postback in the updatepanel is triggered by utilizing JavaScript on the button's onclick event within

During my testing, I encountered an issue with buttons inside a repeater within an update panel. When adding asyncpostback triggers for the buttons using <Trigger></Trigger>, an error is generated indicating that the button could not be found. ...