Bug 425053 - persistence.xml with filter var - error: cannot be resolved
Summary: persistence.xml with filter var - error: cannot be resolved
Status: UNCONFIRMED
Alias: None
Product: M2E-WTP
Classification: Technology
Component: jpa (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P3 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-07 17:25 EST by Marcus Malcom CLA
Modified: 2015-08-26 23:18 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcus Malcom CLA 2014-01-07 17:25:26 EST
Versions:

* Eclipse Kepler Service Release 1
* m2e - Maven Integration for Eclipse 1.4.0.20130601-0317
* m2e-wtp - JPA configurator for WTP 1.0.1.e43-20130911-1546
* m2e-wtp - Maven Integration for WTP 1.0.1.20130911-1545


Example persistence.xml:

<persistence>
    <persistence-unit>
        ...
        <jar-file>some-jar-${some.version}.jar</jar-file>
        ...
    </persistence-unit>
</persistence>

Error:

Type: JPA Problem
Description: JAR file "some-jar-${some.version}.jar" cannot be resolved  persistence.xml
Comment 1 Fred Bricon CLA 2014-01-07 17:32:26 EST
Can you please attach a sample project reproducing the error? 
Also do you see an error if the filename is hardcoded?
Comment 2 Marcus Malcom CLA 2014-01-07 18:14:55 EST
I can't add a sample project at this time. I'd need to create a dummy project and I just don't have time right at the moment. I might be able to get to that soon, but I suspect you will need that on your side.

Adding a specific version doesn't seem to help.
Comment 3 Fred Bricon CLA 2014-01-07 21:52:37 EST
Does the target file correspond to an open project?

I suspect there might be 2 bugs here :
- the filtered version of the persistence.xml isn't used by Dali (WTP's JPA support). I guess this is a resource locator issue on the m2e-jpa side
- Dali doesn't support <jar-file> resolution somehow.

We'll still need a sample project anyway
Comment 4 Fred Bricon CLA 2014-01-07 21:55:44 EST
cc'ing Neil Hauge of Dali's fame, who might have some ideas
Comment 5 Neil Hauge CLA 2014-01-08 09:59:07 EST
(In reply to Fred Bricon from comment #3)
> Does the target file correspond to an open project?
> 
> I suspect there might be 2 bugs here :
> - the filtered version of the persistence.xml isn't used by Dali (WTP's JPA
> support). I guess this is a resource locator issue on the m2e-jpa side
> - Dali doesn't support <jar-file> resolution somehow.
> 
> We'll still need a sample project anyway

Currently Dali doesn't support resource filtering, so that is likely the issue.  We do support jar-file resolution, but not one with variables.
Comment 6 Marcus Malcom CLA 2014-01-08 10:59:42 EST
@Fred - re: 2 bugs.

Yes I agree, I tried a maven filter var and one w/o the filter var. Neither one seems to work.
Comment 7 Marcus Malcom CLA 2014-01-08 11:04:00 EST
@Neil - is this on the roadmap? ETA? If not, can this be added?

Thanks - M
Comment 8 Fred Bricon CLA 2014-01-08 11:49:31 EST
Neil, if m2e-jpa provides the filtered persistence.xml via a resource locator, would that be enough? I'm not sure as I suspect the marker is applied to the non-filtered file being edited.

The fact a non-filtered version doesn't find the jar makes me think there might be an issue with Dali's jar file resolution anyway.
Comment 9 Neil Hauge CLA 2014-01-08 12:21:34 EST
Ah, missed that comment about a specific version not helping.  You may need to do a project clean after adding a jar in order to specify the jar-file.  Try a hardcoded example and a project clean after adding the jar and the jar-file ref to see if that clears up the warning.  jar-file refs are a deployment time concept, so there are cases where it would not resolve at design-time, but we try to cast a wide net to resolve it.

I would think a resource locator that provides the resolved persistence.xml would be sufficient to fix the filtering issue.  I'll try to verify.
Comment 10 Marcus Malcom CLA 2014-01-08 12:35:12 EST
When I changed to a non-variable I am still having the same problem: JAR file "some-jar-2.1.8-SNAPSHOT.jar" cannot be resolved. 

Just to be sure, some-jar-2.1.8-SNAPSHOT.jar is showing up under Maven Dependencies. The problem happens in both of these scenarios:

1) Project reference (I have the some-jar project loaded in Eclipse) and the Maven Dependency is referencing the project

2) JAR reference - closing the some-jar project and pulling the JAR from maven repo
Comment 11 Marcus Malcom CLA 2014-01-08 12:35:58 EST
Oh and sorry, yes, I do a Clean each time I make a change, still doesn't work.
Comment 12 Neil Hauge CLA 2014-01-08 12:57:27 EST
(In reply to Marcus Malcom from comment #11)
> Oh and sorry, yes, I do a Clean each time I make a change, still doesn't
> work.

In that case the JAR must not be getting picked up as a JPA file in our project scan.  That would indicate a deeper issue.

A JPA file is found by visiting all the resources in an IProject.  It then has to pass a number of tests, including:
- is it a java related file
- javaProject isOnClassPath() answers true
- the fileResourceLocationIsVaid (this is a ResourceLocator implemented method and may be where the problem is occurring?)

This logic is found in AbstractJpaProject.addJpaFileMaybe_(IFile).
Comment 13 Marcus Malcom CLA 2014-01-08 16:20:21 EST
Is there anything I can do on my side? The project/jar should adhere to those contraints ... not sure what fileResourceLocationIsVaid is all about.
Comment 14 Neil Hauge CLA 2014-01-09 14:00:59 EST
(In reply to Marcus Malcom from comment #13)
> Is there anything I can do on my side? The project/jar should adhere to
> those contraints ... not sure what fileResourceLocationIsVaid is all about.

I don't think so.  I think the custom ResourceLocator is going to have to change to support this Maven related requirement
Comment 15 Archimedes Trajano CLA 2015-08-26 23:18:26 EDT
This is still happening on Eclipse Mars

However, I don't think Dali should try to do any resource filtering.  However, it should read the Deployment Assembly and process it based on the "deployed" version rather than the source version.