Troubleshooting issues with Ajax and Jena

Whenever I attempt to utilize AJAX to call Jena in my servlet, I encounter this error:

java.lang.ClassNotFoundException: com.hp.hpl.jena.sparql.core.Prologue
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at fr.objective.blogomatic.semantic.web.ServletAjax.doGet(ServletAjax.java:40)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
... and more ...

This is the Jena code snippet causing the issue:

class classUsingJena {
public void execute(){  

String queryString = PREFIXES
                        + " Select ?label "
                        + " where {"
                        + " ?description j.5:entity-label ?label ."                     
                        + " } ";

Query query = QueryFactory.create(queryString);
QueryExecution qe = QueryExecutionFactory.create(query, model);
ResultSet results = qe.execSelect();
ResultSetFormatter.out(System.out,results, query);
qe.close();}
}

The Jena code runs smoothly on its own, but when invoked from the servlet, it triggers the aforementioned error.

Here's the relevant part of the servlet code:

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    String service = req.getParameter("service");
            classUsingJena jena= new classUsingJena()  //bug
    return;}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    doGet(req, resp);
}

@Override
public void init() throws ServletException {
    ServletConfig config = getServletConfig();
    urlAjax  = config.getInitParameter("urlAjax");
}

My JavaScript code functions correctly:

$("#Analyser").click(function(){

        var article = $("#TxtArea").val();
        ajaxFunction("acteur",article);

        console.log(article);
    });
