Java Web Project not building correctly
Asked Answered
S

2

13

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.

Steffen answered 11/7, 2012 at 11:52 Comment(9)
Yes, figure out how to tell Eclipse to write the compiled .class files to your WEB-INF/classes directory.Zoospore
This has worked before, this issue has just arisen today without any input on my part (I believe). The deployment assembly in Eclipse is set accordingly.Buiron
Apparently not. If it was, you'd have .class files.Zoospore
If only that were the case - I've got a Deployment Assembly mapping from "src" to "WEB-INF/classes", which was also there as default (and worked less than 24 hours ago for some reason that's completely eluding me).Buiron
Something changed in the last 24 hours. You'd make progress faster if you'd stop insisting that everything is fine and accept the fact that you don't have a valid WAR file.Zoospore
I'd be the first to admit that I've done something terribly wrong if only it made me progress, alas I don't see what - it appears as though Eclipse isn't compiling my java files at all. Just a few minutes ago I pondered why my WebService isn't updating after editing the Implementation file - I was only able to access the "Old" version from yesterday. Then I cleaned my project and now no class files are available whatsoever (so Cleaning deleted the old class files without compiling anew) - now if only I could get assistance as to where to look, I can assure you my Deployment Assembly is fine.Buiron
I use IntelliJ, so I can't help you much with Eclipse. It seems that Eclipse doesn't know to re-make the project before creating the deployment assembly. Perhaps that's a hint - there's a checkbox that needs to be ticked off or something.Zoospore
@Zoospore : if you don't know Eclipse why are you even commenting here?Duggan
Knew Eclipse before I started using IntelliJ; the details escape me. Do you have an answer you'd like to share, Konstantin?Zoospore
D
20

A few steps to perform to restore sanity...

  1. Refresh your project. It is possible that something was modified on the file system external to Eclipse.

  2. Kick of Project -> Clean.

  3. 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)?

  4. 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?

  5. If everything is good so far, there is nothing wrong with your project. The Tomcat server adapter just got confused.

  6. 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.

  7. 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.

Duggan answered 11/7, 2012 at 12:28 Comment(4)
Thanks for your answer! In Step 4, when I export to WAR, I don't see the classes either (path to packages is existant, .class files aren't). I performed the other steps accordingly.Buiron
That indicates that something is broken in your project. Do you see anything in the Problems View? What about Error Log view?Duggan
Indeed! The Problems-View has shown that a required libary is missing. Unfortunately it didn't occur to me to check this view as I work with Visual Studio which is a bit more "in-your-face" about errors. (I started programming in Java a few days ago) Thanks for the pointer!Buiron
After building your project check /build folder (Not the deployed location), if it contains your compiled .class files or not? You can check that using Navigator view.Christophany
D
0

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.

Dieldrin answered 24/9, 2020 at 15:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.