Hot Code Replace Failed in Eclipse - Delete method not implemented - java

I'm developing a java web-application with vaadin and spring and I'm using tomcat7-maven-plugin like application server during development. The problem is that when I run my application and I try to change everythings, I'm getting the following error.
I read many thread like:
Hot Code Replace Failed (eclipse)
How do I get Java “hot code replacement” working in JBoss?
But I'm sure that my jdk is the same for both compile and run steps, I have also the flag Project->Build Automatically activated but each time that I try to modify any thing I get the error above.

Unfortunately Eclipse can't deal very well with hot code modifications.
I would suggest you to have a look to JRebel as I suggest in Eclipse Hot Code Replace Fail - republish web application post.
JRebel is a JVM Java Agent that integrates with application servers, making classes reloadable with existing class loaders. Only changed classes are recompiled and instantly reloaded in the running application. JRebel plugs into IDEs and build systems.

Related

How to auto reload app engine dev server?

Im following the tutorial on the App Engine website for 'Google Cloud Endpoints' in Java. Everything works fine and I can run the development server using mvn appengine:devserver. The problem is that when I make any changes to a file (for example, any java file) the dev server doesnt automatically recompile. I need to ctrl-c to kill the dev server and restart it for every code change I make.
Is there a way to have maven automatically detect changes to any files in my project and have it automatically rebuild and restart the dev server?
Unfortunately no. If you want this behavior on your dev server, you need to use Python.
I run in the same issue and there is no real workaround provided by the App Engine to help you doing this.
From the "Using The Google plugin for Eclipse":
With Eclipse, you can leave the server running in the debugger while you make changes to source code, JSPs, static files and appengine-web.xml. When you save changes to source code, Eclipse compiles the class automatically, then attempts to insert it into the running web server dynamically. In most cases, you can simply reload the page in your browser to test the new version of the code. Changes to JSPs, static files and appengine-web.xml are recognized by the development server automatically, and also take effect without restarting the server. If you change web.xml or other configuration files, you must stop and start the server for the changes to take effect.
(https://developers.google.com/appengine/docs/java/tools/eclipse#Running_the_Project)
There is NOTHING comparable in Java (link from "The Java Development Server") (https://developers.google.com/appengine/docs/java/tools/devserver)
There's currently nothing in the App Engine SDK to automatically restart when files change, but that's not to say you can't do it. I ran into the same problem and wrote up a script to listen for file changes as triggers to restart App Engine. It's in JavaScript, so you'll need to install Node.js if you haven't already.
// Install watch-exec
$ npm install -g watch-exec
// Watch the current directory
$ watch-exec --command "mvn appengine:devserver" --watch .
This will immediately start App Engine, and then restart it any time a file changes. If the app crashes for some reason, the script will wait for your next edit before trying to restart.
P.S. That entire script is about 40 lines of code, and you could probably do the same thing in other scripting languages. If you haven't tried writing your own automation before, I'd definitely recommend checking out the source code to see how this works.
I've found using Gradle, GAE, and Spring MVC, the assemble command will put the correct artifacts in place, and the server will re-init the app. It's a little quicker than a server restart.
Using App Engine standard with the cloud.tools appengine-maven-plugin hot swap works fine (most of the time, can be problems when setting up the workspace).
For a multi-module maven project: no need to stop the server or browser,
just push the code changes (maven command package -pl *-server)
& refresh the browser.
Debugging with a debug client currently works perfectly for changing / adding code within methods.

Eclipse Java Remote Debug: How do I ensure that the code I've got in my project is the same as the code running in the JVM?

I've got some existing source code, and jars for a webapp. I am attempting to run the webabb using tomcat and then remote debugging the tomcat server using eclipse to figure out what is happening with the webapp.
For some reason however, eclipse refuses to trap any breakpoints. I've compared the md5sums of the jars on the server with the ones I've got in my debug project, and they match.
Is there some way I can ask eclipse to reconcile the java classes in the remote JVM with the java classes in the local jars and make sure they correspond. Or, perhaps, more specifically, whether the code associated with breakpoints I've set have actually be loaded into the remote JVM?
Check that on the Java Compiler properties page for the java projects in question that the class file options are all checked (you only need the first three but having all five checked is a good thing for debugging)

hot-replace debugging with maven on jboss

I'm currently using jboss/maven/eclipse to debug a web app. I've enabled remote debugging in the jboss run.conf file and then use mvn war:inplace to compile and with that I can successfully add a breakpoint and step through code.
However I remember a while back using Tomcat I was able to hotswap or hot-replace a java class by making changes, saving it and then having the debugger re-enter the method. I'm thinking there has to be a way to do this but don't know how.
You can try JBoss Tools Eclipse plugin, or if all else fails, JRebel (however, its not free).

Eclipse and JBoss not refreshing or rebuilding

I'm having this problem in eclipse (EE) when I change things in my code (even something as simple as the text I'm printing using println) it doesn't get applied. I'm using JBoss and when I rerun the servlet, nothing happens.
Any idea how I can force JBoss/Eclipse to do this? I can't preview anything so it's really annoying if I want to test some new code.
Thanks!
Eclipse publishes the newer versions of your application periodically (its called the automatic publish feature). Either the interval is too large, or you're not waiting sufficiently long enough for re-deployment, or automatic publishing of the application has been disabled.
Sometimes, despite ensuring the above, Eclipse might still not publish the newer classes, in which case you might want to perform a clean build, which causes the newly built classes to be loaded into JBoss.
Sorry to ask such a basic question: Do you save your changes before testing?
Eclipse uses its own compiler to check for syntax errors while you are editing, but you have to save the file before the edits take effect in the application.
I only ask because this could be confusing if you are new to Eclipse, having changed from a different IDE. File permission settings can also prevent your files from being saved or built.
Working on EJB deployed in JBoss with Eclipse IDE.
We have ANT build file, in which first old project is deleted from JBoss,
then compiling classes, & building proper directory structure & deploy as .ear - .sar again in JBoss directory.
Stop JBoss, run build file, start JBoss.
Its a good practice to have a build file to deploy project.

How can I deploy web app on Tomcat from running app

I would like to develop updater app. Lets say I've got:
- Running Tomcat
- Running Updater App on the Tomcat
- Running old version of the app on the same Tomcat
I would like to
- Stop old app
- Undeploy old app
- Deploy new version of app (lets assume that I've got new app war file somewere in Updater app resourcess.
Is it possible to do such remote deployment on Tomcat from another app at all?
To deploy a project to your Tomcat Server from another app you need to:
Add a library into your project “catalina-ant.jar” from the folder: {TOMCAT_PATH}\lib
And in your project to deploy a war file you need to only do:
org.apache.catalina.ant.DeployTask task = new org.apache.catalina.ant.DeployTask();
task.setUrl("http://localhost:8084/manager");
task.setUsername("managerLogin");
task.setPassword("managerPassword");
task.setPath("/UrlToYourDeploadingProject");
task.setWar(new File("c:/Project.war").getAbsolutePath());
task.execute();
Thanks to this solution I'm able to develop project that can update automatically my apps.
Yes. There's a set of tools (well, a .jar) released with Tomcat that's usually used by ant but that can be used by anyone willing to call the code. There are tasks for starting and stopping applications, deploying, undeploying, listing applications and so forth; essentially it's an API that wraps the functionality of the manager servlet.
One moment while I try to dig up the name or a link for you...
Here's Apache's information on this stuff: http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html#Executing Manager Commands With Ant
... and here's a user, elsewhere, describing in detail how he uses these tasks: http://raibledesigns.com/wiki/Wiki.jsp?page=TomcatAntTasks
You may object that you're not ant. That's true, but there's nothing magic about ant, it's just calling code inside the jar. That code can be called from anywhere else that follows the API.
Here's a tutorial on writing ant tasks: http://ant.apache.org/manual/tutorial-writing-tasks.html
Not quite the same, but it should give you an idea of how the API works.
I see no reason why you shouldn't be able to call this API from within a servlet if you want to.
Alternatively, you could run the manager servlet in your Tomcat and simply access the manager application like a Web service: Use your browser or WireShark to snoop on the traffic between your browser and Tomcat when you deploy an app, and then duplicate that to remote control manager. Me, I think using the tools jar is simpler.
If you use a "project lifecycle" tool, this undeploy/deploy can be automatized in the development cycle.
Saying that, I think about Maven2 and his "maven-deploy" plugin :
mvn compile : java compilation
mvn package : creation of the war file (for a webbapp project)
mvn deploy : stop, undeploy the old application, deploy and start the new version !
After, you can couple this automatization with a continous integration server (like Hudson).

Categories

Resources