Is there a way to read static web content from workspace rather than deploying in the WAR file?

Answered

I have a web project that contains a lot of static html, css, and js files in the directory src/main/webapp.  When I make a change to any of these files, I need to rebuild and redeploy the war and ear file. I'm wondering if there's a way to have that deployment artifact simply read them directly from the the source code in the workspace, rather than redeploying them each time. I believe I was able to do this in the past by creating a custom artifact, but am having trouble getting that to work currently, so i'm wondering if there's a guide somewhere for setting this up, or some other efficient solution I'm missing?

0
13 comments
Avatar
Permanently deleted user

Those still require redeploy to update static resources. Also, I notice that using Reload > Update Resources in the server run tab doesn't actually seem to work as a shorter redeploy option either. Full redeploy of the Ear is the only thing that seems to work for me.  Do I need to mark the 'webapp' folder a certain way to signify it as static content to IntelliJ?  

0

No, it works for folders configured as web resource roots. Update action updates the files in the artifact output directory, you can check it using your favorite file manager. If the file is updated in the artifact output, but the app server doesn't see this update, there must be some caching enabled for the app server/framework you are using. Google how to disable it for your specific case.

0
Avatar
Permanently deleted user

I'm using WebSphere Application Server 8.5.5 and IDEA 2018.3 

I checked the Project Structure > Facets, and it looks like my 'webapp' folder is correctly configured as a Web Resource Directory there...

So I did some tests.. I modified an html file, then checked for the change in the exploded artifact's output directory. It was updated there about a second after I changed it. I did an 'Update classes and resources', then checked the file again in my server's 'installedApps' folder, and it was NOT modified there. Finally, I manually updated the HTML file in the 'installedApps' folder and reloaded my browser, and saw the update there. 

So the problem isn't building to the artifact output, or caching on the server. It's deploying contnet from the artifact output to the server installedApps. I wonder if there's a configuration that can help me do that? I spoke with a coworker who uses eclipse and he said there was an option to have Websphere read artifacts directly from the workspace target directory, which allows him to get instant updates for non-compiled code using the same server profile. Is there anything like that for IntelliJ? 

0

IntelliJ IDEA instructs the app server to load the web application contents directly from the artifact output directory when you use the Local configuration for the app server. This way the second copy operation to installedApps is not needed at all.

Try again with the vanilla app server installation, you should not see the copy of the app under installedApps as it works directly from the artifact.

0
Avatar
Permanently deleted user

I set this server up using the "WebSphere Server > Local" option (not "remote"), but it doesn't seem to be behaving as you stated. Could you clarify what you mean by "vanilla app server installation" please? 

0

Make a new clean server installation that has no modifications to the startup scripts and configuration and has no apps deployed manually to it, configure this server in the IDE and try deploying a new hello world project exploded web artifact to it. See if you can update it per https://www.jetbrains.com/help/idea/updating-applications-on-application-servers.html.

0
Avatar
Permanently deleted user

Alright, I created a brand new empty IntelliJ project.

I created a brand new WebSphere 8.5.5 server profile, and didn't do any custom configuration on it. I set it up in IntelliJ as "WebShere Server > Local" and didn't modify any of the default settings.

I went out to github and grabbed a random hello world ear (https://github.com/sameergarg/examples/tree/master/hello-world-ear) and imported it into my project as a Maven module from existing sources. I verified that all the web and ear artifacts were created by default, and didn't modify any of them.

I went to Run > Edit Configurations and added the exploded ear artifact to my new server in the "Deployments" tab, and ran the server. I hit the index page in the browser and saw the hello world text I was expecting.

Then I added some random text to the index.jsp's body, and ran "Update application > Update resources" from the Run tab. I reloaded the web page and nothing had changed.

I snooped around on the file system and, again, its building the artifact to the module's /target/ directory, and when I go to the server profile I can see that the files were copied over to "installedApps", not read directly from the module output folder.

0

Thanks for the details, I was able to reproduce the issue. We'll investigate it.

At the moment you can use the Deploy action to update the app instead of restarting the server:

0

https://youtrack.jetbrains.com/issue/IDEA-210668 could be related to the problem. During my testing WAR deployment with the liberty server profile worked fine, but now with the full server profile and EAR deployment it doesn't work as expected.

0
Avatar
Permanently deleted user

Thank you for testing that. I will note that my problem isn't exclusive to JSP - originally I was trying to do this with html/js content in the webapp folder, if that makes any difference.  

0
Avatar
Permanently deleted user

Was there a ticket created for this that I could watch for updates and/or a bugfix for the issue, by chance? 

0

You can follow https://youtrack.jetbrains.com/issue/IDEA-210668 at the moment. If we find that your issue is different, a new ticket will be submitted.

0

Please sign in to leave a comment.