Home > Blockchain >  Redeploy Dynamic Web Project to Wildfly Server with Eclipse EE
Redeploy Dynamic Web Project to Wildfly Server with Eclipse EE

Time:05-11

I am creating a dynamic web project using Eclipse EE to run on a Wildfly v18 server. I setup a test servlet just to ensure that my setup is working and mapped it in the web.xml file:

@WebServlet("/Test")
public class Test extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // TODO Auto-generated method stub
        response.getWriter().append("<h1>Test</h1>");
    }

}

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
    <servlet>
        <servlet-name>test</servlet-name>
        <servlet-class>com.nhbb.test.Test</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>test</servlet-name>
        <url-pattern>/test</url-pattern>
    </servlet-mapping>
</web-app>

The servlet works and I get the desired results when I open localhost:8080/TestProject/test in my web browser. However, if I change the text in the servlet response, the changes are not reflected on the server or the front end.

I tried restarting the server, removing the project from the server and redeploying it, changing the server settings to "Automatically publish after a build event," enabling hot code replacement with the regex pattern \.jar$|\.class$, and even restarting my computer. In every case, the changes are not reflected on the server or the front end unless delete the project and recreate it from scratch with the desired changes.

I discovered another workaround which involved shutting down the server, exporting the project from Eclipse as a WAR file, deleting the contents of the server's standalone\deployments directory, then extracting the contents of the WAR file to the same directory before turning the server back on again. This approach works but is highly inconvenient and impractical.

I believe there is something wrong with my setup because redeployment should be much easier than this. At the same time, I created the dynamic web project using the default settings, so I cannot see how it does not work.

How can I practically redeploy my project to the server?

CodePudding user response:

"Automatically publish after a build event" implies that you build, i.e. leave automatic builds on, to deploy updated class files. This is also not specific to WildFly servers.

  • Related