Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 184378 - Tests do not compile after adding the modelgen jar
Tests do not compile after adding the modelgen jar
Status: RESOLVED WONTFIX
Product: javaee
Classification: Unclassified
Component: Persistence
6.x
All All
: P3 (vote)
: 6.x
Assigned To: Sergey Petrov
issues@javaee
:
Depends on:
Blocks: 178108
  Show dependency treegraph
 
Reported: 2010-04-16 19:56 UTC by Petr Jiricka
Modified: 2010-05-14 19:47 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments
Build log (9.45 KB, text/plain)
2010-04-16 19:56 UTC, Petr Jiricka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2010-04-16 19:56:54 UTC
Created attachment 97554 [details]
Build log

1. Create a new Java class library project
2. Create some entity classes from database
3. Add the eclipselink-jpa-modelgen jar file from the EclipseLink distribution to the classpath
4. Build the project - works fine
5. Create a new class under Test Packages
6. Run tests for the project

=> Fails with the message in the attachment.

The question is whether the fix should be on the NetBeans side (making sure we don't put the modelgen jar file on the tests classpath if persistence.xml does not exist), or on the EclipseLink side (be more tolerant to missing persistence.xml). My preference would be on the EclipseLink side.

Right how this bug is not that pronounced because of step 3, but when we re-enable issue 178108 (metamodel generation by default), this bug will become more serious, as it will fail out of the box.
Comment 1 Sergey Petrov 2010-04-19 12:23:01 UTC
I can run selected test, but "Test" for entire project fails with ap problem.
Comment 2 Sergey Petrov 2010-04-20 08:11:10 UTC
What I can see if I have entity in src and entity in test, both are processed by ap correctly and both have metamodel generated and present in code completion.
Comment 3 Sergey Petrov 2010-04-20 08:15:26 UTC
/tried j2se and ap in editor support, in case of web project entities from test are not processed, it may be another issue.
Comment 4 Tomas Zezula 2010-04-20 08:22:30 UTC
I am looking at it.
Comment 5 Tomas Zezula 2010-04-20 14:29:52 UTC
The problem is that the eclipselink requires the persistence.xml file. The best fix if possible is on the eclipselink side (if there is no persistence.xml and there are no @Entity classes do nothing). If not doable on eclipselink side Sergey can extend his indexer, which now copies the persistence.xml into caches, to put it also into tests cache root. This is ugly but it should work. We will also need such a hack in the build-impl.xml for the case when compile on save is off.
Comment 6 Sergey Petrov 2010-04-20 16:17:17 UTC
Is there any difference with build and with run classpath for tests?
Eclipselink see persistence.xml if tests are executed and can access db/persist entities etc. But it may be because main part access persistence.xml another way then annotation processor.
Also as I said before I got metamodel generated for entity in test sources in j2se project in current build, i.e. without additional hack for indexer.
Comment 7 Tomas Zezula 2010-04-20 16:31:42 UTC
Yes, there is a difference.
For source compile, the source root contains the persistence.xml and it's copied into caches.
For tests the source root is test folder which has on its classpath build/classes (result of compilation of src folder). There is no persistence.xml among sources or class output (caches).

In the runtime the persistence.xml is probably loaded by ClassLoader.getResource which looks up in all jar files on classpath. In compile time the AP is looking for persistence.xml only in CLASS_OUTPUT (where your indexer copies it from src root).

>Also as I said before I got metamodel generated for entity in test sources in j2se project in current build.
But you had a persistence.xml in the test root, right? For the j2seproject works the original "hack" before the indexer was integrated. When AP is looking for file in CLASS_OUTPUT and it's not found there we are trying to find it among SOURCE.
Comment 8 Sergey Petrov 2010-04-20 17:04:40 UTC
>But you had a persistence.xml in the test root, right?
No, I'll retry tomorrow, but I had persistence.xml in usual location only.
Comment 9 Sergey Petrov 2010-05-04 11:54:35 UTC
I'll wait for 2.0.3 for integration.
Comment 10 Petr Jiricka 2010-05-05 15:25:18 UTC
For now, I think we can downgrade to P3, what do you think?
Comment 11 Sergey Petrov 2010-05-06 11:01:55 UTC
As it was considered el issue and is fixed on el side, in my opinion this one issue may be closed now.
Comment 12 Sergey Petrov 2010-05-14 19:47:14 UTC
if there are no objections.
now metamodel jar isn't added by default
later eclipselink versions will no have this issue
no actions from nb is planned - close as won't fix


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo