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.
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 am using Tomcat 6.x and Eclipse J2EE Kepler. For reasons mentioned in my other question, I sometimes need to delete the Tomcat from the Servers list and re-add it.
The weird thing is: after I re-add the server, two configuration files server.xml and context.xml revert to a previous state! let's call it S. I cannot really tell what S is - it definitely is a state I once had, but it lacks some newer changes. For this reason my webapp does not work and I have to revert these two files in the workspace/Servers folder.
I'd love to fix this by updating S. However, I am unable to find the source of S, where Eclipse takes it from - I tried fulltext-searching my computer for files that look like the server.xml and context.xml, but to no avail. Specifically, I updated these two files in the conf/ folder of my Tomcat installation, but it did not help.
Where could Eclipse be keeping S? In some weird DB in the workspace metadata? Could it be using the local history?...
Thanks for any insights!
If you are working on Eclipse then there should be a folder called Servers in your workspace. When you start your server for the first time, it copies over the tomcat conf files into this eclipse project. So no matter if you change your actual context.xml from outside, eclipse will override it with what is stored in the 'Servers' folder.
If you still need the eclipse to take control of your tomcat installation directory, you need to primarily update this file from within the eclipse.
I'm running a webapp through Spring MVC whose backend is written in Java. I am working in Eclipse. I'm trying to make changes to the java code (which I did not write, but am tasked with editing).
However, none of the changes I make do anything. I tried manually compiling the project in Eclipse (Project -> Build Project) but nothing happened. I even tried taking out one of the .class files to see if it would be recompiled and it was not. The directory which should have contained that file remained empty.
I've already checked and the source and deployment paths match the places in which the .java and .class files I'm working with are located. What the heck is Eclipse doing and how can I make it compile my files?!?
Take a look at
How does Eclipse deploy Web Application using Tomcat
Did you remove the deployed app under:
{Workspace_location}/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps
I've got a Vaadin project that uses JIRA's SOAP API. It runs fine in Eclipse, but attempting to make it work in IntelliJ and with Maven is slowly driving me mad, though I feel I'm close to completion.
Whenever I deploy my application to a local Tomcat server, all I get is a stack trace caused by this:
java.lang.NoClassDefFoundError
be.azvub.jira.service.JiraSoapServiceServiceLocator.getJirasoapserviceV2(JiraSoapServiceServiceLocator.java:53)
This class exists, because nothing has changed since I moved them from eclipse and because I can open the .java file and see that there are no errors in there. I can remove the luine of code that makes the call to this class and all is well, so it's a localised problem. The problem class is in a different package from my Application class (which still works), where the call to it is made.
What's causing this problem and how can I fix it?
I had the same problem and fixed it now after debugging ...
IntelliJ usually auto-creates a folder /lib under your /src folder inside your project, and then it would tell your project that all LIBs are in there, on that basis; we usually assume that it's the place to put all your LIBs in there as well.
Although with that setup your project would compile fine since IntelliJ can link up to your JARs However, with that sort of setup Tomcat will fail to execute, since Tomcat expects to find the classes under /WEB-INF/lib,...
Therefore, the solution is to:
1) Drag your LIB folder (sorry I mean "/lib") from /src/lib to be
under /web/WEB-INF directory
2) You would get a warning about moving classes / JARs, say YES.
(You need to tell your project to re-map your existing pre-defined
LIBs to the new folder):
3) From the main menu, select FILE -> Project Structure
4) Select
Libraries from the left menu
5) If you don't see any existing libs, then you're done, click OK
6) If you do see libs in there, then:
7) Click on each LIB from the
middle-list, and then remove the ones that can't be located,
8) Re-add them again from the new location
9) Repeat (7) to all other LIBs.
10) OK,
RE-compile, your project should deploy on Tomcat now and work fine.
Regards
Heider
I don't know how I did it, but by fixing an unrelated problem, this got fixed along with it.
I changed the Web Resource Directory under File | Project Structure | Facets (So the app could find Vaadin's theme folder under the WebContent directory instead of the default src/main/webapp it was set to) Neither of the folders actually contain the class that was giving me problems.
I also forced Maven to reimport everything, as I have done several times before, but now I used the option to do so under the project's context menu in the Project Explorer instead of the Maven Projects tab, so maybe that made a difference? Maven is still largely voodoo to me, but at least everything seems to be working normally now.
But thank you for your assistance anyway.
My guess would be the build path, check to see if the class you are calling is present in the build path of the project.
I noticed that "sometimes" the resources i put into a source folder in my Eclipse project will not be copied to the output folder ("bin") immediately.
E.g. i change a properties file using the eclipse editor and save... and "bin" still has the old version.
Does anyone know what exactly triggers the copying (and how i can trigger that from a plugin)?
I thought it happened automatically when a resource changes.
-- EDIT --
To clarify what i meant by triggering it from a plugin: I have a plugin that depends on up to date resources in the output folder, but apparently the resources are outdated when my plugin is called. And that's why i need to better understand what happens and how i can force it when i need to.
If you don't add the resource through eclipse (but for instance through the windows explorer), eclipse wont notice some changes until you refresh your project/folder. (right click in the packater explorer for instance).
After it notices the change it will copy it to the output folder when you build (often this is done automatically upon changes)
This is a Bug in almost all Eclipse versions, it happens without any reason. My eclipse 3.5.2 and 3.6.2 both meet this problem in someday. In my case, I need to copy modified .clj clojure source files to classes directory for immediate effection in a web app, now I have to set /src before /classes in CLASSPATH of web appserver startup script, It's solve my problem temporarily.
As #Thirler said, if you don't add the resource through Eclipse, it may not notice the files until you refresh your project. However, if the Refresh/Clean doesn't work (in my case, it didn't), you have to add the files to the folder structure IN ECLIPSE.
Just drag the file from the folder where it is in the file system using Finder/Windows Explorer, drop it into the same folder in Eclipse's Project Explorer (Eclipse will ask for overwriting, just say yes) and Voila!
EDIT:
An easier way is to just navigate into the folder using Project Explorer and then Refresh (F5).
As far as I know it happens when you build the project. You don't need a plug-in, you just need to tell eclipse to do a build of the project.
There is an Eclipse setting Java > Compiler > Building > Output folder > Filtered resources.
For unknown reasons, this was set to *.launch,*.testsuite,*.deploy,*.location,*.execution,*.datapool,*.artifact,*.html,*.svg in my workspace (while the default seems to be just *.launch). This was the reason, why my Eclipse constantly refused to copy a classpath resource index.html.
Late response, but I just stumbled over this question but non of the answers helped me to convince Eclipse to do its job.
This happened to me when I imported an Eclipse project as a whole, including both src and bin directories. The fix is to Clean the project: Project -> Clean... -> select your project and press Clean. This should re-build the project and properly locate the resources needed.