Question

Since I upgraded Worklight to version 6.1 (eclipse plugin version: 6.1.0.00-20131219-1900) the servlet MyServlet that I created (and that worked fine with the previous version) no longer works.

By "it doesn't work" I mean that when the Worklight server starts the init () is no longer executed .   This my jee notation:  

   @ WebServlet (name = "MyServlet", displayName = "MyServlet", urlPatterns = {"/ MyServlet / *"}, loadOnStartup = 1) public class MyServlet extends HttpServlet {

  I think the notation is not recognized by the new Worklight and that it is necessary to adjust the web.xml. The problem is that the web.xml is located inside the war and is overwritten each time; any suggestion about it?

In server.xml I have:

            <feature>servlet-3.0</feature>

The problem of non-load servlet in Worklight 6.1 is due to the default version of the the XML Schema for the Servlet deployment descriptor.

The version attributed to worklight should be set to 3.0 (not 2.4) in order to enforce 3.0 behavior (allowing the use of jee notations). In Worklight 6.0 it was 3.0, now in Worklight 6.1 it is set to 2.4. I've replaced manually the webapp descriptor element in web.xml inside my war project with:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">

and now it works (my Servlet is loaded!).

Is it possible to restore version 3.0 in Worklight 6.1 by default?

Was it helpful?

Solution

To answer the question of back to v3 - this is not possible. While this was the version in a previous release, it was decided to go back to v2.4 due to compatibility reasons. v3 is not supported.


Indeed, the contents of the .war file is being re-generated upon every build in Worklight Studio. This is true for all previous Worklight versions and not new to 6.1.0. This is the expected behavior.

It is not recommended in any way to edit the web.xml file during development (since it will be over-written). As consequence it is not recommended for production either, because if you do any changes in your project and then re-deploy the .war file, it will not contain your previous post-build changes.

See the comments in this question: Worklight Init Servlet

What you can try, based on the comments, is:

Another option might be to have a separate servlet deployed to your server (not part of the WL .war) and communicate with it using HTTP adapter

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top