Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 183779 - [71cat] Unable to compile project with JPA Entities and Eclipselink
[71cat] Unable to compile project with JPA Entities and Eclipselink
Status: RESOLVED WORKSFORME
Product: javaee
Classification: Unclassified
Component: Persistence
7.1
All All
: P1 with 3 votes (vote)
: 7.2
Assigned To: Sergey Petrov
issues@javaee
:
: 202420 210547 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-04-09 15:06 UTC by javydreamercsw
Modified: 2015-02-04 03:14 UTC (History)
8 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
Full output for review (19.09 KB, text/plain)
2010-04-09 15:09 UTC, javydreamercsw
Details
Sample Project (331.91 KB, application/octet-stream)
2010-05-27 23:48 UTC, javydreamercsw
Details
stacktrace (1.39 KB, text/plain)
2012-05-10 19:23 UTC, Jesse Glick
Details
stacktrace (1.39 KB, text/plain)
2012-12-10 17:25 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description javydreamercsw 2010-04-09 15:06:13 UTC
[ BUILD # : 201004090201 ]
[ JDK VERSION : 1.6.* ]

I'm getting this error when compiling:

error: javax.annotation.processing.FilerException: Attempt to recreate a file
for type com.validation.master.core.db.AssigmentType_

Before that I see Notes about metadata creation of classes like this one:

Note: Building metadata class for round element:
com.validation.master.core.tool.MD5

But also noted that is looking for some weird files, maybe this is why is
failing:

Note: File was not found: META-INF/orm.xml
Note: File was not found: META-INF/eclipselink-orm.xml
Note: File was not found: META-INF/orm.xml
Note: File was not found: META-INF/eclipselink-orm.xml

What I have is the persistence.xml file on the META-INF folder. this used to
work before. Just retried in today's build.
Comment 1 javydreamercsw 2010-04-09 15:09:17 UTC
Created attachment 96968 [details]
Full output for review
Comment 2 Jiri Rechtacek 2010-04-09 16:02:03 UTC
As a workaround add a switch -proc:none into javac.compilerargs into project.properties, e.g.javac.compilerargs=-Xlint -Xlint:-serial -proc:none. I use this solution in CRUD Sample too.
Comment 3 Jesse Glick 2010-04-09 16:14:51 UTC
Not clear what project type you are using, so reassigning for evaluation.
Comment 4 Sergey Petrov 2010-04-09 17:02:45 UTC
If you don't need entities metamodel it's easy to turn off ap in project properties, but wonder why eclipselink tries to recreate AssigmentType_, may it be listed in persistence.xml twice?
Comment 5 Sergey Petrov 2010-04-09 18:11:00 UTC
As it may be an issue in CanonicalModelProcessor it may be good to file an issue at https://bugs.eclipse.org/bugs/
Comment 6 Sergey Petrov 2010-04-09 19:45:28 UTC
Jiri
Do you mean GRUD sample have the same issue?
Comment 7 Sergey Petrov 2010-04-09 20:00:39 UTC
As I missed it in previos comment.
Note: File was not found: META-INF/orm.xml
Note: File was not found: META-INF/eclipselink-orm.xml
Note: File was not found: META-INF/orm.xml
Note: File was not found: META-INF/eclipselink-orm.xml

are notes only and are shown insuccesful cases also, most likely compile failed only because of error
error: javax.annotation.processing.FilerException: Attempt to recreate a file
for type com.validation.master.core.db.AssigmentType_
Comment 8 javydreamercsw 2010-04-10 00:36:52 UTC
In my case it was a plain Java project. I was in the process of retrying with a Web project when the work week came to a close. :P Will file the bug as suggested.
Comment 9 Sergey Petrov 2010-04-12 08:47:04 UTC
Thanks, please add link to el issue if you will file.
Comment 10 javydreamercsw 2010-04-12 11:57:20 UTC
Here's the link to the bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=308713
Comment 11 Sergey Petrov 2010-04-13 10:28:54 UTC
I found one of your projects(VMCore) with AssignmentType and it contain two AssignmentType entities, it's marked with error badge even in editor, so it's reasonable to have some problem from persistence support. If you still want to compile such project it's easy to turn of ap in project properties.
Feel free to reopen with your opinion/ more details.
Comment 12 javydreamercsw 2010-05-27 04:09:41 UTC
I was able to remove the badges after recreating the Persistence classes.

Need to retry tomorrow.

It only appear to happen with Eclipselink. Hibernate and Top link doesn't show that issue but I need JPA 2.
Comment 13 javydreamercsw 2010-05-27 15:37:04 UTC
I made sure no duplicate entities exist.

Even recreating the files got to the same error as before, adding the -proc:none  compiler option fixed the issue but it needs further investigation IMO. I noticed that the Eclipselink libraries seem up to date.
Comment 14 Sergey Petrov 2010-05-27 15:42:12 UTC
can you provide sample project?
what build do you use?
Comment 15 Sergey Petrov 2010-05-27 15:43:11 UTC
do you have the same output without duplicates?
Comment 16 javydreamercsw 2010-05-27 23:48:09 UTC
Created attachment 99576 [details]
Sample Project

I tried with 20100526001 and 6.9 RC1. I get exactly the same output without having duplicates.

The sample project has the
Comment 17 javydreamercsw 2010-05-27 23:49:35 UTC
*completing previous comment, sorry*

javac.compilerargs=-proc:none not enabled. Enabling that makes the project compile perfectly.
Comment 18 Sergey Petrov 2010-05-28 13:20:14 UTC
ok, I found two reasons and both are eclipselink related
- eclipselink do not handle j2se environment properly, and do not work properly without <exclude-unlisted-classes>true</exclude-unlisted-classes>, but it's not main one here as all classes are listed already.
- if several pu contain the same entity eclipselink throw this exception and block compilation.
in my opinion eclipselink issue can be reopened with these details, 

as a workaround/fix/solution on nb side if there are more then one pu
1) disable  annotation processing (just uncheck checkbox in compile option)
2) specify additional compiler option like "-Aeclipselink.persistenceunits=VMPU" if you want to use metamodel.
Comment 19 javydreamercsw 2010-05-28 23:42:34 UTC
Reopened eclipse bug as requested.
Comment 20 David Konecny 2010-05-31 00:04:37 UTC
There is many ways how to look at this problem.

