I have a development project on ear project using jsf and primafaces. I'm using intellij 15.6 and web logic 12.1.1.0.
After I completed all the configuration on server and idea, I start server from idea, it makes and deploys the application but deploy fails.
After I do maven wls plugin undeploy, redeploy will is successfull. But when I change some xhtml files, I cannot see the changes in browser. Configuration server, update resources both them. I want to see the changes in xhtml after refresh browser or window.
Short answer is that you can't. When Weblogic loads your application it does so by staging your changes (in one way or another). Those staged files cannot be modified after loading. The best you can hope for is to leverage autodeploy, and after you build your application having a scripted deploy to the autodeploy directory. There is a possibility that if you had your project set up at the staging directory (and were not making any actual code changes) that you could tweak some files, as long as things are set up to not cache resources.
Here are the details you were looking for (note that you still need to re-compile):
Using FastSwap to speed up dev
Using FastSwap Deployment to Minimize Redeployment
Working with AutoDeploy
Related
We are working on Liferay platform, which uses Tomcat servlet. We have deployed modules, which consist another our compiled jars. Now, we wrote simple program, that monitor our resources and replace them in webapps folder if changes detected. This works fine, but when we are trying to replace sources in compiled jars (js, html etc), then Tomcat detect changes and start redeploy.
Is there any way to replace resources in compiled jars without affecting Tomcat redeploy automatically? Our Tomcat redeploys take a lot of time, and we want to redeploy resources only on demand.
You can disable autodeployment setting Host autoDeploy attribute to false. Then you can use startup scripts, tomcat manager or REST api to redeploy.
<Host autoDeploy="false"
See https://tomcat.apache.org/tomcat-7.0-doc/deployer-howto.html#Deploying_on_a_running_Tomcat_server
You can consider also to deploy on demand using the tomcat API and providing a war. There is an Ant task available. See this example
I'm working on a java/javascript webapp that runs on tomcat.
We're working with IDEA and I've managed to get debugging set up for both the client and server code at the same time, which is great. I did have hot redeployment of the javascript set up when running Tomcat manually, however I find when running Tomcat through IDEA this doesnt work as it's setting stuff up somewhere in my users folder.
I was going to just set up a deployment configuration to go to that folder but I can't see any of the javascript files in there.
Is it possible to get the best of both worlds and have debugging and automatic deployment working together?
Update
Here's my config:
I'm using maven to build a specific profile rather than using 'build war exploded'. I suspect the latter wont work to build as quite a lot of custom properties need supplying by maven at compile time.
I also now have war exploded set in start up in deployment.
In Run - >Edit Configurations -> select tomcat instance.
then on update action : restart option
and in deployment tab instead of war use war exploded.
Now click on green button for run project it will ask option then select update resources and ok then refresh your page it will show change.
Keep one thing in mind that clear the cache.
Here is a screenshot :
It turns out I was having problems because I had antiResourceLocking=true in my tomcat context.xml config file.
I had switched this on as I was having problems with things hanging onto the war files and stopping recompilation.
changing to use antiJARLocking="true" instead seems to have solved both problems. Redeployment is now working in idea and I'm not experiencing problems with things holding files open
I'm trying to run a multi-module Maven web app in Eclipse (EE Helios SR 1). In NetBeans one have just to click the run button. But here it's probably a little more complicated.
I've added Tomcat 7.0.26 as a server for the war module of the project. When I try running the app, in the Servers part of the window I see Apache Tomcat v.7.0.26 at localhost [Started, Synchronized], but browser doesn't react. Does the system browser need to show the page when the app is running?
I tried to move to localhost:8080 and localhost:8080/welcome.html (the second one should be processed by the app) when the server was started, but I got 404 error both times. I also didn't see the new folder in the apache-tomcat-7.0.26/webapps/. Should Eclipse place the project there when running the application? I'd be really grateful if someone tells me what I'm missing here.
If not specified, tomcat integration with eclipse deploy by default war to a specific folder in .metadata, in my case somethings like: ~/workspace/<my_project_workspace_name>/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/
Every war are then unzipped to a folder. If your maven pom.xml you'll find a
<build>
<finalName>myapp</finalName>
</build>
Then it'll deployed to tomcat as :
localhost:8080/myapp/welcome.html
I have had a lot of bad experience with running web servers in Eclipse. Most of the time, this was related to unreliable class/resource reloading.
My solution was to add Jetty to my app in a new module (see Embedding Jetty). This basically turns my web app into a Java application, avoiding most of the problems. It also allows me to specify a filter (written in Java) when the app should reload.
This solves all the problems with class reloading (classes and resources are never copied anywhere; they are loaded from Eclipse's bin folders), startup is much faster (we got the startup time from several minutes down to 15s) and reliable.
Maven Projects are different from the ones with Web Application Facets, You cannot directly run a Maven App as a web app because the folder structure is different. In order to run your application directly from eclipse, try to add Web Application nature to your maven project [A complex modification involving modification of .project and .classpath files along with addition of few other files]. I would recommend modifying your pom.xml file accordingly
I use Eclipse Indigo (EE) to build applications in Java framework Vaadin,
using Tomcat 7.0 server. After changes in code I wont see result in a browser,
so I need to click option "Clean Tomcat Work Directory.." and wait until
Tomcat stop and start a server.
Otherwise, when I refresh app page, I don't see any changes.
Even when I restart server (and when eclipse automatically restart it when I save changes), without cleaning tomcat directory.
Option "Automatically publish when resources change" is enabled.
Is any faster way to do that? or can I automate that process?
Additionally to the answer of Kowser, it is possible do hot code changes when running tomcat in debug mode.
Otherwise you could investigate in JRebel
In your "Modules" tab of your Tomcat, you hace to clic on 'Edit' and uncheck the 'Auto reloading enables' option.
With that, several changes won't need a restart (as long as you start your server in debug mode).
If you setup your project to use ant for building and deploying, you can simply add Ant builder to your project Builders to run your ant build and deploy targets every time after you have saved a file. Then provided that tomcat is configured to support auto-deploy, this should achieve what you want, with two caveats:
If your project takes more than a few seconds to build, building after every save is not practical.
You may run out of memory for the tomcat instance if the same app is deployed to it repeatedly for a number of times. This can happen if tomcat is somehow unable to recover all the memory from undeployed resources.
It might be possible. But your setup is a bit different from what I use. I am just using tomcat+eclipse to do Servlet development using Velocity and Torque.
The following works for me where changes are visible in the browser as soon as I save in eclipse.
I assume that you have a project directory such as
apache-tomcat-7.0.11/webapps/$YOU_PROJECT/WEB-INF/classes/
Create a symbolic link with ln -s from your eclipse project directory and to the classes directory in WEB-INF.
Then configure eclipse to write all .class files to this directory. (Done by right clicking on the project in Eclipse and choosing Properties and then Java build path.
In your $tomcat/conf/context.xml config file first tag should be:
<Context allowLinking="true" reloadable="true">
Also add the following as a child to if it is not already there.
<WatchedResource>WEB-INF/web.xml</WatchedResource>
That is what I have done, but I am not sure it works with your EE tools.
ps: This solution assumes that you are using linux/unix. I don't know if it works with windows. The major problem is that eclipse can't write class files outside the project directory (Which is why that symlink is required).
btw: Tomcat may(Depending on class loader, used .jar files and other complicated details) leak a lot of memory when automatic reload is enabled so you may want to increase the allowed memory(Mostly permgen) to prevent out of memmory exceptions from tomcat.
I know this has been asked and answered very long ago. But use this info if it is helpful to anyone of you. I use Eclipse Kepler and configured Tomcat 7 server inside eclipse. I don't have to do any other configuration but to just uncheck Update context paths check box. That is all. Leave other setting as default.
In this way, changes to the resources files (xhtml pages, css files etc.) as well as the java source code files show up in the browser. Only for class files the web application would be redeployed (no server restart auto as well as manual required).
Location of Update context paths: Double click on the tomcat server under Server tab. Under Publishing tab you would find this Update context paths check box.
Absolutely no other change needs to be done for the auto publishing. This works both in normal and debug mode of tomcat.
Screen shot from my eclipse below:
No, there is no other way.
You will notice immediate changes only while updating a JSP/HTML/etc.... Classes will not be loaded/refreshed automatically. It will be contradictory to change a loaded/instantiated class when server is live, isn't it? At least it should not be possible.
It's better to perform Unit Test while developing something. It can help you to reduce the amount of annoying server restarts.
Currently, I have tomcat installed on the production server to serve my java webapps. I develop in eclipse at my personal workstation and then I use an ant script to build the project into a war file and deploy that on the server.
This setup works well when I am on the same network as the server because deploying is almost instantaneous. However, now that I am working remotely uploading the war file to the server is slow and in most cases very redundant (there are about .5 GB of static media included in the war file).
Is there a better way to update my webapp on tomcat from eclipse and if so what are the best options for implementing such a solution with minimal effort?
Checkout rsync. It transmits just the updates to the file, so it will greatly speed up your process. Also depending on how complex your application is you might look into installing jetty on your personal workstation. It works well with eclipse and lets you check the new code almost instantaneously.
What it sounds like you want is to have the exploded war file(your root app/result of ant compile) sit in your tomcat web-apps folder. Tomcat will deploy it based on the host or context tag in server.xml.
This way, you can just drop your $app/WEB-INF/classes into the application and, if context reload is enabled, the new files will be deployed immediately.