I use tomcat with eclipse in 'Use tomcat installation' mode. My problem is, that eclipse overwrites tomcats server.xml every time, and deletes my crossContext="true" elements.
Should I use custom location? Or the eclipse setup is wrong?
Thanks!
You can edit the equivalent configuration files inside your "Server" project/folder in the eclipse workspace. Those are the configuration files with which eclipse is overwriting the ones found under your Tomcat installation.
I have experienced a lot of pain getting Eclipse to interact nicely with Tomcat. I recently switched over to Jetty and I will never go back! It's especially easy to use if you use Maven as your build manager. If you use Jetty for development, you can still use Tomcat for deployment.
If you want to preserve Tomcat artifacts then you can choose "Use Workspace Metadata" option. This option will copy all configuration files to "{workspace}/.metadata/.plugins/org.eclipse.wst.server.core" directory but still use the installed Tomcat Binaries for starting and stopping server. This is a neat way to have multiple server configs using a single tomcat.
Related
I'm trying to learn Tomcat but the problem for me is the that the Tomcat server has to be restarted each time I make changes to the code.
Is there any way to make Tomcat pick up changes to the code without having to restart the server?
Maybe an IDE (Like Eclipse or NetBeans) can be somehow used to develop for Tomcat and test all the changes right there in the IDE?
Well if your putting your latest compiled files(classes/resources) under WEB-INF/Classes or lib folder you dont have to restart the server. You can can configure IDE's like Eclipse to configure this way where they can put latest compiled files under right target folder. Rcent Eclipse version comes up plugin where you can configure it to use existing tomcat server. You can also explore Mongrel Plugin which also serves the same purpose .
Please have a look at "DCEVM". It's a Java runtime environment alternative that works just like a normal JRE but is able to reload class changes in almost all situations. Very cool, and it's free.
http://dcevm.github.io/
Installation is very straightforward, see explanation on the site.
i have tomcat project the directory structure is
previously i was using tomcat server, whenever i modified .java files i used to build the project and restarted the server in eclipse through plugin than the changes would have taken effect.
Now in my company they changed from tomcat to weblogic since i am new to it, i used to build war file every time and deploy manually to check the changes.
Can any one tell me how to do hot deployment in web logic. i googled it but it says i need to change project type to dynamic project, that i cant do since it already in development.
is their better way just make changes to java file build and no need to restart the server through eclipse in weblogic 12c.
Eclipse IDE luna
weblogic 12c server
project type : tomcat project structure
I think how you doing that is a little old fashioned. With eclipse luna, tomcat 5.0 - tomcat 8.0 is well supported. And take some effort to turn your project into a 'Dynamic Web Project', in that way you will benifit a lot from the experience of other people.
For hot redeploying, you can try JRebel, it reload your changed java class without reloading the whole applcaition.But it's a commercial software, and I don't know a good and free alternative yet.
I have got a war file generated using Maven and it works perfectly fine when i manually deploy it on the tomcat server.
However, the war file was generated using Maven on eclipse and when i try deploying this on the server using eclipse, it just doesn't act. The tomcat server starts perfectly fine. What I do is : Right click on the Tomcat Server 7.0, then Add/Remove Project and add it to the server.
The problem is when I deploy and publish it on the server and nothing happens after that.
On trying to access it, it says - The required resource is not found
Eclipse doesn't deploy the WAR. Instead, it knows how Tomcat works and deploys the exploded WAR.
The next step is to look into the webapps/ folder of Tomcat to make sure Eclipse really has deployed something.
If that looks ok, you need to look into the Tomcat log to see why it doesn't like the deployed web app.
Most of the time, there is old code which is somehow stuck in Tomcat, so Tomcat can't undeploy the old version. If that's the case, stop Tomcat, delete the app manually and try again.
There were certain jars required in specific versions for the application to work. I was usin the maven supported versions. I have got it to work adding them directly in Tomcat's lib folder for time being and the application now works. (Anyways i need to look to get them configured now on the maven)
Also, i guess installing the plugin for m2e - eclipse.org/m2e-wtp helped as well. Thanks #Aaron Digulla for the inputs.
I have developed a java webservice application that I have been running on my dev-computer and in the meanwhile been setting up a dedicated ubuntu based linux server.
I have installed oracle-jre, mysql and apache tomcat 7 on this linux server and
after reading documentation I understand that I can either copy the deployed project archive (.WAR) or I can simply copy the project folder, into the servers /webapps/ folder from my development computer. Then restart tomcat7 and it should automatically run the webapp.
On my dev-computer with Eclipse IDE the webservice works properly as expected, but I cannot access the POST URL methods at all on the server
e.g. localhost:8080/Webservice/rest/account/login
(The installation on the server seems to be O.K as the Apache examples all work properly.)
I cannot see any logs in the /logs/ directory, in fact the folder is completely empty, so I cannot debug whats actually happening. Why aren't logs writing to the Catalina.out file?
Am I deploying this correctly as explained above?
Do I need to configure Eclipse or any project settings to reflect the change from the eclipse IDE / dev-computer to the server? E.g Is there any real difference?
A lot of questions there, but I wanted to clarify as much as possible,
Cheers,
Oliver
I fixed this issue by reinstalling tomcat.
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.