Why does restarting a computer wreak havoc on Java Build Path? - eclipse

I'm sure we've all been there, I've got a JSF (Java) project on Eclipse that built fine yesterday, I call it quits for the night, turn off my computer and come back to it the next day only to find missing JAR errors, some of which are due to actual missing classes, others I can clearly find by navigating my build path. What's up with that? Is windows scheming against me and re-indexing files or something while I'm away?

So this might be IDE dependent on Eclipse Java EE Juno but on restart it created a copy of my src folder as a library which caused some Hibernate - duplicate mapping errors

Related

in my eclipse its showing red cross error on each project.how to fix it?

I removed tomcat server after going into windows-->preferences-->server-->run time environmentsenter image description here. after this its showing red cross on each project .and not running any project even after adding the server. but newly created projects are running without any error. how to fix this red cross error from every project
As mentioned by #howlger, you should clean up your project's Java Build Path so that you only build against one Java runtime.
Ok, so after removing that Tomcat Server Runtime, you were probably prompted to remove it from any projects that were referring to it. If so, this is how to get things working again.
When working with Java, you need a Java Runtime from which to get the classes to compile your own code against. When working with servlets and JSP files, you need to get the Servlet API from somewhere so you can compile against them, and WTP (which you're using) has you get them from an actual server--like Tomcat (ideally the same version of the server you're going to deploy to, so you have the same libraries and classes at development time that you have at runtime). By removing it from your preferences and project(s), they no longer have jar files with those classes to compile your own sources against, so the Java tools don't know what those types are.
That means that fixing the problem requires getting a server runtime back on the Java Build Path. Screenshots are valid for Eclipse IDE 2021-12 (WTP 3.24).
Make sure you have a valid runtime on the Server / Runtime Environments preference page. In this picture, I've let it download both Apache Tomcat 9 and 10 for me. Really, you must have something here to proceed.
Open the Java Build Path property page of your project and select the Classpath node. Unless you select that node, the buttons to Add a Library won't enable.
Select the Server Runtime type of Library from the list. Continue through the later pages in the dialog until you've selected the runtime you intended. Once finished, your Servlets will be recompiled the next time a build happens.
I found the solution for this. To solve this issue just right click on project name and go to properties and then click on project facets. After that, click on runtimes and tick on Apache tomcat and and JRE and then apply. Done.

Another GWT module may need to be recompiled

I'll start with the other threads I've read:
GWT module may need to be (re)compiled REDUX
Some subtlety of GWT compilation - "gwt module may need to be (re)compiled."
Google App Engine - recompile GWT module
GWT Maven : Module 'xxx' may need to be (re)compiled
I have taken the following steps to fix this:
Cleared my browser cache.
Deleted gwt-unitCache folder.
Deleted *.nocache.js.
Deleted every file that was left over from a previous build. (I did this by looking at the date and time it was created.)
Run both maven clean and gwt:clean on my project.
Compile by right clicking on the project and going to Google > GWT Compile.
Run maven package.
Put the war in my JBoss EAP 6.1 (JBoss AS 7) folder.
Connect to it and still get the "GWT module may need to be recompiled" error.
What else could be causing this error to come up?
This has happened to me in the past when I imported a GWT project to a different computer. Seems you have already done some things I have tried. Before you start, right click on your project, hit Refresh, so you don't miss anything that's not in sync with the file system. There are multiple things it may be, so here's all the things I did to get it working:
Before the following steps also helps if you use the same version of GWT that was originally used to create your project. Also, make sure gwt-servlet.jar, gwt-servlet-deps.jar, validation-api-1.0.0.GA.jar, and validation-api-1.0.0.GA-sources.jar in your libs directory are the same as the ones from your GWT SDK directory (only if your app uses them).
Delete gwt-UnitCache
Open up the war directory.
Delete ALL compiled module folders.
Delete the war/WEB-INF/deploy folder.
Delete the war/WEB-INF/classes folder. It may be hidden in Eclipse, so you may have to do it via your file system.
Now, on the menus: click Project > Clean...
Make sure a build happens too. Either make "Build automatically" is selected, or use the option in the "Clean" dialog.
Do a GWT Compile. If you have more than one module, ONLY compile the main module. Any inherited modules will also be compiled.
I hope this helps. Ask if you need any clarifications.

Where to put the User Library for Eclipse-Dali-Hibernate integration?

