Intellij Hotswap does not reflect java changes on wildfly webserver - java

I am running webapplication using Intellij and wildfly web server.
I would like when I modify my java class like small modification inside a method that these changes are reflected without having to rebuild the whole project which take mucht time.
For that I have configured jboss debugger like in the following screenshots and just start in debug mode:
When I save changes it shows the following message as you also can see on the next screenshots: JBoss/WildFly 26.0.1.Final: 0 classes reloaded
or
Loaded classes are up to date. Nothing to reload. The changes in java class are reflected only when I clean install on parent project and restart the server again. How can I get the changes reflected without having to clean install ?

Related

Do I have to restart tomcat everything for every jsp or java change?

I am running tomcat v7.0 within my eclipse. I have to restart tomcat for every single jsp or java change. I am sure I have set my server wrong somehow. How can I see my changes without keep restarting tomcat?
Thanks!
When you are deploying to the tomcat from eclipse, If you are planning to work without deploying every time you to a change to the code base, you can use Jrebel.
Jrebel will sense your changes and take care of the re-deploying. Only issue is that It is a have to buy plugin and I know there are opensource or free applications like that.
If you are running the application in DEBUG mode, it will auto restart every time you make any change to ur JSP or java code.
You can try deleting the tomcat instance from eclipse and also the Servers folder that is present in the Project Explorer. Add your server to eclipse again and deploy your war file. The changes to JSP or javascript files will now reflect without a server restart.
That not necessary it's depend upon your configuration
When you configure Tomcat in eclipse then we have 3 option
never publish automatically
automatically publish when resource change
automatically publish after build event
so you can configure this as per your requirement.You get this option once you create tomcat server in eclipse ,then select the tomcat server,then either press F3 or right click and open.
i prefer point 2 to select and make sure you have uncheck build automatically in eclipse ,so that once you sure about all the changes you can build the project and tomcat get restart automaticcaly

Is there any guide showing how to build effectively an application with appengine and maven in eclipse?

I'm trying to develop an application using Google App-Engine and Maven using Eclipse. I am facing a problem where by whenever you change a CSS or JSP file, a restart of the application is required. This makes working quite difficult, since a reload takes a lot of time.
For example when you develop on tomcat no need for restart is required when such a change is made, only Java or xml file require restart of the server.
Is there a solution that mimics the tomcat behavior on GAE SDK when developing on localhost?
If you've built using the standard app engine maven archetype, when you run mvn appengine:devserver from you -ear directory, the exploded war working directory is located here:
<yourapp>/<yourapp>-ear/target/<yourapp>-ear-1.0-SNAPSHOT/<yourapp>-war-1.0-SNAPSHOT.war
If you change any JSPs in this directory, they will get reloaded without needing to restart the devserver.
Thus, you can set up a simple script or command that copies all your JSPs and static files from /-war/src/main/webapp to that deploy directory whenever you want your files to be refreshed. I saw on some threads where people set up their IDE (in this case IntelliJ) to automatically do that copy whenever the IDE loses focuses, which makes it trivial to get pages reloaded.
Building application with appengine in eclipse using maven is not very effective and time consuming because on every change on jsp/css/js with a traditional approach there is a need to restart appengine or mvn appengine:devserver.
#adevine make me thought about a solution, and I found this link: http://andrei.gmxhome.de/filesync/index.html wich installs a plugin in eclipse, then I activate the project to sync files from myapp/src/main/webapp to a target folder generated by maven myapp/target/myapp-snapshot-0.0.1.
It's working!!!
Whenever a change is done in webapp the files are transfered automtically(no need to run anything else, just save the file) to the target folder and are reloaded successfully.
Hope this could help people because its frustrating working with appengine(restarts takes a lot).

How to debug problems with GWT dev/hosted mode?

I'm trying to set up the GWT dev/hosted mode in a Maven-based Java webapp. I start my webapp via Maven Tomcat7 plugin (mvn tomcat7:run-war-only) and it is running fine. Also, startup of GWT via mvn gwt:run works and shows no errors.
However, if I access my webapp with the gwt.codesvr=127.0.0.1:9997 parameter, I just see a blank page in my browser. Interestingly, the page source contains the content of my JSP, but it is only defining some divs to be replaced by GWT.
How do I debug this situation? I haven't found any option for GWT dev mode to generate some kind of logging output. For example, it would be interesting to know if the GWT code server ever receives a call. At the moment, I'm missing any clue where to start looking why GWT dev mode is not working.
My original question was, how to debug Maven GWT plugin in case it is not doing what it is supposed to do. Here are a few hints which helped me during this process:
increase log level to ALL via config parameter
check in browser (e.g. via Firebug) that files of hosted mode like devmode.js and hosted.html are queried
insert Window.alert("..."); into the onModuleLoad() function to see if GWT code is executed at all
ensure that your app server is executing the exploded war (e.g., delete packaged WAR file before starting app server)
after startup of app server, don't call page without GWT codeserver parameter as this already generates some GWT files in the webapp exploded folder, which might conflict with those to be created by GWT hosted mode; take note which files are created and delete them manually
GWT dev mode seems to be not fully deterministic as I was able to get it running after forced reloading of the page in my browser
start from a working example, e.g. like the one I shared here: https://github.com/steinsag/gwt-maven-example

