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

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 :(

Related

ClassNotFoundException: com.itextpdf.text.Element

Situation: I have a Java file in my project that uses the features of the iTextPDF library. The project compiles properly. I use JDK 1.7, Tomcat 7.45 and Eclipse Neon.3 Release (4.6.3).
Problem: While starting the server via Eclipse, I get an error:
java.lang.ClassNotFoundException: com.itextpdf.text.Element
What I've tried so far:
Ensured that only 1 version of iTextPdf 5.4.jar is available in the entire project. It's there in WEB-INF/lib folder. It's not there in any of the externally referenced libraries.
I updated my Eclipse.
Any help will be greatly appreciated.
Well, as a starting point- try and expanding the JAR, and see if you can search for or manually find com.itextpdf.text.Element class.
if it's not found there, you know there's nothing wrong with your eclipse or project settings, and nothing wrong with your jar imports.
You should then determine between 3 options:
Is the JAR even on the classpath? it's possible everything is present there, but the project does not even consider looking in it.
Should this class be in the JAR? is it available on other versions of this JAR?
Is this class neccesasry for you application? why is eclipse looking for it, where in the code it is referecened? can you live without it? or, can you manullay replace it with a class file you can find online? (this will take some debug time, and some more research on your part)

Define a Java 9 multi-moduled project in Eclipse

I'm trying out Java 9 Jigsaw module system (no module experience yet) and would like to use it for capsuling the classes within my project, but it's confusing.
According to this article it should be possible to have multiple modules within ONE project. I made a new project in Eclipse Oxygen (Java 9 is supported) with the same structure as shown in the article. But Eclipse keeps telling me that I must not have more than one module-info.java in a project.
I really don't know how to tell Eclipse that it should use the "multi-module-mode". And I really would appreciate not having to create a new project for every single module.
This works:
This not:
But according to this article something like that should work:
And how about deployment of a modularized project with Eclipse? There is nothing to see about the new jmod extension. Do I still export it as a runnable JAR file like before?
Notice that my questions refer to working with the IDE (no command line, I mean with an IDE that should be possible, right?) Thank you for enlightening me.
Currently, Eclipse requires you to create a separate project for each module (e. g. because each module has its own Java Build Path).
To understand this design decision, consider that Java modules correspond to OSGi bundles / Eclipse plug-ins and it has always been to have a separate project for each bundle/plug-in. If you come from the Maven world, you would probably expect a deeper folder structure instead. But modules are self-contained and combining several modules into one project would only add an additional folder level without meaning. However, Eclipse supports nested projects and so-called working sets if you need an additional folder level.
Exporting modules as images is planned for Eclipse 2019-03 (4.11), on March 20, 2019 (see Eclipse bug 518445). Exporting modules as JARs that can be used on the modulepath (-m) already works (see my video).
I don't know if this question is still open for an answer, but you can solve this problem by simply removing all source folders on the build path. At least this works for Eclipse 2021-12 version.
As you can see this is a demo project from the Official Gradle Guide Book and it has multiple modules. Each module has its own module-info.java.
project structure in IntelliJ IDEA
If I open this project in Eclipse it will give me the 'duplicated entries on module-info.java' error.
Eclipse shows the error
But if I delete all the source folders on the build path, the error is gone and the project can be built and run without problem.
project properties: Java build path
The only problem is that you have to build the project with Gradle so that it will produce the .jar of each module and you have to include them in the libraries later.
include all the .jar in libraries
I think this is probably the same solution mentioned by howlger above.

Eclipse plugin: Self hosting work's but jar give unexpected behavior

I have finished developing a plugin for eclipse, along the way I have been using the self hosting feature of eclipse to test and debug my plugin. However, after exporting the plugin and installing it into my own eclipse host, hardly anything works.
I have JavaFX UI's which wont appear anymore, file's cannot be read due to URI's not being hierarchical, and other parts working very strangely.
I came here to ask why does the plugin work on a self hosted eclipse application while when exported and installed on my current host does not work?
Could it be something to do with other plugins causing conflict ?
Does self-hosting work differently than installations of jars?
The main difference is that your code is packed in to a jar. If you are trying to access files in your plug-in using things like File or FileInputStream or anything else that expects a file these will not work. There are specific Eclipse APIs you must use to access resources in plug-in jars (mainly FileLocator).
Another common mistake is not including everything that is required in the plug-in in the build.properties file. The plug-in jar only includes files listed in this file. When you test locally this requirement is not checked.

How to View Classpath While Debugging in Eclipse

I'm trying to troubleshoot a GWT-based app I'm writing in Eclipse. It currently uses Spring Framework 3.1.1 and Hibernate 4.1.6 on the back-end side. I'm currently having troubles with the dreaded "javax.validation.ValidationException: Unable to find a default provider" that seems to plague a lot of folks but is caused by different problems. I've tried the various solutions of using different versions of the JSR 303 implementation (e.g. diff. versions of Hibernate Validator) but it doesn't seem to make a difference.
And after debugging, I'm seeing why. Once execution gets to javax.validation.Validation.getValidationProviders():317 (in validation-api-1.0.0.GA), the app (running on an Eclipse internal Jetty server) attempts to read the META-INF/services/javax.validation.spi.ValidationProvider resource from the classpath and comes back empty. I am absolutely certain that the different validator implementations I've put (e.g. hibernate-validator-4.3.0.Final.jar) have that resource and it does contain a value (e.g. org.hibernate.validator.HibernateValidator), but is not appearing to the classloader in question. The way I've included the JAR in the classpath is by adding it to the project's Build Path which seems to add it to the Jetty runtime when I execute the applications.
My question is: Is there a way to view the classpath in Eclipse debug mode visible to a certain classloader? Secondly, does anyone know why the Hibernate Validator's resource is not first and foremost in the classloader that Validation is using?
The webapp classpath is composed by the directory WEB-INF/classes and by all the jars in WEB-INF/lib. If you want a jar to be available at runtime, you must NOT add it to the build path, but to WEB-INF/lib.
Dropping a jar in WebContent/WEB-INF/lib in Eclipse will make it automatically part of the buid path of your webapp, and available at runtime.

Hibernate Setup in eclipse helios

How I can setup Hibernate for a Dynamic Web application by using Eclipse Helios? I am a newbe so please let me know if there is any example.
I tried for Java application and included all JARS and it worked fine. But don't understand how I can do it for Web application and test it.
I will use Struts2 so I will appreciate if I can get appropriate example or guidance.
Drop the jars in WEB-INF/lib. Those jars are automatically added by Eclipse to the project build path, and constitute (with the WEB-INF/classes directory and the container classpath) the classpath of the webapp.
http://hardik4u.wordpress.com/2008/09/02/struts-2-hibernate-3-integrationcomplete-using-eclipse/
https://stackoverflow.com/questions/4364923/struts2-and-hibernate-framework-create-in-eclipse
First, download Struts2, and import example WAR file into Eclipse. You can find it from the source folder: struts-2.3.1-all\struts-2.3.1\apps\struts2-blank.war
Second, you should install Eclipse Hibernate Plugin. Goto Window > Preferences > Install/Update > Available Software Sites and add following link and name it JBossTools or something.
http://download.jboss.org/jbosstools/updates/helios/
Depending on your needs you can install Hibernate Plugins for many project types. In this case, select web application plugin.
And after, you should include Hibernate Core libraries into your classpath. I would recomment Hibernate 3.6 and greater. Because it does not depend on asm (asm-3.3.jar, asm-commons-3.3.jar ...) anymore. If you use earlier versions you might encounter some problems, since Struts2 also depend on asm libraries.
Then create your database, and use following link to configure and generate model bean classes.
http://casteyo.wordpress.com/2007/06/06/conf_hibernate/
Now you don't need to write mapping files by yourselves. And with DAO factory pattern you have your way to finish your project.
Hope this helps, and Goodluck