Automatically synchronize Java servlet in Eclipse? - java

I'm using Vaadin framework and everything is setup fine using the Book of Vaadin. When I alter source code it automatically builds and synchronizes the server which I can see in the Server tab, however when I refresh my browser window nothing is changed.
The only time when I can see the change is when I select my module in the Server tab and choose Clean Module Working Directory in the right-click menu.
I have looked everywhere in Eclipse, but there must be a way where this is not needed or is done automatically, because it's somewhat tedious. Any ideas?

Which browser are you using? The Eclipse built-in browser (based on IE, I think) is not the best at noticing changes to the application.
Anyway, try appending "?restartApplication" after your URL to force restarting the app.

I had same problem, before i finished reading book of Vaadin. In my case it was because of session, i just add close listener for mainWindow:
mainWindow.addListener(new Window.CloseListener() {
#Override
public void windowClose(CloseEvent e) {
getMainWindow().getApplication().close();
}
});
It will close old session when F5 is pressed, try it!

Related

wicket: changes does not appear after page reload

I have created java Project with wicket in eclipse. the application works fine. The problem is, when I change the java code in the project and reload the page to see these changes, the changes do not appear.
The changes appear only when I run the project again (right mouse click on the project -> run as -> java application). Is there a way to see the changes after reloading the page without needing to run the project again every time?
Use debug-as instead. This will instruct eclipse to use hotswap and update your running application. Note that you'll still need to restart your application often since hotswap doesn't support all class file changes. For that you'll probably need to use a class-reloading solution, such as JRebel, or use the redeploy feature of a container.
Are you using Wicket >= 1.5? You might also be stumbling over the page version parameter that Wicket appends to every URL of a stateful page, e.g. ?5
If you simply reload the page with this parameter, the page will be rendered again, but not constructed new from the scratch, which might also lead to your changes being ignored.
It's quite annoying, but to get a proper reload of the page, you need to remove the parameter and hit enter.

Play! framework. create a new view

I created a new project using the play console
now, by default I got in my views directory two files:
main.scala.html
index.scala.html
I want to add a new view file. I call it "forums.scala.html"
now, I know that in order to render a view you need to do this:
views.html.forums.render("Forums");
the problem is that the intellisense doesn't recognize "forums"
but index and main it does recognize.
I've noticed those files:
class_managed/views.html/index.class
class_managed/views.html/main.class
but there is no forums.class so I suspect this is the problem.
I tried to build the project, but it didn't help.
so, what is the solution?
thanks
Your new views are compiled to managed sources after next browser hit if you are using play run for starting Play in dev mode.
If you'll use play ~run it will try to compile it as soon at it will recognize change in the file.
Finally if you started your app in production mode ie. via play start you have to stop it with ctrl+c and run again. Anyway, developing application in production mode is just a bad idea :)
Depending on your IDE most probably you'll need to refresh file structure to allow it find freshly created managed sources.
right click on ther project and click refresh, that worked for me - found it in another thread.
Found the solution.
running "compile" command did the work.
I understood that intelliJ do it auto, so I will probably use it instead of eclipse.
cheers!
If you want to program in scala, my recommendation is to forget about intellisense. Eclipses scala-ide is quite buggy, dont know about netbeans. And because of nonstandard layout of play2 application, non std development tools (play console), it becames even more handy to use simple text redactor (like sublime or textmate) with good old open-folder-as-project feature.

IntelliJ productivity tips running tomcat

I'm developing using IntelliJ 11u on a spring mvc application using tomcat.
I tried the maven jetty plugin, but after a few builds I keep getting java permGen issues and then it just hangs. I was told this was because spring uses log4j and it has some sort of leaks?
Anyhow, I'm asking for tips to help fire up a server, tomcat, with my updated code so I can make quick updates and have tomcat reloaded.
Here are my current annoyances with tomcat:
Only code changes seem to get auto-reloaded, if I make changes to my view pages things don't get updated unless I redeploy. The maven jetty plugin seems to map to my view pages directly and I saw updates to my view pages instantly w/o it even redeploying.
if I have more than 1 thing running in intelliJ, like say I have a main program that I run, or a unit test, IntelliJ seems to re-order what gets run in the run drop down menu and also the shortcut keys get changed to the last thing I ran.
I use google chrome, for some reason when I start tomcat it brings firefox to the forefront and opens a new tab each and every time.
If someone can address any or all of the above issues that would be great as I hate this dance I have to go through just to update/redeploy my application. I wish it could just be a consitant method, using shortcuts or automatically without me having to close the tab created in firefox, and then minimizie it, or redploy for a simple view change etc.
You should configure IDEA to update classes and resources and enable a checkbox in the Run configuration to do it automatically on frame deactivation.
Browser can be changed in IDEA settings and you can disable opening browser at all in Tomcat Run/Debug configuration.
As for the Run panel tabs order, you can pin tabs using the tab right click menu, in this case they will remain in the Run or Debug panel in the order they were created.
Look at JRebel if you want an even more productive environment (It costs, but I find it is worth it). As you can see here, http://zeroturnaround.com/jrebel/features/, it increases the types of changes you can hot-swap (no waiting for a build). I am currently evaluating it myself and will probably pick up a full license.
BTW, if you develop in scala (it looks like you're not, but just in case) the plugin is free.

IntelliJ IDEA: prevent redeploy for any little change

I am using IntelliJ IDEA and developing web application in Java.
Is there any way that I debug my app without redeploy for any little change? the redeploy thing makes the working very slow and annoying.
Update action in IntelliJ IDEA is configurable, in case of exploded web application you can set what to do: update resources, update classes and resources, redeploy, restart the server. In most cases it's enough to update classes and resources. Update can be performed automatically on frame deactivation (when you switch from IDEA to the browser).
It depends what are you redeploying, JSP or raw Java class? If you change a Java class then IDEA will not compile it and redeploy by itself. If you change a JSP (pr JSF...) you can click package file (Ctrl+Shift+F9) from right mouse click menu.
If you use Netbeans, Netbeans does this for you. I am also fan of IDEA but I liked Netbeans due to this feature.

Clean Working directory of Tomcat in Eclipse

When I work in on an servlet application in Eclipse, I have to choose Clean Working Directory in the server tab of Eclipse for the changes to be visible in the browser. Is there any way to make sure that I only have to build my servlet and the changes are immediately visible?
Doubleclick the Tomcat entry in Servers view, go to the Publishing section and select Automatically publish when resources change.
It by the way won't happen that "immediately". It might take around 3 seconds, you should see this activity in server logs. Although a slow starter, but Glassfish publishes in a subsecond. You may consider it instead for fast development.
Honesty, i do not think this is possible.
It is like programming in javascript and there is no way to see the result without clearing the browsers cache and reloading the page.

Categories

Resources