It is perfectly OK to have one persistence file with two units. In given example (attached Sample Project) I would argue though that second PU (TestVMPU) should have been defined in separate persistence file stored under tests folder - it is merely a good practice otherwise TestVMPU will get deployed into production which is not desirable (though harmless).

There is not much what EclipseLink can do to prevent this error: the EL annotation processor was instructed to generate metamodel and it is reports error instead of overriding already generated metamodel class which is good thing. Perhaps the EL error message could be more self explanatory to help user realize what's wrong, eg. "Metamodel class yyy.XXX_ already exists and cannot be regenerated. Explanation of the problem is most likely that yyy.XXX class is referenced from more than one PU and annotation processor was executed on both of these PUs. Either process just one PU or configured different output folders for the PUs to avoid filename collision."

NetBeans automatically start JPA annotation processor during the build to generate metamodel classes to make user's life easier. That's good thing but perhaps we should be more careful what we do when multiple PUs are available in a project. Perhaps, and I'm just brainstorming here, we should:
* have a property explicitly listing PUs to use for metamodel generation; and
* store such property in project properties; and
* pass value of that property to "-Aeclipselink.persistenceunits=" (considering 'persistenceunits' is plural it means list of units separate by commas can be passesed, right?); and
* always automatically enable just first PU and keep other ones disabled; and
* (optionally) let user edit this value in visual PU editor (a checkbox at the bottom of each PU section saying "Generate meta model"). That way user can decide which PU to include/exclude.
I would aim for simpler rather than more complex solution because it should not happen too often and with better error description on EL side user should be able to figure out how to address it.  If we learn that lots of users are impacted then we can try to introduce more complex solution.

What do you think?
Comment 21 Sergey Petrov 2010-05-31 10:10:50 UTC
ok, may be we can add subpackage option by default. but also user can do it himself and control it better.
Comment 22 javydreamercsw 2010-05-31 13:25:09 UTC
I understand the TestVMPU comment but still is valid to have multiple persistence units. In my case all PUs are basically duplicates with different database provider targets but this is not always the case. Some times more than one active PU is needed to handle two separate DB's at once or separate parts of the database.

Also cases when the PU is decided at run time would be affected by this proposal and/or would present the same scenario.