Roo doesn't update class-files anymore

After working for weeks on a Roo Project mine stopped to update the .class-files inside the directory:
Project\src\main\webapp\WEB-INF\classes\com\company
and
Project\src\main\webapp\WEB-INF\classes\com\company\web
When I deploy with STS on the local Tomcat it used the new class-files but perform package command used the old one from the locations mentioned above.
Once I deployed the war-file to a remote server I got silly errors.
It took me like one workday to figure out what is going wrong.
How can I make Roo update the .class-files again? I tried poll now but it finishes within one second without any results.
Have you tried doing a perform clean from within the roo shell? This should remove the target folder and rebuild all your class files.

Can Eclipse automatically refresh Tomcat app?

I use Eclipse Indigo (EE) to build applications in Java framework Vaadin,
using Tomcat 7.0 server. After changes in code I wont see result in a browser,
so I need to click option "Clean Tomcat Work Directory.." and wait until
Tomcat stop and start a server.
Otherwise, when I refresh app page, I don't see any changes.
Even when I restart server (and when eclipse automatically restart it when I save changes), without cleaning tomcat directory.
Option "Automatically publish when resources change" is enabled.
Is any faster way to do that? or can I automate that process?
Additionally to the answer of Kowser, it is possible do hot code changes when running tomcat in debug mode.
Otherwise you could investigate in JRebel
In your "Modules" tab of your Tomcat, you hace to clic on 'Edit' and uncheck the 'Auto reloading enables' option.
With that, several changes won't need a restart (as long as you start your server in debug mode).
If you setup your project to use ant for building and deploying, you can simply add Ant builder to your project Builders to run your ant build and deploy targets every time after you have saved a file. Then provided that tomcat is configured to support auto-deploy, this should achieve what you want, with two caveats:
If your project takes more than a few seconds to build, building after every save is not practical.
You may run out of memory for the tomcat instance if the same app is deployed to it repeatedly for a number of times. This can happen if tomcat is somehow unable to recover all the memory from undeployed resources.
It might be possible. But your setup is a bit different from what I use. I am just using tomcat+eclipse to do Servlet development using Velocity and Torque.
The following works for me where changes are visible in the browser as soon as I save in eclipse.
I assume that you have a project directory such as
apache-tomcat-7.0.11/webapps/$YOU_PROJECT/WEB-INF/classes/
Create a symbolic link with ln -s from your eclipse project directory and to the classes directory in WEB-INF.
Then configure eclipse to write all .class files to this directory. (Done by right clicking on the project in Eclipse and choosing Properties and then Java build path.
In your $tomcat/conf/context.xml config file first tag should be:
<Context allowLinking="true" reloadable="true">
Also add the following as a child to if it is not already there.
<WatchedResource>WEB-INF/web.xml</WatchedResource>
That is what I have done, but I am not sure it works with your EE tools.
ps: This solution assumes that you are using linux/unix. I don't know if it works with windows. The major problem is that eclipse can't write class files outside the project directory (Which is why that symlink is required).
btw: Tomcat may(Depending on class loader, used .jar files and other complicated details) leak a lot of memory when automatic reload is enabled so you may want to increase the allowed memory(Mostly permgen) to prevent out of memmory exceptions from tomcat.
I know this has been asked and answered very long ago. But use this info if it is helpful to anyone of you. I use Eclipse Kepler and configured Tomcat 7 server inside eclipse. I don't have to do any other configuration but to just uncheck Update context paths check box. That is all. Leave other setting as default.
In this way, changes to the resources files (xhtml pages, css files etc.) as well as the java source code files show up in the browser. Only for class files the web application would be redeployed (no server restart auto as well as manual required).
Location of Update context paths: Double click on the tomcat server under Server tab. Under Publishing tab you would find this Update context paths check box.
Absolutely no other change needs to be done for the auto publishing. This works both in normal and debug mode of tomcat.
Screen shot from my eclipse below:
No, there is no other way.
You will notice immediate changes only while updating a JSP/HTML/etc.... Classes will not be loaded/refreshed automatically. It will be contradictory to change a loaded/instantiated class when server is live, isn't it? At least it should not be possible.
It's better to perform Unit Test while developing something. It can help you to reduce the amount of annoying server restarts.

Categories