Hibernate configuration in Eclipse Luna - java

I installed the Hibernate plug-in on Eclipse from here.
Installation is successful-- I'm now seeing Hibernate as an option in Window > Open Perspective.
I've set the properties on the project itself-- Enable Hibernate support is now checked in Properties > Hibernate Settings.
Also, Hibernate Builder is checked (was automatically) in Properties Builders.
However, Java is not seeing Hibernate-- I'm getting errors to all Hibernate imports in my source code.
When I attempt to "Fix project setup..." in the editor, I get "No proposals found ... click for manual configuration."
What am i missing?
I downloaded Hibernate plug-in to get around this manual fix for one thing. The same code is working all fine when I manually add the jars to the project build path.
I'm using Eclipse Luna 4.4.2
TIA.
//-------------------------
EDIT:
While autocreating persistence.xml, Eclipse is (must be) looking at the version of Hibernate plug-in, not the jars on the project's build-path.
And that's causing a version conflict in between JPA and ORM. See the accepted answer here for reference.
Burned me half a day.

The plug-ins make Eclipse Hibernate-aware, not necessarily your project. Your project still must be configured (either manually or via a dependency management tool like Maven or Gradle) with the appropriate Hibernate JARs. It's the difference between development-time (the Eclipse plug-ins), compile-time (JARs on the build path) and runtime (JARs on the runtime classpath).
It would be nice if the plug-in provided a Quick Fix (à la Fix project setup...) that offered to download and/or add Hibernate JARs to your project, but as far as I know that's not something they implemented.

Related

SpringToolSuite is unable to recognize spring boot annotations

I got a project from GitHub which is a Java spring boot application running with Maven dependencies.
I am so confused why I can't run the application successfully on STS.
There's no longer a problem on my old laptop. Because I just changed my laptop, this problem only occurred on this laptop.
The details / symptoms of the issue are:
When I typed "SpringToolSuite" on my start panel, no applications were being recognized. So I have to open STS manually from Downloads (ie. its original file location). But anyways, it is just a minor issue.
In STS, annotations such as the lombok log and most of the getter/setter methods were unrecognized.
Failed to perform "Run as Spring Boot App" from STS, but it is successful when I tried to perform "mvn clean install" to create a Maven build from command prompt.
Error message: "log cannot be resolved"
I tried finding results from other posts here but to no avail.
The steps that I import the project is:
Create another folder as the workspace.
Open STS by selecting the created folder as the workspace.
Click File > Import and import as existing Maven project (as it is a Maven-built application).
I also tried to create a Maven build from command prompt, which is successful eventually.
As the situation was so strange here, please advise further what I can do. Thanks.
Lombok has a plugin for Eclipse (and therefore STS as well) that enhances the IDE with direct support for Lombok: https://projectlombok.org/setup/eclipse
Without that extension the IDE is not really able to recognize and support Lombok.
Thanks so much for your suggestions.
First of all, I've made sure my STS the latest version. I installed it from the official site https://spring.io/tools.
I downloaded the Windows one. See image.
I executed the spring-tool-suite-4-4.16.1.RELEASE-e4.25.0-win32.win32.x86_64.self-extracting.jar file afterwards. A folder with STS application inside has been generated.
Referring to your second question, I am sure I have the lombok dependency.
This is part of my pom.xml. See image.
I also performed again the "mvn clean install". It is success and error-free.
Fyi, I also make sure every setup is right, such as:
It is pointing to the same java version as what Maven points to.
In STS, the Java compliance level is the same as the java version I defined in PATH environment variable.
Also in STS, the Installed JRE is pointing to the right folder.
But as the STS is still not recognizing Spring Boot annotations. That's why it seems weird here. For example, logs are underlined red with an error message on the IDE. Getters and Setters of #Data fields are not implicitly referenced with that spring boot annotation since they're also underlined with error.

Eclipse RCP - Shere javadocs and attached sources of dependencies among projects in workspace

