0

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"

jfr
  • 397
  • 2
  • 17
  • Have you imported the projects via Maven import ? – khmarbaise Feb 10 '16 at 16:58
  • @khmarbaise - thanks for replying. I'm not sure if the current project was imported, but in trying to work this out - I've tried a number of things many times - I'm sure at least one was an import, and it would've been via 'Import ..\Existin Maven Project'. FWIW, I can live with having 'workspace resolution enabled' turned on, though I think that's not a good practice. What concerns me is how the persistence.xml file refuses to accept the mapped superclasses, as I think is going to cause big problems later. – jfr Feb 10 '16 at 18:11
  • @Khmarbaise - your question raises a few on my end: 1) There's no out-of-the-box JPA/Maven project for Eclipse. You have to create one, and then enable the other. From google searches it doesn't appear to make any difference which one comes first, but I'm not so sure. What do you think? What would you suggest? ... 2) Re importing, would I be better of not importing, but instead create a new project from scratch (which one comes first depends on answer to question #1) ? Thanks! – jfr Feb 10 '16 at 18:35
  • If you correctly have a working maven project use the default location in should be imported correctly and should berecognized by Eclipse. If you reimport...first you have to delete `.classpath`, `.project` and `.settings` folder in your project to force Eclipse to recreate them from scratch... – khmarbaise Feb 10 '16 at 21:30
  • @khmarbaise - apologies for not getting back sooner, needed to try a few things out, that took lots of time, and then other things came up. Not sure exactly what causes the problem but the ONLY solution was to enable workspace resolution (menu item on the Maven right-click popup window). Why this is necessary for the project to function as a JPA project is and will remain a mystery. But thanks again for your input. – jfr Feb 29 '16 at 17:13

0 Answers0