Since two days it is not possible to debug my application, normally I use tomcat 8.0.27 for my project. When I use 8.0.39 it also does not work for the same project. I cleaned it, cleaned working space, delete it, installed it again and still it does not work.
When I try it with another project in another workspace, it works well ...
screen print error message tomcat eclipse
I've been having issues with a Java project that I've been working on for a while.
Starting about 1 or 2 weeks ago, whenever I use Netbeans (8.0.2) to generate a new file in the project (right click on package > new file), the wizard will hang for up to 10 minutes before releasing control back to me. The file is created after about 5 minutes. This doesn't happen with any other project, only this one; but I can't find anything different in my project's configuration compared to projects that work.
I created a bug report about this on the Netbeans bug tracker, but it hasn't been looked at in over a week. It has a copy of the Netbeans output log, and a profiling snapshot of the class generation.
I've tried reinstalling Netbeans (remaining at 8.0.2), which didn't help, and I don't really know what else I can do to locate the problem. If anyone has experienced anything like this, or has any advice on how I can track down the issue, it would be greatly appreciated.
Here is a link to my project on Dropbox. Feel free to download a copy, compile it, run it, etc.
I am using Windows 7 64-bit, and I am using the official Netbeans 8.0.2 from netbeans.org, launched straight from the desktop (I am not using any particular command line arguments or enviroment variables, as far as I know)
It turned out that the issue was that my Mercurial client was hanging when it made status calls, and Netbeans, due to a bug, was stuck waiting for it forever.
The issue with Mercurial can be worked around by deleting the Mercurial log file, and the bug with Netbeans was eventually fixed.
I'm running Eclipse Helios Service Release 1, with Tomcat 7.0.12 in Linux Ubuntu Natty Narwhal.
I've been happily hot re-deploying my webapp until it stopped working for apparently no reason. The following exception is displayed:
SEVERE: Allocate exception for servlet Index
java.lang.ClassNotFoundException: obliquid.servlet.Index
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
In Servers tab I've "Tomcat v7.0 Server at localhost [Started,Synchronized]
My project appears as a child of Tomcat v7.0 Server
In Properties, Java Build Path, Source I've Project/src Source folder
In Properties, Web Deployment Assembly, I've the following mappings: /WebContent -> /, /src -> /WEB-INF/classes, /test -> /build/classes
My src directory contains a Servlet in obliquid/servlet/Index.java
I tried already to click on Clean Module Work Directory... and Publish
I tried to stop and start the Server from within Eclipse Servers tab
What else should I check? Thank you.
UPDATE Despite now I'm working with the new project, I came back to check the old one, and mysteriously now it's working. I think I won't be able to find what has happened.
However today with the new project, I had 404 errors with no apparent reason and I found out that right clicking on the Tomcat server and selecting "Clean..." can be useful. Maybe it could have helped.
Selecting "Clean..." says: "Clean will discard all publish state and republish from scratch. Are you sure you want to clean all published resources?". Selecting yes, I solved the problem
UPDATE 2 It happened again on the new project. 404 errors, this time they don't go away.
Stop -> Clean... -> Start (404)
Stop -> Clean Tomcat Work Directory... -> Start (404)
Stop -> Clean Tomcat Work Directory... -> Clean... -> Start (404)
Stop -> Remove on the application -> Clean... -> Run As -> Run on Server -> (404)
Exit Eclipse, Start Eclipse
Start the server -> (404)
UPDATE 3 It turned out that this time I just didn't notice an exception caused by a listener-class during startup. After solving the problem, it worked. Guess I should stop working at 3 AM.
While on Tomcat 6 and Eclipse Ganymede I found out the following chain to work like charm:
1 stop server
2 project -> clean
3 project build (I had automatic build disabled)
4 delete server
5 delete Servers folder
6 restart Eclipse
7 create new server, add project and start :)
takes some time but worked like charm. My problem was a irritating Listener start problem, but this seems to be something similar: a property at tomcat. Btw: nowadays I am also a big Glassfish fan.
I found that this procedure is useful:
Click on Servers tab and Stop the server in use if it's running
Right click on the server again and select Clean...
Right click again and select Clean Tomcat Work Directory...
Hopefully the ClassNotFoundException should be gone now.
Another time I had a problem with a class launched at server startup, an exception in a listener class (ServletContextListener). When a ServletContextListener raises an exception during startup the application deployment is aborted, hence the 404 errors. In that case fixing the problem that caused the exception, made the application working again.
EDIT: This shorter procedure worked for me most of the times, but today didn't work and I had to follow Mico's extended procedure. My suggestion is, if you have a similar problem, first try this shorter procedure. If the problem persists, try with Mico's.
I'd recommend that you stop and start the Tomcat server again. Hot deploy does not work forever; there are some issues that will cause you to have to restart after a few redeploys.
I wonder when I see the accepted answer with +25 is it really accurate?
First if you are going to delete the server then whats the point in cleaning it? It will take your time unnecessarily and nothing useful will you gain.
So i will say just 5, 6, 7 steps should do the magic
5 delete Servers folder
6 restart Eclipse
7 create new server, add project and start
This could be something I learned on con-fess 2011. For me this sounds like a classloader problem.
The theory behind:
Java does not only use the type of the class but also the classloader which loaded it to identify the type of an instance. This means a simle operation could fail, e.g.
ClassA a1 = new a1;
ClassA a2 = SomeOtherClass.giveMeInstanceOfA();
a1 = a2;
This example would fail if SomeOtherClass uses a different classloader because Java would say that they are not the same.
The speaker also mentioned that some servers use per default about 45 different classloaders.
What does this mean in practice:
You deploy your webapp to the server, everything runs fine. The server caches the classes and everything he needs to load them somewhere. Now you make a hot deploymen and the server may loads new classes with a new (or different) classloader. This is the point where it starts to become dangerous because from now on you have two different classes in the memory which should be the same. Simple operations like casts (ClassA a = (ClassA) new ClassA()) fail, new Methods within the class are not found (because the server takes a cached version without this method),....
This is the point where I restart the server, clean the working directory (to get rid of the cached versions) and start thinking about hot deployment as critical thing.
If it is possible to try Mikkos procedere and this solves the problem this explanation could help you understand why.
I know this does not solve your problem but could give you some hints what maybe could have happened.
Speaking of hot deployment of Tomcat, you would indeed experience various problems, the least of which is memory leak, which is why you would have to restart the application. I would recommend to try JRebel for fast turnaround of "make and save any changes and then refresh the browser and see the changes immediately". You can find the JRebel hands-on lab, which shows how to use it with Tomcat and Eclipse. http://www.javapassion.com/rebels/jrebel_basics/
I have gained some new experience on programming and I am not anymore starving on Eclipse + Tomcat combination. Several ways here can help you out of the need of the usage of that combination:
First of all, don't use them together!
You can use other available IDEs, e.g. IntellijIdea (that is not free, but is worth of investing) has an property that when you debug a Java code, you can change code on fly and compile the Java files one by one and then it suggests if you'll want to have it updated on server. No restart needed almost never (of course it sometimes gets lost, but mainly it works).
Use standalone tomcat server, not the one inside Eclipse / your IDE. That first trick works only when you debug external server, nothing inside IDE. There comes the second tip: if you happen to change only jsp or html content, those files can be copied to the right place inside tomcat's webapp folder manually with unix cp or windows copy command and if you happen to develop files in same foulder long time, you can copy the folder content (e.g. myFolder/*.jsp) as many times as you wish and no restart is needed at all. The changes come visible when you touch or edit&save the web.xml file inside the webapps folder and then after that with refreshing the visible page on browser. Probably hard refresh with CTRL+F5 is the best way.
Thanks to #Verdan about his comment, otherwise I wouldn't have came back to answer again.
I was able to solve this by disabling the maven nature (right click on project >> maven >> disable maven nature). Then re-enabling it (right click on project >> configure >> convert to maven project). I had tried all of the other tips and tricks above, but this is the one that finally worked.
I was running into the same problem - tried all of the above, Eclipse always freezed when i tried to start the server, even after i deleted all the server configs and created a new one with a freshly downloaded tomcat instance. Anyways, problem wasnt solved until i moved to a new workspace, reimported the projects and created a new server. Seems like an Eclipse bug to me...So in case nothing else works, this is the way to go...
I'm currently struggling with the same problem, but nothing mentioned here does not help me. Anyway, I found out that if I:
stop server in eclipse
run tomcat elsewhere (in my case the xamp distribution)
stop currently running tomcat
start tomcat in eclipse
everything works just fine, of course until I change something in code and try to test it again.
This might be the ultimate newbie question, but I am really in a hurry and need a quick fix.
I have a Java project which I develop under Eclipse, and run under Tomcat, using the Eclipse plugin. Until last night everything was sound and fine. Then, I got an Eclipse error, which made me kill the Eclipse process ... and this morning, the project does not want to run.
It compiles, but as if Tomcat has no idea of my project library folder. When I run it, it starts screaming "class not found" exceptions. I did a little experiment of moving my project libs directly into Tomcat's library folder - it works, so clearly the problem lies in Tomcat, not recognizing my project lib folder any longer.
I tried cleaning the project, refreshing it and whatnot, but still the problem persists. I don't want libs t remain a direct possession Tomcat, because that makes a series of other problems and complications. I just want things back as they were last night before the crash.
A solution that seems to have worked - go to the Server view, right-click, then "Clean Tomcat working directory". It has always been there, I must have just been too hectic before to notice it.
i am working on a flex+java combined project.
My IDE and computer configuration is as follows:
Windows 7 Professional, 64-bit, Core2Duo 2.1GHz, 2GB Ram
Eclipse (helios) with Flash Builder Premium v4.0 Eclipse plugin
Flex=javaEE combined project with BlazeDS v4.0.0.14931 and Apache Tomcat 6
using BlazeDS remote object--RPC for flex+java communication.
My Problem is :
Any change in java code is compiled immediately and appeared on output when i run the project on server.
When i make a small change in Flex code (eg, reposition of a button...anything), and run the project on server, it does make any change on output.
Actually it depends on my luck... because it makes change in output randomly.
what is is happening???
i tried rebuild, republish, clean , restart server, restarting the IDE, restarting the computer..... all available feature i could think. Also, i created a simple flex project on IDE and compiled it..... everything is compiled and displayed on output.
Please HELP ME.
Ganesh Tiwari
IOE, Pulchowk Campus, TU
Nepal
Try to clear your browser cache and see what happens
Please clear the Browser Cache each time you run and then try.
SWF is cached by the browser, so it does not take the new one, it displays the old copy only.
Hope this should solve your problem