Problem began a few days ago, asked a question (Eclipse 4.5.1 jpa 2.1 facet error) but didn't get much response. In the mean time I've tracked down where the problem probably is (Maven workspace resolution setting) but have no clue about the solution. My IDS is Eclipse Mars 4.5 (newest version, downloaded and installed 2 days ago). The 'problem' project has a number of classes that extend #MappedSuperclasses (#MSC) from another project that is in the same workspace.
Here's what happens when Maven workspace resolution is:
ENABLED - (i) 'JPA Details' view functions properly, (ii) persistence.xml file opens properly (i.e. tabs at bottom show, etc), .. BUT (iii) adding #MSC to persistence.xml generates error "Class '[class]' cannot be resolved". Tried adding #MSC files to an orm.xml file, same result. Everything compiles (i.e. classes in problem project extend #MSC classes w/no problem).
DISABLED - (i) 'JPA Details' view no longer works, & (ii) persistence.xml opens only with basic xml editor, which generates many problem messages (including 'Target entity not defined') which suggest that Eclipse is no longer treating project as a qualified JPA project.
I'm really at 6's and 7's on this, would be grateful for some guidance. Is this one of those irritating false positives that needs to be suppressed? Thanks.
FWIW here's the text for the persistence.xml version:
persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
Related
I'm using IBM RAD 7 (aka Eclipse 3.4) and WebSphere 7.
I have a workspace with a basic EJB setup; projects TestEAR, TestEJB, TestJPA, TestWeb.
I can annotate an ejb ("#Stateless EntityService") in the TestEJB project and it works fine. But if I put an ejb ("#Stateless EntityDAO") in the TestJPA project it doesn't get injected in the EntityService. If I move EntityDAO to the TestEJB project it works fine.
Also, if I annotate a class an entity ("#Entity MyEntity") it is not known as an entity to the container (I get a "not recognized entity" ... "Known entity types: []" error). But if I add a my.domain.MyEntity tag to the TestEJB's persistence.xml it works fine.
QUESTION: Why can't the TestEJB project recognize annotated classes in the TestJPA project?
NOTE: There is no "Deployment Assembly" tab in Eclipse 3.4, but there is a "Java EE Module Dependencies" tab (TestEAR > Properties > Java EE Module Dependencies); I checked and all projects are in the list and checked (ie. TestEJB, TestJPA, TestWeb).
Any help is greatly appreciated! This one has me truly stumped.
Thanks,
Rob
Seems there are a few questions here...
For your TestEJB project not using TestJPA beans make sure both are listed as an <ejb> module and not <jar> module in your application.xml file in TestEAR. Also make sure they are both part of the EAR.
For the No Known Entity types if that error is appearing within RSA you might want to right click on the project and look for "JPA Tools" and select "Configure JPA entities", if you do not see "JPA Tools" ensure JPA facets are enabled for that project. If it is occuring on the server (WAS I presume) make sure the following line is not in your persistence.xml <exclude-unlisted-classes>true</exclude-unlisted-classes> or all classes will need to be listed therein, not necessarily a bad thing.
Unless it is absolutely critical I would store your EJBs and Entities in the same project for simplicity.
How do I switch project from JDK 6 to 7, I know I am not using it because switch doesn't accept String.
In build path I have jre 7 in compiler settings I have 1.7 , everywhere and it still doesn't work. I use Spring Tool Suite(Eclipse based) latest version which officially supports Java 7.
And in project facets I also have 1.7. Why it has to be so bloody difficult.
And in .ini I have perfectly correct C:\Program Files\Java\jdk1.7.0\bin\javaw.exe
-startup
And I am sure my IDE supports 7 because whenever I create new project I have not syntax errors with String switch statement.
And my JAVA HOME set to JDK 1.7 :-)
UPDATE: The problem only happens with projects of Spring nature.
UPDATE 2: Happens with template Spring MVC project, Spring Hibernate template apparently works with Java 7.
Totally confused.
When I start a new Java project in Eclipse Indigo, eclipse tells me that the compiler compliance level 1.7 is not supported:
It is not possible to change that from inside eclipse, the properties dialog shows that:
So as a result, it is not possible to use the new switch statement with Strings in it:
See the "Eclipse Forums Post" for more information about the topic. It seems that it will come only with the next eclipse version.
In window / preferences / Installed JREs you need to have the JDK1.7 as the default set up. Additionally in Project / Properties Java Compiler it should be also set (or disable the project specific settings)
UPDATE :
In my .settings folder there is a file called org.eclipse.wst.common.project.facet.core.xml
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.6"/>
<installed facet="jst.web" version="2.4"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
and contains some rather suspicious values. Not sure it matters, but worth trying to close the project change it then reopen the project. If that doesnt help then search for the string 1.6 in all files in your project
Compare .classpath and .project files between your simple Java projects and Spring projects. Sometimes the Nature or other project setting can be set differently.
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 :(
Can anyone explain where the Eclipse GWT plugin defines it's entry points?
In an attempt to get my old GWT project working again with GWT 2.0, I created a default GWT 2.0 project in Eclipse and was able to run it successfully. It's the one that asks for a name and calls the 'greet' servlet on the server, which responds etc... so far so good.
I then ported all the classes from my older maven GWT project over to this new GWT project in the hopes of getting the RPC calls to work. It had many dependencies, so I also copied over the maven pom.xml, commented out all of the gwt related plugins in the pom, and managed to get the Eclipse M2Eclipse maven pluging to recognize the pom and adopt all of the maven dependencies. All of the issues in Eclipse are now resolved and it looks good to go.
However, when I click on the GWT compile icon for the project, it pops up a "GWT Compile" dialog now asking me to "Add an entry point module". There are no entry points listed to choose from in this dialog. This is frustrating because I kept the exact same GWTApp.gwt.xml and moved my code into the previously-working auto-generated GWTApp.java class.
I can't imagine why the Eclipse plugin doesn't look in the GWTApp.gwt.xml file to figure out what the entry points are.
Can anyone explain how these entry points are defined or suggest why the project stopped working?
Thanks!
I'm certain the following is the problem and solution. I've been doing GWT for about 6 years.
Whenever you import an existing maven (namely from a Mojo-generated archtype, but probably others) project into eclipse, you will get a broken configuration which will not allow you to debug until you fix it. But the fix is simple. What happens is the build path will be set to exclude all files from '[proj]/src/main/resources', and this has the effect of hiding the [proj].gwt.xml module file from eclipse. So all the GWT dialogs that look for those modules can't see them! So you can't even create a debug configuration that works.
Here's the fix:
Right-click the project, and open Properties -> Build Path dialog -> Source Tab, and look for the one ending in '.../src/main/resources', and you will see it has excluded: . So highlight just that entry and remove the '', so that it reads "Excluded: (None)". Now the dialogs (namely the debug configuration dialog), for GWT will all see your module file, and everything will work.
Just to be sure, that wouldn't be similar to this case, where the exclusion filter was a bit too large?
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes"
path="target/base-resources"/>
I think that you may have an exclusion filter which is too aggressive on your "target/base-resources" directory.
It seems that you have an exclusion filter of "**". Won't that match everything?
You are right! This was the problem! :)))
I didn't know what the exclusion filter was and somehow it was added automatically during the development.
Thanks for the suggestions to my question - you prompted me to find the answer. I looked and did not have any exclusion filters but checked the Java Build Path in the project properties.
When I'd added the maven dependencies, it must have implicitly changed the defined source directory of the GWT eclipse project. (Probably to src/main/java or whatever that dumb long-winded maven default path is). Eclipse offered no hints that the Java classes were not on the project build path. Once I defined the src directory explicitly for the project, the gwt.xml module appeared in the GWT Compile dialog box!
On to the next hurdle... coz it still ain't working yet! :(
Thanks for your help!
Sonatype's eclipse maven plugin is infamous for many things. One of them is excluding all the files in your resources maven folder for a given module whenever you allow it to rebuild the eclipse classpath.
m2eclipse will probably be the single reason that I re-evaluate using Intellij...
I had the same problem.
Right click the project and select properties.....
There was empty dialog (no entry points suggested).
After some digging I found that mymodule.gwt.xml file was accidentally marked as "lib" in .classpath (eclipse project file in the root of the project folder). I seems it was marked as "lib" on .classpath automatic generation (I was importing clean maven GWT project, not eclipse project).
Simply delete line with mymodule.gwt.xml from .classpath file, cause it is in src/main/resources, that is normal "src" classpath.
Right click the project and select properties. Expand and select Google -> Web Toolkit. The right pane will have a section called Entry Point Modules. Click the add button and select your .gwt.xml file.
(Eclipse 3.4, Ganymede)
I have an existing Dynamic Web Application project in Eclipse. When I created the project, I specified 'Default configuration for Apache Tomcat v6' under the 'Configuration' drop down.
It's a month or 2 down the line, and I would now like to change the configuration to Tomcat 'v5.5'. (This will be the version of Tomcat on the production server.)
I have tried the following steps (without success):
I selected Targeted Runtimes under the Project Properties
The Tomcat v5.5 option was disabled and The UI displayed this message:
If the runtime you want to select is not displayed or is disabled you may need to uninstall one or more of the currently installed project facets.
I then clicked on the Uninstall Facets... link.
Under the Runtimes tab, only Tomcat 6 displayed.
For Dynamic Web Module, I selected version 2.4 in place of 2.5.
Under the Runtimes tab, Tomcat 5.5 now displayed.
However, the UI now displayed this message:
Cannot change version of project facet Dynamic Web Module to 2.4.
The Finish button was disabled - so I reached a dead-end.
I CAN successfully create a NEW Project with a Tomcat v5.5 configuration. For some reason, though, it will not let me downgrade' an existing Project.
As a work-around, I created a new Project and copied the source files from the old Project. Nonetheless, the work-around was fairly painful and somewhat clumsy.
Can anyone explain how I can 'downgrade' the Project configuration from 'Tomcat 6' to 'Tomcat 5'? Or perhaps shed some light on why this happened?
Thanks
Pete
This is kind of hacking eclipse and you can get into trouble doing this but this should work:
Open the navigator view and find that there is a .settings folder under your project expand it and then open the file: org.eclipse.wst.common.project.facet.core.xml you should see a line that says:
<installed facet="jst.web" version="2.5"/>
Change that to 2.4 and save.
Just make sure that your project isn't using anything specific for 2.5 and you should be good.
Also check your web.xml has the correct configuration:
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
This may be old but I tried and found the following in eclipse Galilio.
Open the navigator view and find that there is a .settings folder under your project expand it and then open the file: org.eclipse.wst.common.project.facet.core.Delete the content of this file and right click on the project and click on properties. Go to Project Facats in the popup window there you can click on runtime tabs and convert your project to the new facet you want.
if you are using Maven, then shutdown eclipse, then type >mvn eclipse:eclipse -Dwtpversion=2.0, and restart the eclipse.
Sorry it seems I can't post a comment without enough Rep so...
I think it's too difficult for eclipse to degrade safely to a lower standard because it can't really know if you've used something from the newer web standard. So if it just allows you do to that it could cause your program to fail on an older version.
You can always be backward compatible but not forwards compatible.
You can try to uncheck the facet, apply, change the value of the facet and check. It works for me in Eclipse Helios SR1.
So the main difference is that I do it with 'Dynamic Web Module'.
I hope it works for you too.
I saw the same thing, then I changed the web-app version value in the web.xml. Doing so could fix this for you.
If you are using maven you can generated the eclipse settings using the maven eclipse plugin.
For the jst.web version the Maven eclipse pluging takes into account the dependencies of the project. If you have a servlet api dependency defined :
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>servlet-api</artifactId>
<version>6.0.32</version>
</dependency>
You jst.web parameter will be 6.0
<faceted-project>
...
<installed facet="jst.web" version="6.0"/>
...
</faceted-project>