I'm working on a set of plugins for a commercial Eclipse RCP Application "FOO_APPLICATION",
which comes with html javadocs for api plugins and without sources.
I'm using Eclipse 4.5.2 and the target "FOO_APPLICATION" is based on an older version of Eclipse, 3.6
Everything seems fine but I'm experiencing this annoying issue:
If I attach javadocs or sources to plugin dependecies (for eclipse standard plugins I can also attach sources, because I have also the original 3.6 sdk sources jar)
Eclipse does not remember this setup and I have to do this again at every startup. :(
What I'm missing here?
But consider also this point: I'd really like to solve this problem from a wider point of view: since I have many projects (in the same workspace) that share the same dependencies of "FOO_APPLICATION",
is there a way to setup sources or javadocs once and made them available throughout the whole workspace?
If the sources are present in the target platform as individual Source Bundles, the source is automatically displayed.
As far as I know, there's nothing comparable for Javadoc.

Liferay 6.2 GA5: error with building services

I'm trying to do some modification to the service layer of my portlet (e.g adding a column or a finder to a table in the service.xml). No matter what I do, when I build services it all goes good(no errors) but when I try to deploy or make the war, many errors appear. In this case I was just adding a new column (note2) to an already existent table
The method getNote2() is undefined for the type ESFShooterAffiliationChrono
or this:
The method getNote2() of type ESFShooterAffiliationChronoModelImpl must override or implement a supertype method
I'm working on Eclipse Luna 4.4.0, liferay IDE 3.1.2, Java JDK 1.7.0 67. I've set Compliance to 1.7 in eclipse and both "ant.build.javac.source" " ant.build.javac.target" to 1.7 in build.properties.
I think there must be something wrong with the service builder. I tried starting over with a new workspace and a fresh Plugin SDK, even with the 6.2 GA6 but with no avail. I've also tried deleting all generated service class before doing the service build but without success.
Can you give me any advice on how to solve this?
Most likely, you have some old code around and embedded in your dependencies. Search for a -service.jar named after your plugin, e.g. your-portlet-service.jar.
This might also happen when both a your-portlet-service.jar and the WEB-INF/services folder are on your build path. The compiler and the editor might pick up different versions. And when you build through Ant, Ant might pick a third variation for the precedence.
Check your eclipse and your Ant build path.

Why/Where does Eclipse inject extra libraries such as JPA 1.0?

I'm suddenly getting this error when attempting to run anything within the context of Eclipse:
Caused by: java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
I know this is the old JPA 1.0 spec being used whereas my project uses JPA 2.0. I can run my unit/integration tests no problem via Maven and IDEA, but if I run them in Eclipse (tried Kepler and Luna) I get the error.
Doing a little digging I found the older library being injected via the ProjectClassLoader:
ProjectClassLoader: entry= $HOME/.m2/repository/javax/persistence/persistence-api/1.0.2/persistence-api-1.0.2.jar
However it does not show up in my Maven dependencies or transitive dependencies. This is not the first time I've seen this. The last time I deleted my project and recreated it, but that approach failed this time. I've also tried disabling the JPA Facet.
How can I solve this?
There are 2 places to look. Both are under project properties.
First if your project is using facets look at that section. Three will be a facet listed for JPA. It should be checked and the drop down to the right should be 2.0 (or 2.1).
Next there is also a JPA tab just up from there. That has several tabs under it but the main thing is to set your JPA version and specify the implementation. This is probably where you are pulling in the 1.0 jar.
If you have facets turned on make sure the two places are consistent. You can get them out of sync quite easily and it is confusing and annoying to figure out.
I was finally able to "solve" this -- at least get myself working again. Here's what I did:
deleted my project(s) within Eclipse
deleted both the .classpath and
.project files on disk (e.g. find . -name ".classpath" | xargs rm)
reimported my Maven project
And magically the JPA 1.0 is not being included in the project anymore. #Terry had some good info, but my configuration appeared correct per his notes. I think this is just a work-around and that there's possibly a bug lurking within Eclipse Luna with regard to this.

Autocompletion in Eclipse for Roo project

I've got a Roo project where I've made a couple of entities, and when I load up the project in Eclipse it loads up fine, but if I i.e. make an instance MyEntity entity and then write entity. I don't get any of my properties (i.e. getMyField) in the autocompletion list. If I write entity.getMyField() it compiles fine, that is taken care of by the aspects. How do I enable autocompletion for functions generated by the aspects?
Cheers
Nik
Which "type" of eclipse are you using? Do you have AJDT intstalled within your eclipse? If so there is still an option to disable weaving of JDT. The note below (taken from the Roo documentation) should help you to turn on JDT weaving (Window -> Preferences > JDT Weaving.
When using AJDT you may be prompted
whether to enable weaving of the JDT.
You should select to enable weaving so
as to ensure the Java Editor in
Eclipse (or STS) gives the best
AspectJ-based experience. You can also
verify this setting is active by
loading Eclipse (or STS) and selecting
Window > Preferences > JDT Weaving.
By the way have you considered trying the Spring Source Tool Suite? There you find all the plugins (AJDT support...) already installed. And it fits very well for Roo as it offers Roo functionality from within eclipse.
I have experienced the same problem as niklassaers: Roo AspectJ methods not showing in eclipse autocompletion while compiling fine. I'm using the latest version of STS, with AJDT installed by default, and verified that JDT Weaving is active, but the problem persists.
On the other hand, I've found out that executing Maven > Update project... (Alt-F5) makes the ROO AJ methods visible to auto completion.
This solution might be related on how I structured my project (I have two eclipse Maven projects in my workspace, myproject.data containing roo classes with aj methods, and myproject.services acting as a client for those classes); besides, I have to repeat Alt-F5 every time I open my workspace, but this seems to work.
I'd like to understand better the reasons of this code completion problem, and maybe find some way to solve the problem permanently, without having to update maven projects every time. Could it be related to interactions between the AJDT plugin and m2eclipse Maven plugin?

Categories