I've recently found out how to remotely debug my java files on a Tomcat server via eclipse and was wondering something. I am wondering if I could import the same files into Eclipse that are currently housed in the webapps folder on my tomcat server, and instead of having to go to that filepath anytime I need to make a code change with the files in the tomcat server, be able to make them directly in Eclipse which I would be using to debug anyway.
Currently I've tried importing the same project folder from the webapps folder in Tomcat into Eclipse and made a small code change, relaunched my server, but am not seeing the change in my tomcat library.
When importing into Eclipse does it make it's own separate instance of the files, instead of actually being able to import the same exact files as in the tomcat server?
If you double-click the Tomcat server in the 'Servers' view inside Eclipse, you will see a configuration tab "Server Locations".
By default, eclipse doesn't make changes to the tomcat 'webapps' folder, it uses folders under its workspace.
Changing that option to 'Use tomcat installation' will make the changes be visible from the tomcat/webapps folder on your file system.
Related
I am unable to find another article that solves my problem but am happy to hear about one if you know the answer.
I have a RESTful service built in Java with Eclipse. It uses Spring and all of its bells and whistles.
After much work with configuration files, I am able to build the service into a war file, deploy it to my Tomcat webapps folder, and run it from standalone Tomcat. However, it still throws several errors on start when I try to start it from a service defined within Eclipse. The errors are the same errors that I was seeing before I got the config files correct for standalone Tomcat. The errors are about the inability to create the required beans because of references to properties that can't be found.
How did I get it running in Tomcat? I added a couple of .properties files to define properties needed by the beans that get launched at startup and then added a 'set CLASSPATH=...' line to the setenv.bat file in the Tomcat bin folder. This new line adds the properties files into the CLASSPATH. That seems to have fixed everything from standalone Tomcat.
So, my question is, "How do I make these same changes inside my Eclipse server?" I have added the properties folder with the property files under the config folder in Eclipse, just like it is in my native Tomcat folders, but I do not know how to modify the CLASSPATH string to specifically point to my .properties files (as I have done in the setenv.bat file for standalone Tomcat).
I think I understand the problem, but have no idea about the solution.
Thanks for listening.
Dave
Eclipse does not use any *.sh/*.bat files to startup Tomcat. In order to modify the way the server is started you have to open the configuration UI of the server by double-clicking on the server in the Servers view.
From there you will be able to modify the classpath of the system classloader through "Open launch configuration".
Another important setting is "Server path" which tells Eclipse, the value of $CATALINA_BASE. You can modify it only after removing all modules and cleaning the server. It is useful to set it to an easily accessible directory: this way you can verify directly that Eclipse didn't mess up your application deployment (sometimes it "forgets" to copy some libraries).
The "Configuration path" setting tells Eclipse where to find the files (but not subdirectories) that will be copied into $CATALINA_BASE/conf.
Remark: if your application requires you to add libraries to the top classloader, there is probably a problem in your project. The "missing" libraries should be added to WEB-INF/lib of your application instead: look into the "Deployment assembly" of your Eclipse project configuration.
I added my local tomcat 8.0.14 with eclipse successfully. My local tomcat is located at /Users/masum/tool/tomcat-8.0.14. I can see it form eclipse runtime Environment as well. Whenever I deploy any webapp to eclipse's tomcat. It doesn't appear in local tomcat-8.0.14/webapps directory. I expected it should go there. But it doesn't.
Also is I do any changes in tomcat/conf/server.xml. These changes doesn't effect in eclipse integrated tomcat. Also if local tomcat is running, port number conflicts with eclipse's tomcat. I have to stop local tomcat to work with eclipse tomcat. Looks like two different instance of tomcat.
My question is where does eclipse tomcat physically located? If I deploy any web app in eclipse tomcat where it actually goes? How can I configure Tomcat so that I can control it both from eclipse and also manually?
Thanks in advance.
Double click your tomcat server in the servers tab. In the servers tab you will see "Server path" under server locations. This is the location of eclipse's tomcat working directory. If you stop tomcat and undeploy all web apps, start and stop again, you will be able to select other options. Click "Use custom location" to set the location to a place of your choosing. In project Explorer you should see a tomcat folder. Under that folder you will find server.xml and the other config files, which you can modify as needed.
I have a website someone's developing for me on a VPS (Java, javascript, CSS, HTML) that I would like to run on my Macbook Pro.
He commits the source on Github, which I download with Sourcetree.
I have Tomcat 6 and MySQL running on the Macbook fine.
Can I bring the root folder, the mySQL db and an associated media folder over without creating a .war file to run it on tomcat on localhost by simply setting up the connections properly in datanucleus, or is it much more complicated than that?
Thanks in advance for your thoughts.
I know people who try to develop application directly in die Webapp Folder from Tomcat but that is not the right way.
At your place i'll do this:
clone the application locale on your mac
Use an IDE(eclipse/Netbeans/IntelliJ) to open the project
Build a local war file which you can deploy directly to your $CATALINA_HOME/webapp/
Do not forget the make all required mySQL settings (context.xml) and so on...
Yes, you can. But it is necessary to have compiled webapp.
Simply put root folder contents (your deployed application) to "/webapps/ROOT" and start tomcat by running script in "bin" folder.
Make sure that you properly configured database properties of your application.
If you have only sources - it is not such simple. You have to build war and deploy it. Or ask developer to include "target" directory in git repository and then copy "classes" folder to /webapps/ROOT/"
I'm running eclipse Juno, with Tomcat 7.0.29. I have some files that are saved to the root of the webapp by my webapp and I want to delete them. I'm trying to find the localhost folder in order to be able to do this. Everything I'm reading tells me it should be at /var/www, however there is not /www directory in var. Where could it be?
Since you're using Eclipse IDE and you don't know where your Tomcat installation folder is, you can find it using the IDE by going to Windows/Preferences. It will pop a Preferences window, select the Server/Runtime Environment option in the left tree, in the right side must appear Apache Tomcat v7.x. Select it from the list and select the Edit... option, it will show you the tomcat installation directory. Let's call this folder <tomcat>
Now you know the folder installation, but maybe Eclipse is not using it to deploy the Java Web applications. To make sure of this, in your Eclipse, go to the Servers view (if it's not visible in the IDE, go to Window/Show view/Servers), it will show you your tomcat server (and others), double click on it. In the Tomcat overview window, check the Server locations panel, expand it and check where the webapp is deployed:
If selected option is Use Tomcat installation then the web app must be in <tomcat>webapps
If selected option is Use workspace metadata then the web app must be in your workspace inside .metadata/.plugins/org.eclipse.wst.server.core/tmp[number]/wtpwebapps (thanks to Lars Vogel blog post). This is a special folder created by Eclipse.
Default tomcat folder is at /var/lib/tomcat7. Your webapps are under /var/lib/tomcat7/webapps
Not sure what localhost folder you are referring to. There is /etc/tomcat7/Catalina/localhost but I dont see a reason why you should be touching it.
This assumes you used standard Ubuntu tools to install tomcat.
I've got a Java Web Project which I'm deploying to a Tomcat embedded in Eclipse's Servers Plugin, alas, when I navigate to the location of that webapp after publishing/starting the server, the .class files are all missing. I can navigate as far as ProjectName\WEB-INF\classes\path\to\packages\ -> All packages are empty.
Any Idea how to solve this problem?
Edit
Build Automatically is checked and it compiles just fine for another web project I've just included, just not for the one specified
Edit 2
Reinstalled Eclipse (because why not) - nothing's changed, works for Project #2, doesn't work for Project #1. Not even the path to the packages is existant now. The content of the src folder (that's supposed to be moved to WEB-INF/classes) isn't there at all - but the resources (I've got a resources folder with the same deployment assembly command) are.
A few steps to perform to restore sanity...
Refresh your project. It is possible that something was modified on the file system external to Eclipse.
Kick of Project -> Clean.
Now look at your project (not the deployed location) on the file system. Do you see the expected files in the /bin directory (or whatever you may have changed class output directory to)?
Let's now try exporting a war using the wizard. File -> Export -> Web -> WAR or something like that. Check the WAR contents. Are you .class files there?
If everything is good so far, there is nothing wrong with your project. The Tomcat server adapter just got confused.
In the Servers view... Make sure Tomcat is running. Next right click on Tomcat and select add/remove projects. Remove your project. Confirm that your web app is no longer accessible.
Now re-add your project via add/remove projects or invoke one of the run as actions.
The above should reset Tomcat server adapter and hopefully things should work as expected.
Check if you had deleted or moved your external JARs associated with the project on your IDE. I had moved it and ran into the same issue.