function getXMLObject()  //XML OBJECT
{
    var xmlHttp = false;
    try {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP")  
        }
    catch (e) {
        try {
          ... Simplified for brevity ...
    }

var xmlhttp = new getXMLObject();  



function ajaxFunction(value,textToPass) {

    if(xmlhttp) { 
        xmlhttp.open("GET","ajax?service=ajax&value="+value+"&text="+textToPass,true); 
        xmlhttp.onreadystatechange  = handleServerResponse;
        xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xmlhttp.send(null);
        }
}



function handleServerResponse() {

    if (xmlhttp.readyState == 4) {
        if(xmlhttp.status == 200) {
            $("#J").text("");
            parseXml(xmlhttp.responseXML);
        }
        else {
            //alert("Error during AJAX call. Please try again");
        }
    }
}

function parseXml(xmlData)
{
  $(xmlData).find("nom").each(function()
  {
    $("#J").append($(this).text() + "<br />");
  });
}

Answer №1

I mistakenly specified the outdated version of Arq as 1.8.7 instead of 2.8.7 in the pom file. Fortunately, after making the correction, everything is now functioning smoothly.

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

What is the best way to modify Mega Menus using JavaScript?

I am currently managing a website that features "mega menu" style menus. These menus consist of nested <UL> elements and contain approximately 150 to 200 entries, resulting in a heavy load on the page and posing challenges for screen readers. To add ...

The updates made to a variable within an ajax request are not immediately reflected after the request has been completed

My global variable is not displaying the expected result: function checkLiveRdv(salle, jour, dateus, heure) { var resu; var urlaction = myUrl; $.ajax({ type: "POST", dataType: "json", url: urlaction, data: myDatas, suc ...

Can the geocoder API/search box be utilized to locate specific markers on a map?

Incorporating Mapbox into an Angular application with a high volume of markers on the map (potentially thousands) and hoping to implement a search box for users to easily locate specific markers based on unique names and coordinates. Is this functionalit ...

Updating the content of a file on an iPhone

Is there a way to update the entire document content with a response from an ajax request? I've tested out using document.body.innerHTML and document.write(), which both work on desktop Safari. However, I'm looking for a solution that will also ...

`Can controllers be included in route or template definitions?`

When it comes to defining a route with a template, there are two main ways to set the controller for the view: In the route: $routeProvider .when('/phone/:phoneId', { controller: 'PhoneDetailController', templateUrl: &ap ...

Locate element in Cypress with ID that includes a span element

Recently diving into Cypress, I'm looking to locate an element with a dynamic id that contains specific text. For instance: ... <div class="col2"> <button id="random-city-name_type-125" class="btn-secondary"> ...

When setting up columns in a MUI DataGrid, it's important to remember that each field must have a unique name to avoid any conflicts. Having

I am currently working on a DataGrid project where I aim to display the values of ready_by and name. Here is an image for reference: https://i.stack.imgur.com/3qZGa.png In my code configuration, the setup looks like this: (specifically focusing on the la ...

Guide on how to turn off cache in AngularJS + NodeJS CRUD application

I'm encountering an issue with cache in Internet Explorer, but everything seems to be working fine in Chrome. Whenever I try to add an item in my application, the data doesn't refresh automatically and I have to press Ctrl+R to manually refresh. ...

Utilizing Material-UI Select for creating a number range dynamically

Seeking a solution to create a select element using material-ui that offers a range of numbers from 0 to 20,000,000 in increments of 25,000. Currently, I have accomplished this using a for loop. for (let price = 0; price <= 20000000; price = price + 250 ...

Attempting to transpile JavaScript or TypeScript files for compatibility within a Node environment

Our node environment requires that our JavaScript files undergo Babel processing. Figuring out how to handle this has been manageable. The challenge lies in the fact that we have a mix of file types including .js, .jsx, .ts, and .tsx, which is not subject ...

What is the method for utilizing underscores in Visual Studio Code without the need to "enable" them beforehand?

I attempted to utilize underscore in Visual Studio Code and found that it only works if I include this line of code at the beginning: var _ = require('underscore'); The output functions properly with this code in place. However, if I remove it, ...

Improving user input in AngularJS

My goal is to create a filter that converts time into seconds, such as: 01:30:10 becomes 5410, and vice versa. This way, the model only holds seconds while providing users with a more user-friendly representation. I've successfully implemented a work ...

Oops! Hardhat Test Error "Error: Virtual Machine Exception occurred while processing transaction: reverted with reason 'Please deposit additional funds'."

Encountering an issue with the following error message: Error: VM Exception while processing transaction: reverted with reason string 'deposit more' in the Hardhat Test.js file Test.js -> it("should be able to withdraw if no one appl ...

The useNavigate() function seems to be failing to redirect to the '/protected' route

The issue lies in the redirection process after receiving the token from the API. Although the token is successfully saved in local memory, the redirect to the intended page does not occur as expected. Instead, a manual window refresh is required to naviga ...

The Express server is set up with CORS enabled, however, it continues to encounter issues when attempting to make asynchronous HTTP requests from

We're currently experiencing an unusual issue and are seeking assistance to resolve it. Initially, our Express server is functioning well as an API when accessed from the same domain. However, we also need to utilize this API on our computers for tes ...

Uploading files using jQuery AJAX

I am attempting to send an array of files in my ajax request. Here is the code I have: $(document).on('click', '#submit_edit_discussion', function (event) { event.preventDefault(); var channel_id = $('#channel_id').va ...

Discover the correct steps to transition from using particles.js to the react-tsparticles package

Migrating from react-particles-js to react-tsparticles-js Hi there! I'm currently facing an issue with my ReactJS website here, which is deployed using Netlify. The error code below keeps popping up, and I believe it's related to the transition ...

Can you explain the significance of the v-on="..." syntax in VueJS?

While browsing, I stumbled upon a Vuetify example showcasing the v-dialog component. The example includes a scoped slot called activator, defined like this: <template v-slot:activator="{ on }"> <v-btn color="red lighten-2" ...

Mapping an object in ReactJS: The ultimate guide

When I fetch user information from an API, the data (object) that I receive looks something like this: { "id":"1111", "name":"abcd", "xyz":[ { "a":"a", "b":"b", "c":"c" ...

Deliver a JSON object to a View using Flask and Ajax

I'm attempting to send a python dictionary back to the view using AJAX and extracting data from a JSON file. However, currently I am only receiving [object Object],[object Object] as output... If I inspect the network traffic, I can see that the corr ...