I am struggling with the configuration of the Eclipse Dali plugin and Hibernate. The version I'm using is as recommended:
Eclipse 3.6.1 (Helios SR1) IDE for Java EE Developers (including Dali 2.3)
JBoss Tools 3.2 (for the Hibernate Tools plugin)
When configuring the Java Persistence properties for my project, I created a user library named "Hibernate JPA" and included the following JARs:
hibernate-distribution-3.6.1.Final\hibernate3.jar
hibernate-distribution-3.6.1.Final\lib\jpa\hibernate-jpa-2.0-api-1.0.0.Final.jar
hibernate-distribution-3.6.1.Final\lib\required\dom4j-1.6.1.jar
hibernate-distribution-3.6.1.Final\lib\required\slf4j-api-1.6.1.jar
hibernate-distribution-3.6.1.Final\lib\required\javassist-3.12.0.GA.jar
hibernate-distribution-3.6.1.Final\lib\required\commons-collections-3.1.jar
hibernate-distribution-3.6.1.Final\lib\required\antlr-2.7.6.jar
hibernate-distribution-3.6.1.Final\lib\required\jta-1.1.jar
As long as the hibernate-distribution-3.6.1.Final folder is outside of my project directory, everything works fine. However, if I put the Hibernate folder into the project directory, I get an error saying "Required class org.hibernate.SessionFactory does not exist in selected libraries":
The error text is wrong, the required class is definitely included in hibernate3.jar, and everything works as expected when I move the JARs outside of my project directory.
I have two questions about that:
I do not understand why the User Library behaves differently depending on whether the JARs are placed inside or outside of my project directory. Could anybody explain what's happening here?
I would like to have my project in SVN, including all the required libraries. Is there any way to configure Dali to accept User Libraries within the project directory?
Thank you very much.
I was having the same problem cos I forgot to add hibernate-jpa-2.0-api-1.0.0.Final.jar.
The only difference is that I'm using 3.5.1-Final cos 3.6.x seems not stable at the moment.
Actually, I'd prefer EclipseLink: everything works fine as a charm. I've wasted many hours with environment configuration :( Last time I've used Hibernate was years ago and looks like troubles to configure still are the same :(

Eclipse ignoring source when deploying webapp

I'm running eclipse with tomcat 5.5. For some unknown reason from one day to the other eclipse stoped compiling my beans and java files that are in the source folder.
If I go to the work directory, I find all the JSP compiled, the folders of the packadges i have, but no classes compiled inside of them. Neither eclipse, nor tomcat give errors. (Except when i try to access the non existing classes)
Anyone has any idea why this happens and how to fix it?
/fmsf
You might have "Build automatically" disabled. You can find it in the Project menu.
I've faced with such a scenario once. In addition it did not detect the local changes w.r.t the code repository. Honestly I don't know the reason but use of a new eclipse installation (Extraction) on same workspace resolved the issue.
Found the problem:
One of the files came out of SVN without read access. Eclipse blocked reading it and wouldn't compile.
+1 to all tks

eclipse is not building my EAR correctly - sometimes it forgets the war, and always leaves out my library jars - why?

I just upgraded to eclipse galileo from ganymede sr2 and now eclipse is doing a really bad job of building my EAR file during deployment. There are several utility jars that are supposed to be included that it is completely ignoring, and there is a single war file that it only includes in the EAR occasionally. Thus, when I deploy to glassfish I get errors like "File not found: blah.war" or if the war file is present, I get ClassNotFound errors.
Also, I'm trying to remove some EJB jars from the EAR but it still adds some of them back into the application.xml (it doesn't put them into the EAR as well, unfortunately).
I think eclipse is storing some extra metadata about the project somewhere outside of the EAR project and ignoring my changes to it, which is annoying. However, I don't know where this is or how to "flush" it away.
Has anyone run into something like this? Any idea how I could figure out what is really going on?
Thanks!
I have the same issue when redeploying, hopefully someone can shed some light on this, otherwise I'm going back to Ganymede...only way around it for me is to always delete the deployed EAR first then things are fine after that when I do a deploy...kind of stupid IMO.
Also getting bad memory leaks with galileo...system slows to a crawl after a few hours of usage, and lot more crashes vs Ganymede...sigh serves me right for jumping to a new version!
Looks like you can read more about this in BugZilla:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=283184
I think they'll have a fix in the next release of WTP.