JavaEE Servlet won't hot deploying - eclipse

I started working with javaEE and currently doing some basic servlet stuff. So I'm using Eclipse neon and GlassFish server. Created a dynamic web project and everything works fine.
The problem are servlet file changes. If there is a change in the java file nothing happens - no hot deploying/ republish. I have to complete remove the application from server and re add it to see the changes.
Changing .html files works (doesn't effect servlets changes)
Rebuild does nothing
Server "clean" does nothing
Server restart does nothing
"Automatically publish when resources change" is of course on, hence the html changes

The problem might be, that it does not observe the correct files for triggering the redeployment.
I haven't tried it for GlassFish, but could see the same behavior for WildFly as you described with the default server settings.
Try to add \.class$ to section Application Reload Behavior in server settings. (This will be the case for exploded deployment.)
Credits to varantes answer in this question

Related

Tomcat not detecting changes to java file at all or automatically

I am running Eclipse enterprise version 2019-06 and Tomcat v9.0. I am trying to run a Spring MVC project. Tomcat will not detect changes to the controller classes. It does notice changes to the JSP files though I have to manually restart the server for them to take effect.
First, I am wanting the server to notice changes in the Java classes themselves, even with restarts
Second, I am wondering how to get the server to auto-detect these changes (both class and JSP changes) so that there is not a need to manually reloading the server.
I have tried:
I have ensured that 'Automatically publish when resources change' is selected in the Publishing subsection of Tomcat
I have ensured that under Modules, the Auto-Reloading is not enabled
(Yes, I have tried 'turning it off and back on'. I have deselected and changed the selections as noted above to others and restarted only to change them back again with nothing happening.)

Eclipse, maven, tapestry, tomcat auto load

I'm running eclipse mars EE. I have a maven project with tapestry 5.4.1. I have tomcat 7 maven plugin and everything is working fine except I'm not able to immediately see changes to tml and css files. When I make a change to any file it's eventually reloaded but it takes time which slows development. I want to be able to see css and tml changes instantly. I can wait for java changes until tomcat reloads them but I can't wait for css and tml changes.
I've read several articles on configuring the tomcat server within eclipse including this stackoverflow entry
However, they don't seem to work or achieve what I want. It seems the issue lies in the fact that tomcat has to wait for a new jar/war to be created and deployed instead of pulling the files directly from the project.
Also, I'm aware of Tapestry's class reloading feature....which doesn't seem to work either. Perhaps my project isn't configured correctly? Here is a screen shot of my project
There MUST be a way to accomplish this. We've all been writing web apps for tomcat in eclipse for 15 years!
Thanks for your help!
It sounds like you may have several issues that are described in the "Troubleshooting Live Class Reloading" section at the bottom of the https://tapestry.apache.org/class-reloading.html page. Please read the Tomcat-specific help at http://www.tynamo.org/Developing+with+Tomcat+and+Eclipse/ if you haven't already.

Is it possible to apply changes to JSF files without republishing?

I'm using IBM RAD version 8.0 and deploying the EAR applications to IBM WebSphere 7.0. Each time I change a JSF file, I need to republish the application, otherwise the changes are not visible.
Publishing takes some time, so usually it takes minimum a minute before I'm able to see the efects of even the most minor change. In 'normal' application development it's about a few seconds, and it's crucial for someone who is no JSF coryphee and still learns and needs to experiment...
Is it possible to use the JSF ability to re-load the JSF page definition without application restarting, when working with IBM RAD and WebSphere? Or I'll be forced to create second environment with Eclipse & Tomcat, for JSF experiments only?
This is normally to be configured in server configuration. Doubleclick the desired server in Eclipse's Servers view and head to Publishing section.
Note that you should take Facelet cache into account as well, particularly when using MyFaces which caches relatively agressively. If you make sure that javax.faces.PROJECT_STAGE context parameter is set to Development, then both MyFaces and Mojarra will relax the Facelet caching strategy, causing it to recompile the Facelet file almost instantly instead of using the cached version for a rather long time.
An alternative to Publishing setting is to use JRebel. It is able to publish changes in Java classes such as managed beans and EJBs as well, saving a lot of hotdeployment time. It has an Eclipse plugin as well.
This thread is old, but I still had the same problem, using eclipse and WebSphere.
One place to check is this. If you use JSF files with the .xhtml ending, you have to make sure that changes in these do not trigger automatic republishing.
In the tab "Servers" double-click on your server.
Open the "Publishing settings for WebSphere Application Server"
Click on "Set Advanced Publishing Settings...".
In the "List of file extensions that do not trigger the server to publish ..." insert or append ", *.xhtml".
Close these settings and restart the server.
In web.xml I have also added a parameter with the name javax.faces.PROJECT_STAGE and the value Development , which may have an influence on the offending behavior.

Getting Eclipse to automatically reload the JSP pages in my Java web application

I was given a template of a Struts project to work on, and I noticed that when I run the web project on integrated Tomcat in Eclipse and make changes to the .jsp viewpages, they don't automatically reload after a few seconds - which does happen in other projects I made myself.
So I figured this was a configuration issue and I did some research, I had a look at my Tomcat server settings:
(x) Automatically publish when resources change (1 second interval)
But because my own projects reload and I use the same server for them, I figured it must be an application specific issue.
So I looked at context.xml to see if there was anything to change here
<Context
...
reloadable="true"
...
>
Which I can only assume tells the server to indeed reload the application on changes.
So I really can't figure it out. It seems to me like everything is in order here. What am I missing?
From Apache Tomcat documentation about the Context attributes:
reloadable
Set to true if you want Catalina to monitor classes in
/WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically
reload the web application if a change is detected. This feature is
very useful during application development, but it requires
significant runtime overhead and is not recommended for use on
deployed production applications. That's why the default setting for
this attribute is false. You can use the Manager web application,
however, to trigger reloads of deployed applications on demand.
Also maybe this will be interesting for you: Using Tomcat Reload Features To Speed Up Development
I ran into the same problem, with a Java/Spring project that I imported via its Maven .pom files into Eclipse.
I found that I had to run the project with "Debug" instead of "Run" - only then, changes to my .jsp files were noticed, so that a reload of the web page would show the changes almost instantly.

JBoss server does not get changes

Eclipse Indigo
Version: Indigo Service Release 1
Build id: 20110916-0149
JBoss 6.1.Final
I have a server which i have configured with some support, but it has broken down.
Broken down means, even tough i;
- stop the server,
- clean and build projects in workspace,
- and clean the server and publish from scratch,
- and start the server again
it responds like it has yesterday's code. I made lots of change but server seems not to be aware of changes.
If you have an advise on this issue, please provide.
Thanks
Try autodeploying your .war or .ear file manually, not using the Eclipse JBoss connector (which sometimes breaks down and acts strangely). Just copy the file to the autodeploy dir (for JBoss 6 i believe this is /server/default/deploy), check the JBoss's logs/console to see that your file is currently deployed, then delete it from there, and again check that the JBoss console confirms succesfully undeploying that application.
Now, that Eclipse JBoss connector is convenient because it lets you quickly deploy, debug, etc (even tho it has it's bugs). You can however to several things to simulate it's behavious without actually using it:
simplest one: Use Jetty: http://irc.codehaus.org/display/JETTY/Downloading+Jetty. Comes as Eclipse plugn, maven plugin, stand alone server. Jetty 8 supports servlet 3.0 so it's up to date. Deploying and debugging is fast and easy and it actually works (I use this a lot). Only downer: doesn't have EJB container.
Use tomcat 7 (stand alone install) and the Eclipse sysdeo plugin: http://www.eclipsetotale.com/tomcatPlugin.html. Allows for seamless deployment/debugging as you'd do with a Java SE application inside Eclipse. Again, the downer is no EJB container
If you really wanna use JBoss, try the following:
start in in debug mode all the time by adding this to your run.bat:
set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS%
make your "target" project folder (the one where either Eclipse or Maven (whichever you use)) to be something like [jboss root]\server\default\deploy\myAppName
Start a "Remote Java application" debug session from Eclipse on the port 8787.
With all this the project should deploy any changes you make on the fly, and stop at whatever breakpoints you have when execution reaches them. It's not awesome, as sometimes certain changes will not be taken into account (eg: if you modify the body of a method in a Java class it will be hot-deployed. If you add a new method it will not).