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.
Related
This may sounds like a dumb question to some, but I am not a Java developer, we have moved a Java app from Rackspace server to AWS linux server and upgraded MySql from 5.2.x to 5.7.x. Some SQL statements are causing issues so I am trying to fix those inside the .java files. However, when I save the file, and use .sftp library from VSCode to push the changes to the linux server, then refresh the site, it does not reflect the changes. Is there anything else I need to be doing every time I make a change?
I was able to update some string in a .jsp file and that worked when I refreshed, so I am not sure why when I change a .java file, it does not reflect change.
The entire directory is confusing to me, I believe it was done so that all files, configs, tomcat files, etc. would be under one git folder so that it can just be dropped anywhere. I find a lot of sources state that a .war file would be created and you would place that file in the tomcat apps directory.
Here is the basic layout of the directory of the app
-www/live/njun
-build.xml
+lib
+scripts
+sql
+src
-tomcat(has some config files, scripts, webapps folder)
-web
-content
-index.jsp
-trampoline
-includes folders with .java files
-tickets
-ticketsMgr.java (this is the file I modified but I could not see any differences in app)
-index.jsp (this is one I modified and did reflect in browser)
-WEB-INF
-classes/com/njun
-lots of folder that have .Class files(although when I open them it's all gibberish characters)
This is the basic structure of what I am looking at.
I tried going to the /opt/tomcat/bin and > sh startup.sh - to restart tomcat. That didn't work.
I also ran the > sh startup.sh version inside of the tomcat folder above,
/tomcat/bin/sh startup.sh - that shows me some info where the home, base tmpdir, jre_home, etc. But that didn't work neither.
I am not being asked to make major modifications on this app, I figure I can manage the SQL errors myself. If we get to the point where we need enhancements done to this app, we would hire a Java developer.
Please let me know if I am missing something and I can provide.
Thanks in advance,
That's because a .java file is just source code. You need to compile it and upload the corresponding .class file generated when you compile the .java sources. How to compile and run a Java program. Or well, since it runs on a Tomcat instance, you might have a JAR or WAR file. But the idea is still the same, since those are just basically zip files that hold your .class files (among other stuff that's less relevant for your issue).
I have a project that runs inside the WebLogic server. 80 % of changes I do to the code affect JSP files only (not the class files). Those JSP files contain the frontend logic.
Whenever I change the JSP page, I need to do the following steps to see my changes:
mvn install inside the source directory.
Redeploy the application in WebLogic Admin Console ("Deployments", "Update").
Is it possible to avoid these two steps, if the only thing I change are JSP files (I don't touch Java files therefore, no class files are modified)?
Note that the application in question is set up in WebLogic so that it reads the directory with the class files (myProject/target), not a WAR file.
I have no definite information whether or not JRebel supports WebLogic. Its only alternative known to me, DCEVM, does not support WebLogic according to the last statement here.
Update 1 (02.05.2018 15:23 MSK): Changing
<wls:resource-reload-check-secs>-1</wls:resource-reload-check-secs>
to
<wls:resource-reload-check-secs>1</wls:resource-reload-check-secs>
in myProject/src/main/webapp/WEB-INF/weblogic.xml didn't help. When I deploy the application, then make a change to a JSP file, then run mvn install, the changes do not take effect.
There is page-check-seconds properties in weblogic.xml (beside others). Take a look at "weblogic.xml"
If you run in dev mode and not prod wls will redeploy each time a jsp changes at source
No, for several reasons. JSPs have to be compiled. They are not simple html pages. They are also cached by the server. You most definitely have to redeploy the project.
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 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.
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.