redhat-developer / vscode-server-connector

📦 Connects Visual Studio Code to your server adapters and run, deploy apps !!
Eclipse Public License 2.0
56 stars 26 forks source link

WAR file changes isn't detected is it because it doesn't republish? #608

Closed devanpedrik closed 3 weeks ago

devanpedrik commented 4 months ago

I am running a maven project with SLF4J for wildfly 26. It seems that when I add LOGGER.info and such, it does not output the LOGGER into the console until I run the mvn clean install command on my project and restarting the server.

I have tried running wildfly with the same configuration on eclipse and the logger is shown in the console as expected so I don't think there are anything wrong with the SLF4J setup in the wildfly configuration. So I wonder if the server does not republish automatically like eclipse does and is that the supposed function for async publish provided in the setting.

Process for clarity:

  1. Add LOGGER.info("some text here"); then trigger the method containing the logger and it isn't shown in the console.
  2. Restarting the server after it. Then trigger the method containing the logger again and it isn't shown in the console either.
  3. Run mvn clean install command in the project then restart the server. Only then the logger is shown in the console.

Other issue that I faced:

  1. Clicking terminate server shows error popup that says the server is already stopped. Is this the expected behavior or am I missing some configuration for it? Seems to me that its not doing anything.
  2. Clicking the add new server button provided in the view shows the quickpick options download or select from local but I found that if I just created a server then I tried to create it again, it would not work until I reload vscode via reload window. But right clicking then selecting create new server works fine.

Also some side question,

  1. How do I know if the async publish is working? It might be obvious but I can't see it in action which confuse me.

image In eclipse when you make changes to .java file it'll check module then create a new .war folder in the domain's deployment folder with the changes you just made to update it accordingly and this does not seems to be happening for vscode, which seem to be the cause for my problem. Unless I am missing some configuration for this.

image image

What actually happen for vscode is that it'll generate a ISDEPLOYING FILE then it'll turned into DEPLOYED FILE if it is successfully deployed. But seems like the .war file still contain the older version of the files and not the latest unlike what is happening for eclipse. When I open the DEPLOYED FILE seems like it is not a package and contain the text of the .war deployed. Notice the time frame difference between the ISDEPLOYING FILE and DEPLOYED FILE too.

I am quite new to these, please be patient with me.

devanpedrik commented 4 months ago

Doing a full publish prompt error message but still manage to deploy war.

image

which is the same error message shown when clicking terminate server. Also if I may get a clarify on some of the feature provided.

To be clarified:

  1. What are the difference between a full publish and incremental publish?
  2. What is the difference between stopping the server and terminating the server? Even though terminate server does not seems to be working for me at the moment.
robstryker commented 4 months ago

1) A full publish will copy over every file in the module to the deployment directory, and will tell the server to re-deploy the module by renaming the creating a file with a .dodeploy suffix. An incremental publish will only re-publish the changed files. If the changed file is a jsp or html file, it should be picked up by the server immediately. If the changed file is a class file or a descriptor file that links to dependencies, the change may only be picked up if the server was started in debug mode or if you restart the server after that. The RSP will generally attempt to check it the changed file is a class file in order to trigger the dodeploy functionality.

2) Stopping the server attempts to issue a stop command, typically by running the shutdown jar as a new process with the proper command line arguments to shut down the server. A terminate will attempt to kill the process, if it has a reference to it.

The biggest problem these tools face is what workspace files or folders are being deployed. Typically, you do not tell the UI to deploy a given project in its entirety, because the project layout is different than the deployed layout. The project layout, for example, often includes folders like src or other paths that will eventually be mapped into some other folder.

So, users typically tell the UI to deploy something like the target/MyWebapp1.war folder. The problem is, this folder is only regenerated when you run a maven command. So changing a source .java file will generally not affect the target folder at all. If you have vscode-java installed, the incremental builder will generally try to compile Your.java into bin/Your.class, but, again, this file is in the bin folder (or other output folder) and is not part of the assembled project structure inside the target folder.

To work around this, you can give your project a mapping file as shown here: https://github.com/redhat-developer/vscode-rsp-ui/?tab=readme-ov-file#provisional-project-structure-details

To summarize, you can add a file named .rsp/rsp.assembly.json at the root of your project, and this file will map your source folders to where, in the assembled war output, it belongs. Then, the RSP incremental publisher will know that when you change src/Your.java, and the vscode-java extension automatically compiles that into bin/Your.class', the class file should then further be copied into/WEB-INF/classes/` in the output war.

robstryker commented 4 months ago

It's worth noting that the linked example does not include a bin folder example. So that would be something like:

{
            "source-path": "bin/",
            "deploy-path": "/WEB-INF/classes/"
},
robstryker commented 3 weeks ago

The workaround listed indicates how to properly use the tool to get the desired results.