Community
Participate
Working Groups
Bugzilla – Bug 251323
[Maven] problem with excluded resources
Last modified: 2015-02-13 08:11:21 EST
When configuring Maven projects in Eclipse IDE, the M2E project has to add excludes "**" for all resources in JDT source folders, so it could apply resource filtering. Basically it disables resource handling that is done by JDT and instead resources are processed by custom builder that copy them and does other filtering. Unfortunately such approach conflicts with data tools, that trows the error shown below and it looks like the problem is caused by resource exclusion. I wonder if this can be fixed in the data tools, so it would scan output folders for resources instead of sources. It would allow to use Maven filtering and would also allow to pickup generated descriptors. java.lang.NullPointerException at org.eclipse.jpt.core.internal.context.persistence.GenericPersistence.update(GenericPersistence.java:123) at org.eclipse.jpt.core.internal.context.persistence.GenericPersistenceXml.update(GenericPersistenceXml.java:106) at org.eclipse.jpt.core.internal.context.GenericRootContextNode.update(GenericRootContextNode.java:161) at org.eclipse.jpt.core.internal.GenericJpaProject.update(GenericJpaProject.java:715) at org.eclipse.jpt.core.internal.AsynchronousJpaProjectUpdater$UpdateJob.run(AsynchronousJpaProjectUpdater.java:82) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
I apologize for not responding to this earlier, but I wasn't sure quite how to respond to this issue. It would appear that we are not handling the case where this filtering is being done, and I assume that would be a bug on our part. But I'm not sure I understand the request very well. The JPA tools don't rely on compiled classes, but rather require Java sources to work with. The tooling manipulates .java files via the JDT, and as a result I don't think we can move away from this standard use-case (java files in source folders). It seems that there may be a new use case here, which involves (I think) working with Java source files located in the output folder. I'm not sure if or how this would work given our current usage of JDT, but perhaps someone could investigate the possibilities in this area.
(In reply to comment #1) > It would appear that we are not handling the case where this filtering is being > done, and I assume that would be a bug on our part. But I'm not sure I > understand the request very well. The JPA tools don't rely on compiled > classes, but rather require Java sources to work with. The tooling manipulates > .java files via the JDT, and as a result I don't think we can move away from > this standard use-case (java files in source folders). Java sources are still in source folders and work fine with Dali. Only resources (all non-Java source files) like persistence.xml and orm.xml can be filtered and therefore need to be read from the output folder.
+1 Can only second that. JPA Tools are entirely unusable if you use m2eclipse which is really annoying if you have a lot of projects build on this combination ;). Regards, Ollie
hmm - how is Dali supposed to *edit* persistence.xml in the output ? that is not really relevant. Where is the persistence.xml in the first place ?
(In reply to comment #4) > hmm - how is Dali supposed to *edit* persistence.xml in the output ? that is > not really relevant. Good point, but I write the persistence.xml myself anyway. I still would like to use the Persistence Outline/Properties... > Where is the persistence.xml in the first place ? src/main/resources/META-INF/persistence.xml src/main/resources is a java soure folder, but, as Eugene pointed out, all files are excluded, because m2eclipse handles resources with a custom builder to be able to filter resources.
There is some discussion going on about using Maven with Dali JPA on the Dali newsgroup. Here is the root of the thread: http://www.eclipse.org/newsportal/article.php?id=717&group=eclipse.technology.dali#717
(In reply to comment #6) > There is some discussion going on about using Maven with Dali JPA on the Dali > newsgroup. Nothing new, the posters probably don't use resource filtering...
*** Bug 290929 has been marked as a duplicate of this bug. ***
I created an issue against m2eclipse "MNGECLIPSE-2197":https://issues.sonatype.org/browse/MNGECLIPSE-2197
(In reply to comment #9) > I created an issue against m2eclipse > "MNGECLIPSE-2197":https://issues.sonatype.org/browse/MNGECLIPSE-2197 I don't really get why looking up classpath resources done against filtered source folders should be M2Eclipse's fault. Dali simply has to inspect the applications target folders. I think the main bug is to expect resources being filtered from the source folders cannot appear in the classpath in any case. In M2Eclipse case, as the pom.xml is the simple place of truth all resources have to marked as excluded as it applies the filtering configured in the pom and the rather limited filtering of Eclipse has to be "deactivated" somehow. Regards, Ollie
We are going to be doing some work in this area for our next release which will hopefully improve this general issue.
bug 317900 has been opened to track a solution to this problem.
bug 317900 has been fixed, which should go a long way towards addressing this issue. The problem remains to map runtime artifacts to resource locations (or to allow build resources to be used), and I feel this puts the ball in m2eclipse's court to provide an implementation of ResourceLocator that will do this.
more and more GlassFish users, using maven are seeing this...
CC'ing m2e project lead. Igor...perhaps you could comment on the possibility for an m2e solution for this issue based on the Dali changes made in bug 317900? It would be great if we could work something out for Indigo.
Adding Fred Bricon to CC who maintains m2e/wtp integration, which is not part of m2e eclipse.org project, at least not yet.
Update: Progress is being made on a solution outside of the Dali project in the m2e-wtp tooling. I don't have information on an date for this support, but it is currently targeted to m2e-wtp 0.14. This issue can be tracked further here - https://issues.sonatype.org/browse/MECLIPSEWTP-11. I am un-targeting this bug as it won't be fixed in a Dali release, but will leave it open for tracking purposes until there is a solution available.
The real world is still seeing this problem, 3 years later. http://stackoverflow.com/questions/3701901/eclipse-does-not-recognize-content-of-persistence-xml
(In reply to comment #18) > The real world is still seeing this problem, 3 years later. I can understand the frustration, and I can assure everyone that the Dali project is very interested in getting proper Maven support, as there is obvious demand from our users. I see m2e-wtp as the proper and only real solution at this time, and as such we have been collaborating with those involved in this effort. I will try to get more information on when 0.14 is planned for release.
(In reply to comment #19) > I will try to get more information on when 0.14 is planned for release. I plan on releasing before the end of september. That means I'll get my hands on the matter real soon, probably next week.
Is there an update site containing Dali or WTP nighlty builds so I can get m2e-wtp's own tycho build running?
(In reply to comment #21) > Is there an update site containing Dali or WTP nighlty builds so I can get > m2e-wtp's own tycho build running? Nightly WTP builds are available at the following location: http://build.eclipse.org/webtools/committers/ Milestone and integration builds are found here: http://download.eclipse.org/webtools/downloads/ Indigo maintenance builds are labeled "3.3.1", Juno builds are "3.4.0". Each build has a hosted p2 repository, which can be found by appending "/repository" to the end of the build page URL. So for the latest nightly build, the p2 repo is located here: http://build.eclipse.org/webtools/committers/wtp-R3.3.1-M/20110907002726/M-3.3.1-20110907002726/repository/ The nightly's aren't retained for very long, so that is something to be aware of.
Hi, I've been trying to implement a Maven Resource Locator. I'm still not exactly sure where I'm going but, so far I wrote a *very* simple, naive implementation, which basically returns the files under the build output folder and delegates everything else to the SimpleJavaResourceLocator. That means the project explorer always displays the resolved / filtered persistence.xml. The problem is if you click on the nodes under the JPA Content icon, it'll open the resolved file, not the source one. So if I were to return the source file instead, well we'd get the opposite. Correct edited file but invalid connection parameter values, if they were filtered. So. I can probably return the original source file when maven filtering is deactivated, and the filtered file when it's on, but that feels a bit odd. WDYT? Also it seems the getRuntimePath method is never used/referenced.
There has been a lot of confusion on this issue. After conversations with Fred Bricon, I think we can say that the fix to bug 317900 should solve almost all (if not indeed all) issues with maven. The problem is that somewhere someone suggested that we should be looking at *output* files when maven is concerned. This led to the idea that m2e should implement a resource locator to map runtime locations to files in the output directories. This is not the case. Dali should be fine with source files in every scenario I (and others) can imagine. Exclusions were the problem. *Not* filtering. We're very close to marking this as fixed (in Indigo). We ask that any who have had problems with this in the past try this in Indigo and indicate if it is no longer a problem or give more details if it is still a problem.
It should also be noted that inconsistent results in testing on Indigo based builds could be due to bug 357810. If Dali doesn't appear to be working as expected, please perform a project Clean... to ensure that the JPA or JAXB project has been built correctly after import. This should only have to be done once per project and will no longer be necessary after bug 357810 is fixed in Indigo SR2.
I would like to add that the inconsistency consistently (pun intended) manifests itself when adding a new dependency to a Mavenized project in Indigo. After re-updating the project configuration (Maven->Update project configuration) the error disappears again. Unfortunately I am not in a position to try any patches. Here is how to reproduce: 1. Switch to Java EE perspective 2. Create new Maven project (File->New->Other->New Maven Project) from archetype: Group ID: org.codehaus.mojo.archetypes Artifact ID: webapp-jee5 Version: 1.3 3. Add a dummy Servlet so there is some Java code for compilers to pick up (New -> Servlet) 4. Create a directory src/main/resources/META-INF 5. Run Maven->Update project configuration 6. Verify that src/main/resources was added to source folders (Java Resources) 7. Enable JPA facet (Properties->Project Facets) and select "Disable Library Configuration" as "Type" (click on "additional configuration" prompt) 8. Verify that persistence.xml was generated to src/main/resources/META-INF 9. Now add a new dependency to the project (Maven->Add Dependency) eg hsqldb:hsqldb:1.8.0.10 or org.hibernate:hibernate-entitymanager:3.6.7.Final 10. The persistence.xml error will appear. 11. Select Maven->Update project configuration or Project->Clean 12. The error disappears again. My configuration: Operating system: Fedora 15 x86_64 Eclipse Java EE IDE for Web Developers. Version: Indigo Service Release 1 Build id: 20110916-0149 M2E - Maven Integration for Eclipse Version: 1.0.100.20110804-1717 Dali Java Persistence Tools - JPA Support Version: 3.0.1.v201108163011-7R7F7CFC7sRdiShWvWQYU375 Build id: 20110324075937
Antix, I believe that is the behavior to 357810. Without any further comment on this bug, I am going to resolve it fixed.
This bug is still there in my Eclipse Luna.
http://stackoverflow.com/questions/3701901/eclipse-does-not-recognize-content-of-persistence-xml is pointing here.