I would like to learn what the user could do as Sergey Petrov states...
Comment 23 Quality Engineering 2010-07-03 03:55:31 UTC
Integrated into 'main-golden', will be available in build *201007030001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/9ac1359a9221
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: fix #183779 - just started
Comment 24 javydreamercsw 2010-09-27 16:05:19 UTC
Unable to reproduce in 6.9/6.10 M1
Comment 25 vinh_truong 2010-10-04 21:29:30 UTC
I got same errors in Netbeans 6.10M1:
....
Note: File was not found: META-INF/orm.xml
Note: File was not found: META-INF/eclipselink-orm.xml
Note: File was not found: META-INF/orm.xml
Note: File was not found: META-INF/eclipselink-orm.xml
Comment 26 David Konecny 2010-10-04 21:59:33 UTC
(In reply to comment #25)
> I got same errors in Netbeans 6.10M1:
> ....
> Note: File was not found: META-INF/orm.xml
> Note: File was not found: META-INF/eclipselink-orm.xml
> Note: File was not found: META-INF/orm.xml
> Note: File was not found: META-INF/eclipselink-orm.xml

These are only *notes* and not errors. What exactly is your problem please?
Comment 27 vinh_truong 2010-10-04 22:58:48 UTC
More information:
1/ Using NetBeans 6.10 Build 201010040000
2/ project --> Generate Entity Classes from Database
2/ Generate JSF pages from Entity Classes
3/ Run Clean and Build, got errors:
....
Note: File was not found: META-INF/orm.xml
Note: File was not found: META-INF/eclipselink-orm.xml
Note: File was not found: META-INF/orm.xml
Note: File was not found: META-INF/eclipselink-orm.xml

4/ Go to browser, clicked on Address link, got error:

[EL Info]: 2010-10-04 15:44:02.203--ServerSession(15856458)--EclipseLink, version: Eclipse Persistence Services - 2.1.0.v20100614-r7608
[EL Severe]: 2010-10-04 15:44:02.203--ServerSession(15856458)--Local Exception Stack: 
Exception [EclipseLink-4003] (Eclipse Persistence Services - 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Configuration error.  Class [com.mysql.jdbc.Driver] not found.
        at org.eclipse.persistence.exceptions.DatabaseException.configurationErrorClassNotFound(DatabaseException.java:82)
        at org.eclipse.persistence.sessions.DefaultConnector.loadDriverClass(DefaultConnector.java:267)
        at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:85)
        at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
        at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:579)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:228)
        at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:380)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:157)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:214)
        at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:202)
        at jpa.controllers.AddressJpaController.getEntityManager(AddressJpaController.java:31)
        at jpa.controllers.AddressJpaController.getAddressCount(AddressJpaController.java:126)
        at jsf.classes.AddressController.getPagingInfo(AddressController.java:40)
        at sun.reflect.NativeM
Comment 28 David Konecny 2010-10-05 01:51:33 UTC
Thanks, more comments inlined:

(In reply to comment #27)
> 3/ Run Clean and Build, got errors:
> ....
> Note: File was not found: META-INF/orm.xml
> Note: File was not found: META-INF/eclipselink-orm.xml
> Note: File was not found: META-INF/orm.xml
> Note: File was not found: META-INF/eclipselink-orm.xml

This is really no harm. Just a FYI note.
 
> 4/ Go to browser, clicked on Address link, got error:
> 
> [EL Info]: 2010-10-04 15:44:02.203--ServerSession(15856458)--EclipseLink,
> version: Eclipse Persistence Services - 2.1.0.v20100614-r7608
> [EL Severe]: 2010-10-04 15:44:02.203--ServerSession(15856458)--Local Exception
> Stack: 
> Exception [EclipseLink-4003] (Eclipse Persistence Services -
> 2.1.0.v20100614-r7608): org.eclipse.persistence.exceptions.DatabaseException
> Exception Description: Configuration error.  Class [com.mysql.jdbc.Driver] not
> found.

**com.mysql.jdbc.Driver not found** - MySQL driver is missing in runtime. You have to either include it in your web app or should deploy it to server for all your apps.
Comment 29 javydreamercsw 2011-09-16 19:49:33 UTC
Got the same issue in a different project in 7.1 (part of NetCat program).

Setting javac.compilerargs=-proc:none seems to solve the problem. Should this be handled by the IDE when the eclipse libraries are added, specially the model generator?
Comment 30 Sergey Petrov 2011-09-16 21:18:00 UTC
I'm not sure why it was closed as worksforme, but as it's said above it's multiple pu case, and unfortunately ide do not handle this case automatically, it's user responsibility to add subfolder properties to persistence.xml in current realization (or disable metamodel creation, you do not need to add "proc:none", there should be checkbox in projects's properties). If I got it right it's something between a defect and enhancement request to generate eclipselink.canonicalmodel.subpackage automatically.
Comment 31 javydreamercsw 2011-09-16 21:50:24 UTC
Is there documentation on how to "add subfolder properties to persistence.xml in
current realization". Never heard of that before.
Comment 32 Sergey Petrov 2011-09-16 22:47:05 UTC
you can find sample in eclipselink issue, see comments above

also copy to this issue:
<persistence-unit name="Bar">
   <properties>
    <property name="eclipselink.canonicalmodel.subpackage" value="one"/>
   </properties>
</persistence-unit>
<persistence-unit name="Bar2">
   <properties>
      <property name="eclipselink.canonicalmodel.subpackage" value="two"/>
   </properties>
</persistence-unit>

currently it's required to add these properties manually
Comment 33 David Konecny 2011-09-18 22:39:38 UTC
(In reply to comment #30)
> I'm not sure why it was closed as worksforme

Me neither. :-) I must got distracted by vinh_truong's last exception. Sorry about that.
Comment 34 Sergey Petrov 2011-09-22 03:15:07 UTC
*** Bug 202420 has been marked as a duplicate of this bug. ***
Comment 35 Sergey Petrov 2012-04-20 08:08:34 UTC
*** Bug 210547 has been marked as a duplicate of this bug. ***
Comment 36 Sergey Petrov 2012-04-20 08:10:12 UTC
fails with compilation, may cause scanning slowness also.
as well as automatic subpackage addition, it's nice to mark project/persistence.xml with warning badge to show possible problem with processing of two and more pu without subpackages.
Comment 37 Jesse Glick 2012-05-10 19:23:59 UTC
Created attachment 119315 [details]
stacktrace

Just doing minor edits in the maven module; IDE keeps on restarting scanning. Bogus error badges on MavenSourcesImpl.
Comment 38 Jesse Glick 2012-12-10 17:25:55 UTC
Created attachment 129168 [details]
stacktrace

Various coupling errors and sundry javac exceptions; I just want the IDE to stop trying to rescan my projects, because it does not seem to be able to.
Comment 39 Sergey Petrov 2012-12-10 17:32:13 UTC
It's unclear why last two reports are added to the issue as the issue have no exception reporter link.
Comment 40 rweaver 2013-01-12 23:38:05 UTC
(In reply to comment #2)
> As a workaround add a switch -proc:none into javac.compilerargs into
> project.properties, e.g.javac.compilerargs=-Xlint -Xlint:-serial -proc:none. I
> use this solution in CRUD Sample too.

For a Maven project, these settings work too:

       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <compilerArguments>
                    <endorseddirs>${endorsed.dir}</endorseddirs>
                    <proc:none/>
                    <Xlint/>
                    <Xlint:-path/>
                    <verbose />
                </compilerArguments>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>
Comment 41 Exceptions Reporter 2013-06-11 09:40:33 UTC
This bug already has 50 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=186560
Comment 42 Sergey Petrov 2013-06-11 09:53:32 UTC
I don't see any 'persistence' traces in latest two reports and in some older also, will try to reset into new issue.
Comment 43 Sergey Petrov 2013-06-11 09:58:30 UTC
Also it's unclear why exception reporter attach these exception into this issue.
#231072 is created instead.
return back to last known status before reopening.
Comment 44 David Konecny 2013-06-11 22:47:29 UTC
(In reply to comment #41)
> This bug already has 50 duplicates 
> see http://statistics.netbeans.org/exceptions/detail.do?id=186560

Weird. Just file a report for "ide/Report Exception" to look into it - looks like something got corrupted.
Comment 45 alice16 2015-02-04 03:14:03 UTC
Very Interesting post. very Nice I am very happy to Read this post.. Thanks

Very Interesting post. very Nice I am very happy to Read this post.. Thanks

<a href="http://www.mageewp.com">free wordpress themes</a>		
<a href="http://www.mageewp.com">blog Wordpress themes</a>


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