I am working on my project of quiet sometime now I am using tomcat and eclipse both working correctly till now..
I deployed the war on 22-1-2012 ( with some print messages) it was working correctly then next day I made some changes removed some messages and redeployed the file...In my webapps folder it is showing the latest time for 'last modified' of my war file.. what wrong i am doing tell me..
P.S any changes to JSP pages of same project are reflected but servlet class is unchanged
This is what log file shows
_SEVERE: A web application appears to have started a TimerThread named [MySQL Statement Cancellation Timer] via the java.util.Timer API but has failed to stop it. To prevent a memory leak, the timer (and hence the associated thread) has been forcibly cancelled. _
Well this is the summary of my problem i hope i can explain you now the problem
i again performed the following steps
Deleted my webapp directory from webapps
Tried to access servlet (it shows 'Resource not available')
Make some changes in print statement to debug
Redeployed WAR from eclipse
Again when access that servlet it is not the latest version it is showing same old messages.
Now tell me if there is solution....
Thanks in advance
After trying so many thing i just observed when i deploy the WAR file non-JSP servlet class files were not included in WAR when I manually add these class files in WAR all the changes are updated.. So now can u tell me how to auto deploy these in WAR..whats the problem?
The JSP files are not updating because they were precompiled, and even though they may pull information from files that have changed, each JSP file that may be affected needs to have a minor change made to it, like add a space and then remove a space, and then save it.
Then build your WAR, and then the updates should show. I went through this same problem tonight and none of the other answers helped. The key is, to check the file dates in the Tomcat directory of where you deployed the WAR. I noticed that even though I was deploying an entirely new cleaned WAR, and deleting all folders, there were still older cached files in there, probably because Eclipse keeps them to save compile time, thinking they don't have any changes.
Hope this helps
Go to Servers View in Eclipse:
Double click on your server. In my case, it’s Tomcat.
A Tomcat Web Module should pop up. Click on Modules tab at the very bottom (see Pic1)
Select your project. Click “Remove” button.
Pic 1:
Now you should see a star next to the Tomcat Tab. That means you need to save your changes. So do a Control+S.
Pic 2:
Right-click on your project in Project Explorer. Go to Maven -> Update Project…
Pic 3:
Now this is the important part, make sure you have “Force Update of Snapshots/Releases” checked. Having that part checked is critical. Then click Ok.
Pic 4:
Now look at your Server View. It should look like this, with a “Restart” warning telling you that it’s out of sync.
Pic 5:
Right-click on it and choose Restart
Pic 6:
Let the server restart. Now if you go back to the Server View, you should see that it’s synchronized. That’s what you want. Like this:
Pic 7:
Now you should be able to right-click on your project and choose “Run As” -> Run on Server and you should see your changes.
Pic 8:
If things still didn’t update, go back and look at your Server View and make sure it doesn’t say the restart thing like in Pic 5 above. If it does, please restart your server again like in Pic 6. Then click refresh on the browser.
Go to browser settings and clear the cache.
Check the log files for Tomcat, I bet there is a startup problem with your web app and it's not getting deployed.
The reality is that Tomcat cannot be running code it doesn't have a copy of. Especially if you have restarted it. It sounds like there is a separate "copy" of your web app that is actually in use. Either made inadvertently by you (hey lets face it, we've all done this) OR made by Tomcat in a location you weren't aware of.
Pick a unique file that exists within your web app. Maybe an icon name, or a configuration file name. Search the entire hard drive for it to locate exploded copies of the WAR file. This will help find it in a temp directory or working folder. Make sure to clean those up.
Also, make sure you are running the Tomcat that you think you are. Most developers with multiple Tomcat installations has also made the mistake of deploying to a different location. Look at the process list to see the arguments given to the JVM at launch time. Be sure to also check environment variable for things like CATALINA_HOME.
EDIT: Your update that JSP pages change, but classes do not make me think you have multiple JAR files on the class path that have the same file in it (one older version loaded first) OR you have changed a class name in the code base, but not updated references to it.
any changes to JSP pages of same project are reflected but servlet class is unchanged
It is not clear what you are saying.
If you are saying that the updated JSPs are in the expanded webapp directory, but the generated / compiled JSP classes have not changed (in the work directory), then try deleting the classes from the work directory. You may need to restart the web container too.
If you are saying that the non-JSP servlet classes have been updated (in the webapp) but you are not running them, then try restarting the web container.
If you are saying that the non-JSP servlet classes have not been updated in the webapp directory, then something went wrong in the webapp deployment. Shutdown the web container, delete the webapp directory (and the compiled JSPs for good measure) and restart the webapp.
After trying so many thing i just observed when i deploy the WAR file non-JSP servlet class files were not included in WAR when I manually add these class files in WAR all the changes are updated.. So now can u tell me how to auto deploy these in WAR..whats the problem?
So the problem is nothing to do with deployment. The problem is that you are not building the WAR file correctly in the first place.
I can't help with this because I don't use Eclipse to build my WAR files. (I use Maven so that the build process is scripted and reproducible ... and doesn't depend on me clicking the right buttons in the right order every time.)
is your tomcat server.xml pointing to the right Workspace?
to make sure, you go to tomcat installed directory -- find server.xml in the confi folder
for every war file, tomcat creates a similar named folder. Delete the folder, try to redeploy war again, hope it will reflect.
In web.xml file add one letter at the end and delete it and then by pressing enter save the file. After that run the program and it works with updated data.
go to catalina home\conf\context.xml
change <Context> to <Context reloadable="true">
Make sure you restart tomcat.
Boom.
You might have to still press F5 or Ctrl+F5 two or three times though.
TL;DR: Make sure your eclipse project is set to build automatically: Project > Build Automatically
I apologize for answering without having complete knowledge of what the WAR files are, but I assume the WAR files are the compiled .class files in the "build" folder.
I noticed that when I saved my Servlet "HelloWorld.java" in my case, that the compiled "HelloWorld.class" did not update at all. I could force the project to build by right clicking the java project and selecting "Build Project". After Building the project, the "HelloWorld.class" file was successfully updated, but the updated code still did not show on the server.
To get the results to show on the server, I had to click on my server (mine was called "Tomcat v9.0 Server at localhost [Started, Synchronized]") and then I clicked "Publish to Server". If you do not see your Servers, do: Window > Show View > Servers
I didn't even have to restart the server, after a few seconds (and refreshing google chrome), the website updated itself!
Of course manually building and publishing (and possibly restarting) the server is kind of too much for my lazy fingers, so I found how to fix it. You can just go to Project > Build Automatically. and then the website will update anytime you save a modified java file.
This solution worked for me because I was only missing the automatic building. but you could also have a problem where the server doesn't automatically publish.
I personally didn't have this problem so I'm just speculating, but there are some settings for publishing. In your "Servers" view, double click on your server name (in my case, double click on "Tomcat v9.0 Server at localhost [Started, Synchronized]"). A tab should open up showing your server settings. Expand the section titled "Publishing", and set your publishing settings as you desire. Right now mine is set to "Automatically publish when resources change".
Unfortunately I have no clue how to make the server automatically restart upon the saving of a modified .java file.
Related
My question is that recently I have started a web project in IDEA, with some servlet filter. At first it was ok ,but today I've found my idea's hot deploy dosen't work again.
For example,when I changed servlet , I need to hit ctrl+shift+F9 to recompile and it will work automaticlly. Now it just run like I didn't change it, even restarted tomcat doesn't help.
Now the only way to update changes is to restart the IDEA whenever I alter java file, servlet, filter, listener, java bean,etc.
I have checked the output path, the class file did changed, the last modification date shows correctly,and I only had one output path.
I figure it is some thing to do with the project setting?
Here are some pictures of my project settings:
And also, whenever I creat a servlet or listener, it shows this weird thing in the Web windows below the Project explorer, like it was loading, sometimes it literally shows loading..., like this:
When I recompile the Module,it shows
Warning: Output path D:\IDEADevelop\LittleBBS\web intersects with a source root. Only files that were created by build will be cleaned.
On the Project tab, replace
D:\IDEADevelop\LittleBBS\web\WEB-INF\classes with
D:\IDEADevelop\LittleBBS\out.
On the Modules tab, click the option Inherit project compile output path.
On the other tabs, ensure that the output directories are consistent to D:\IDEADevelop\LittleBBS\out
I am to trying to enable hot reloading in Weblogic 10.3.3. I tried adding
<resource-reload-check-secs>1</resource-reload-check-secs>
to weblogic.xml (which supposed to be default value in debug mode), but it did not help. However, when I make changes to .jsp files there is no need for republishing.
Any suggestions on how to make it work (if this is even possible)?
Also, jrebel is not an option at the moment.
I guess it is related to whether the application is deployed in exploded or virtual mode. The workaround I found was to replace the file (A bit annoying but saves a redeploy).
Navigate to
<YOUR ECLIPSE WORKSPACE>\.metadata\.plugins\org.eclipse.core.resources\.projects\<PROJECT NAME>\beadep\
There you will have your application files and you can simply replace the changed file.
I can't get any pages of my webapp to load (locally on Tomcat 7.0.2.6), due to this NoClassDefFound error. I'm at my wits end trying to figure out what the cause is, here is what I know:
My coworker has this project successfully running locally (on Tomcat) and on our development server (WebLogic).
I have done a fresh pulldown from svn so my code is exactly the same as his. I've verified that I have a shared library reference to Aspose (and that the required .jars are in there), and that weblogic.xml has an entry for it.
We saw this same error when initially deploying on WebLogic because the Aspose library was named incorrectly, but it ran fine locally on his Tomcat server.
I've tried cleaning and rebuilding the project to no effect.
As best as I can figure, it has to be either a Tomcat issue, or maybe an Eclipse setting.
Has anyone encountered a similar situation? Any ideas on what to try to resolve this?
First thing you need to do is determine if you are colliding with another class with the same name and package. The easiest way to do this is with the cygwin/linux console, save this shell script to a file say, findjar
find "$1" -name "*.jar" -exec sh -c 'jar -tf {}|grep -H --label {} '$2'' \;
put it in your path and navigate to the root of the server instance and run the script like this
findjar . yourclass
Note the period, dont forget it. this will return if you have multiple classes with the same name in your project.
once your sure the project is clean and there is only one copy of the class, i would try actually adding your shared libraries folder to the websphere server instances JVM arguments. to do that:
Go into the admin, click on servers
Open server types, click on websphere application servers
You should see your server listed there, click on it
On the right hand side, you will see a section “server infrastructure” and below that is a subsection “Java and process Management”
Open that section and click on “Process Definition”
On the process definition screen is another right hand column. Click on “Java Virtual Machine”
Yes, finally we are on the correct screen, there is an end in sight here, I promise
On the virtual machine page, there is a large text field labeled “Classpath” What you need to do is enter the full path to the shared libraries folder
its odd and makes no sense to have to do it, but i have had to do that in the past to allow my code to see the properties files in a shared resource.
It is possible that your colleague has java librarys installed within his Tomcat instance itself.
Take a look in the Tomcat directory for some lib folders (I cant remember the exact location and I think it changes based on the version) but something like ${CATALINE_HOME}/common/lib
Verify that he doesnt have differen JAR files in his tomcat installation as yours.
From this question: Does Tomcat load the same library file into memory twice if they are in two web apps?
They are apparently stored here:
Tomcat 6 $CATALINA_HOME/lib
Tomcat 5 $CATALINA_HOME/common/lib
Though I'm not much experience in it, but have seen many times that modified JSP sometimes don't get change while refreshing the page. I have to manually delete the source and .class of JSP from \work\Catalina\localhost..., only after that I get change. WHY??
A lot of times when I have made changes to JSPs and it doesn't show up there was a syntax error with the JSP. Check your tomcat log to see if there was an exception while compiling the JSP.
Depending on settings, Tomcat should be able to auto reload JSPs when you reinstall the war file. That being said, the behavior has always been extremely flakey for for me. What I tend to do is create a Makefile (even if using ant or maven for builds) to install new copies of the war file: Effectively, it:
If work directory exists in ${tomcat}, delete it
If ${webapp} directory exists in ${tomcat}/webapps, delete it
Copy ${dev}/target/${webapp}.war to ${tomcat}/webapps
I have a simple hello, world servlet application that I am just playing around with, and pushing it out to my tomcat server on a VPS.
When I make a change to my code, and deploy it, tomcat doesn't serve the newly published code (even after starting the service again).
I stop the service, then push the new war file to /webapps/, and I make sure to delete the old exploded folder also.
When I re-start the server, it still serves the older codebase.
Is there a setting in the config to stop this behaviour?
Also, what folders would I have to delete? Please be specific (folders and paths) as I have tried deleting some and havent' gotten anywhere.
You can delete the "work" directory.
Are you sure it's not a browser caching issue?
I'd add that in case of really odd behavior - where you spend a couple of hours saying WTF - try manually deleting the /webapps/yourwebapp/WEB-INF/classes directory. A java source file that was moved to another package will not have its compiled class file deleted - at least in the case of an exploded web-application on TC. This can seriously drive you crazy with unpredictable behavior, especially with an annotated servlet.
A little late for the party, here's how I do it
Undeploy application from manager
Shutdown tomcat using ./shutdown.sh
Delete browser cache
Delete the application from webapps, and from /work/Catalina/...
Startup tomcat using ./startup.sh
Copy the new version of the application into /webapps and start it.
I encountered some weird behaviour that did not reflect the actual code base so after some time trying several solutions, my problem was solved by manually deleting everything under /var/cache/tomcat8/
Seems a timestamp issue. According to tomcat documentation, if there is a new jsp or servlet this will create a new _java file in the work folder unless the _java.class files are newer than the jsp or servlets.
Tomcat also creates a ROOT directory at the same level as work/. ROOT/ also caches the old stuff. delete ROOT along with Catalina directory in work.
I'm new to tomcat, and this problem was driving me nuts today. It was sporadic. I asked a colleague to help, and the WAR expanded and it did was it was supposed to. 3 deploys later that day, it reverted back to the original version.
In my case, the MySite.WAR got expanded to both ROOT AND MySite. MySite was usually served up. But sometimes tomcat decided it liked the ROOT one better and all my changes disappeared.
The "solution" is to delete the ROOT website with every deploy of the war.
Sounds like your class loader is not loading the servlet classes once they are updated. This might be fixed if you change your web.xml file which should prompt the server/container to re-deploy and reload the servlet classes.
I guess add an empty line at the end of your web.xml and save it and then see if that fixes it. As i said this might fix it or might not.
Good luck!
I have a bad time putting my war file at /etc/tomcat7/webapps but the real path was /var/lib/tomcat7/webapps. May you want to use sudo find / -type f -name "my-war-file.war" to know where is it.
And remove this folders /tmp/hsperfdata_* and /tmp/tomcat7-tomcat7-tmp.
I had the same issue twice, but in the second time I realized it wasn't a problem on Tomcat at all.. Try to delete the cache of your browser, refresh the page and see if the new version of the page on your server is being shown up. It worked with me.
In folder "/webapp" delete *.war files and folders corresponding to these
folders(the same name).
Clear folder "/webapps/ROOT" tomcat.