This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 178108 - IDE does not generate metamodel classes for managed JPA entities
Summary: IDE does not generate metamodel classes for managed JPA entities
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Persistence (show other bugs)
Version: 6.x
Hardware: All All
: P3 normal with 4 votes (vote)
Assignee: Sergey Petrov
URL: http://wiki.eclipse.org/UserGuide/JPA...
Keywords: RELNOTE, UMBRELLA
Depends on: 184952 180935 181459 181861 184378 187653
Blocks:
  Show dependency tree
 
Reported: 2009-12-03 15:03 UTC by David Konecny
Modified: 2013-12-21 04:13 UTC (History)
8 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
patch for build.xml (956 bytes, patch)
2009-12-03 15:11 UTC, David Konecny
Details | Diff
faulty application created with netbeans 6.9 using eclipselink JPA (5.01 MB, application/octet-stream)
2010-04-26 08:39 UTC, mpapamichael
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Konecny 2009-12-03 15:03:15 UTC
BACKGROUND:
Metamodel classes generated for their corresponding managed entities allow construction of object based queries. For example for following JPA entity:

@Entity public class Order {
    @Id 
    Integer id;
    @ManyToOne 
    Customer customer;
    @OneToMany 
    Set<Item> items;
    BigDecimal totalCost;
}

generated metamodel class looks like:

@StaticMetamodel(Order.class)
public class Order_ {
    public static volatile SingularAttribute<Order, Integer> id;
    public static volatile SingularAttribute<Order, Customer> customer;
    public static volatile SetAttribute<Order, Item> items;
    public static volatile SingularAttribute<Order, BigDecimal> totalCost;
}

and using such class allows for queries of the form:

CriteriaBuilder cb = ordersEntityManager.getCriteriaBuilder();
CriteriaQuery<Order> cq = cb.createQuery(Order.class);
SetJoin<Order, Item> itemNode = cq.from(Order.class).join(Order_.orderItems);
cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);

PROBLEM:
IDE does not generate metamodel classes automatically.
Comment 1 David Konecny 2009-12-03 15:11:49 UTC
Created attachment 92073 [details]
patch for build.xml

This patch can be applied to build.xml in Web project
Comment 2 David Konecny 2009-12-03 15:40:23 UTC
SHORT TERM WORKAROUND:
The attached patch is fine tuned for Web project's build.xml. For J2SE project the patch would b every similar. It changes two things:

* defines xmlns:webproject2 namespace (which would be different for J2SE project)

* adds "-pre-compile" target which generates metamodel classes using EclipseLink's Canonical Model Generator (ELUG)

One more steps which has to be done in Web project is to add EclipseLink(JPA2.0) library to project classpath (use Project Properties | Libraries | Add Library)(and if your server already contains EclipseLink then untick "package" checkbox). This library is needed only for compile time and is not required in runtime - annotation processor which generated metamodel classes is used from EclipseLink implementation of JPA2 (class org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor).

Following this workaround building of project will generate metamodel classes which will be shown in project's logical view under "Generated Sources (jpa-metamodel)" node and can be used from regular project's sources, in code completion, etc.
Comment 3 Sergey Petrov 2009-12-07 03:30:02 UTC
what is the best way for generation?
1. keep metamodel in sync with current entities, I don't know about api yet but it may be tricky to update only specific entities instead of all and may cause problems with performance.
2. generate on demand with some menu action.
3. another way.
Comment 4 Petr Jiricka 2009-12-07 04:42:31 UTC
I am assuming this should be a build step executed as a part of the build. Is that right David? One question is what happens with Compile on Save.
Comment 5 Sergey Petrov 2009-12-07 05:16:55 UTC
yes it can be build step and may be should be build step, but user will not be able to reference this classes in code before build then, may be it's ok.
Comment 6 David Konecny 2009-12-07 12:31:48 UTC
At the moment I think that implementation should follow precedence set by Web Services stub generation: it is a build step which produces generated java files to build/generated subfolder (which makes them consequently visible in project's logical view and available in code completion). I tend to think it is acceptable that project has to be build first before classes can be referenced. And if not we can try to improve it later. Other things to evaluate/resolve are:

* will be the metamodel generation hardcoded in project type's build scripts or should Persistence module use AntExtender API and be able to plug metamodel generation into any Ant based project type?

* what needs to be done for Maven?

* should it be configurable to switch metamodel generation on and off in project's UI? If yes where the UI should be so that it is discoverable.

* maybe other issues
Comment 7 Milos Kleint 2009-12-08 03:39:20 UTC
re maven: I haven't really investigated the details but in general we should look for a plugin that generates the file(s). And then add the relevant plugin configuration snippet into the pom.xml file.

from david's patch it looks like additional config for maven-compiler-plugin could be enough, BUT from nbm maven project experience it seems there are some issues with the compiler plugin and annotations.. 
so it just has to be tested..

http://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html
Comment 8 puce 2010-01-02 19:30:11 UTC
What about refactorings? If you want to rename a property, not only the meta model sources (generated) have to change, but all references, too!

This could be tricky...
Comment 9 David Konecny 2010-01-05 13:22:53 UTC
Re. refactoring - good point, refactorings will have to be evaluated. Some of the cases should be easy to handle, for example if user renames Order.items to Order.orderItems then it is easy to apply the same change to generated Order_ class.
Comment 10 Sergey Petrov 2010-01-13 04:02:35 UTC
Is there any refactoring in Web Services stub generation case?
Comment 11 Sergey Petrov 2010-01-15 06:49:40 UTC
I found no refactoring, but I also can't update at all, may be I miss something, for me it seems tricky to support refactoring if online metamodel classes update will not be done (if classes will be [re]generated with build action only).
Comment 12 Sergey Petrov 2010-02-08 06:32:34 UTC
In latest build I was able to add org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor as annotation processor in j2se project properties, but it was required to copy persistence.xml to {proj}/classes/META-INF manually. Metamodel classed was generated with build action.
Comment 13 Sergey Petrov 2010-02-10 08:59:57 UTC
issue related to persistence.xml https://bugs.eclipse.org/bugs/show_bug.cgi?id=302450
Comment 14 Sergey Petrov 2010-02-16 04:10:23 UTC
One of possible solution will be to add checkbox to some wizards, like new PU, or new entities etc, with option "add annotation processor", this will add annotation processor to standard project properties and we will not need special properties for "matamodel generation". 
The only question if we need also separate wizard to add metamodel generation, it may depends on resolution of a problem with persistence.xml if it will require just to add org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor in properties it may not require separate wizard but if some more properties will be required to handle persistence.xml location wizard is good in this case.
Comment 15 Sergey Petrov 2010-02-16 06:54:24 UTC
My last comment is about j2se project, what is missed from realization, others projects should be done the same way, depending of final decision for j2se.
Comment 16 Petr Jiricka 2010-02-16 07:53:48 UTC
Could we just add the annotation processor every time we are creating persistence.xml with EclipseLink 2.0 as the persistence provider, without asking the user? Or is that not desirable for some reason?
Comment 17 Sergey Petrov 2010-02-16 08:14:32 UTC
It's one of solutions. Need to think more if it's not desirable in some cases, may be because annotation processor will require eclipselink library addition in case of web/ejb modules.
Comment 18 David Konecny 2010-02-16 17:41:07 UTC
Yeah, for now I would always automatically add annotation processor whenever JPA implementation library provides one. If later it is a problem (slight impact on build performance maybe?) we can find a way to let users disable it. I expect that most of the times you will simply need it. When designing the solution Sergey, keep in mind that different JPA impls will most likely have different annotation processor class.
Comment 19 Sergey Petrov 2010-02-17 03:18:58 UTC
it's not hard as it can be added as new provider property, most will be null except one for eclipselink v2.0.
Comment 20 Quality Engineering 2010-02-17 21:59:31 UTC
Integrated into 'main-golden', will be available in build *201002180200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/38fb04e38151
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #178108 - now if persistence.xml is created and canonical processor is found it will be added to processors list in j2se, it's not final realization yet, also do not handle persistence.xml location problem
Comment 21 Sergey Petrov 2010-02-18 04:05:48 UTC
tried to use eclipselink.persistencexml to handle a problem with persistence.xml, but it looks thi property do not work with ../something type of paths and also do not work with full path /something.
Comment 22 Quality Engineering 2010-02-18 21:49:11 UTC
Integrated into 'main-golden', will be available in build *201002190200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/29b39bd096d1
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #178108 - minotr modification, move to request processor
Comment 23 Sergey Petrov 2010-02-19 07:46:05 UTC
there will be separate classpath for annotation processors after fix of issue #180935. in case if library isn't required for compile and currently isn't added (as for web project on gf3) it need to be added to processors libraries only.
Comment 24 Quality Engineering 2010-02-21 22:31:07 UTC
Integrated into 'main-golden', will be available in build *201002220200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/8ff017d44819
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #178108 - move to mutex, update ClassPath
Comment 25 Quality Engineering 2010-02-26 23:04:24 UTC
Integrated into 'main-golden', will be available in build *201002270200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ecd0b0a80b14
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #178108 - for web project
Comment 26 Quality Engineering 2010-03-02 22:08:07 UTC
Integrated into 'main-golden', will be available in build *201003030200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/74949e16722d
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #178108 - all options are saved now, also if create pu for web project annotation processor will work now
Comment 27 Petr Jiricka 2010-03-03 07:04:59 UTC
For Maven, the workaround that worked for me (starting with a Web project that already uses persistence, has persistence.xml, has the EclipseLink dependencies etc) is the following:

1. Add a <pluginRepositories> section before the <repositories> section as follows:
    <pluginRepositories>
        <pluginRepository>
            <id>maven-annotation-plugin</id>
            <url>http://maven-annotation-plugin.googlecode.com/svn/trunk/mavenrepo</url>
        </pluginRepository>
    </pluginRepositories>

2. Add the following plugin under build/plugins

           <plugin>
                <groupId>org.bsc.maven</groupId>
                <artifactId>maven-processor-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.eclipse.persistence</groupId>
                        <artifactId>javax.persistence</artifactId>
                        <version>2.0.0</version>
                    </dependency>
                    <dependency>
                        <groupId>org.eclipse.persistence</groupId>
                        <artifactId>eclipselink</artifactId>
                        <version>2.0.0</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>process</id>
                        <goals>
                            <goal>process</goal>
                        </goals>
                        <phase>generate-sources</phase>
                        <configuration>
                            <outputDirectory>${project.build.directory}/generated-sources/apt</outputDirectory>
                            <compilerArguments>-Aeclipselink.persistencexml=src/main/resources/META-INF/persistence.xml</compilerArguments>
                            <processors>
                                <processor>org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor</processor>
                            </processors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

3. Move the dependency on javax.persistence to the first place so it is before the dependency on javaee-web-api. This is because the JPA API classes that are included in javaee-web-api are stub classes without implementations, so they need to be overriden by the API classes in the javax.persistence artifact.

After that, the metamodel classes will be generated. Discovered thanks to this blog:
http://blog.gueck.com/2009/12/generating-jpa-20-criteria-canonical.html

Milos, what do you think about this approach?
Comment 28 Milos Kleint 2010-03-03 10:38:40 UTC
1. the processor thing is probably correct. Is it in 1.6 only or is 1.5 also supported?
once the current trunk of maven-compiler-plugin gets released, we could simplify the setup by depending on compiler plugin on with 1.6
2. the dependency on the googlecode plugin repository  is sort of dangerous.
3. the publishing of signatures in javaee-api artifacts is a major disaster. I think we've expressed that concern at that time, didn't we? the tricks with dependency ordering could be fragile in large scale projects. the fact that it made it's way into central is also sobering..
I was not very happy with one single api jar either..
Comment 29 Quality Engineering 2010-03-03 22:13:46 UTC
Integrated into 'main-golden', will be available in build *201003040200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/f13b50674483
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #178108 add proper library in case "create pu from non new pu wizards"
Comment 30 Petr Jiricka 2010-03-04 09:05:36 UTC
>  Is it in 1.6 only or is 1.5 also supported?

I think we can just limit it to 1.6 and ignore 1.5. Java EE 6 requires JDK 6 anyway, and for the other use cases (Java EE 5 or Java SE), JDK 6 is widely available and should be usable. We should encourage users to always use JDK 6 with JPA 2 - I just filed a related bug 181531.

> once the current trunk of maven-compiler-plugin gets released, we could
> simplify the setup by depending on compiler plugin on with 1.6

Good, any idea when that could be?

> the dependency on the googlecode plugin repository  is sort of dangerous.

Are there any alternatives?

>  the publishing of signatures in javaee-api artifacts is a major disaster.

I agree.
Comment 31 Milos Kleint 2010-03-04 09:14:50 UTC
(In reply to comment #30)
> > once the current trunk of maven-compiler-plugin gets released, we could
> > simplify the setup by depending on compiler plugin on with 1.6
> 
> Good, any idea when that could be?

it's needed for the nb platform annotations as well, so I'd like to have it for the 6.9 release out, but it's an external dependency on the maven folks, I need to convince someone to do the release.

> 
> > the dependency on the googlecode plugin repository  is sort of dangerous.
> 
> Are there any alternatives?

AFAIK not any better ones..

> 
> >  the publishing of signatures in javaee-api artifacts is a major disaster.
> 
> I agree.
Comment 32 Quality Engineering 2010-03-04 22:11:28 UTC
Integrated into 'main-golden', will be available in build *201003050200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/946b5856b925
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #178108 add proper library in case "create pu from non new pu wizards" for missed in previous commit wizards
Comment 33 Quality Engineering 2010-03-08 11:24:24 UTC
Integrated into 'main-golden', will be available in build *201003081350* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/c31180397425
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #178108 added to handle cutom indexer
Comment 34 Sergey Petrov 2010-03-11 08:21:18 UTC
metamodel generation works with bundled eclipselink in j2se/web/ejb/app clien projects now, but j2se and we have extra features and we may need to discuss if the same should be done in ejb/app client ot it should be removed from j2se/web.
j2se and web add canonical processor to processors list in project's properties when ejb/app client do not.
Comment 35 Petr Jiricka 2010-03-11 08:31:27 UTC
I created a new bug 181861 for the Maven-specific part. Let's continue to discuss the Maven aspect in this bug report.
Comment 36 Quality Engineering 2010-03-12 04:29:04 UTC
Integrated into 'main-golden', will be available in build *201003120200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/c3d35d3bf57a
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: #178108 return position to avoid exception from metamodel processor (seems related to pasing not yet copied file), add position for all members in Editor/text/x-java to avoid validation tests failure
Comment 37 Sergey Petrov 2010-03-12 08:56:39 UTC
now all 4 projects should behave the same way, if user use ap list in project properties already, ap will be added to the list, and will not be added if list is empty.
as it's umbrella now, does it mean it should be closed only after all related issues are fixed?
Comment 38 Petr Jiricka 2010-03-12 09:08:17 UTC
Thanks a lot, Sergey! I think we can close this issue now.
Comment 39 Sergey Petrov 2010-03-12 09:19:09 UTC
fixed
Comment 40 Sergey Petrov 2010-04-09 17:00:53 UTC
reopen after fix #183473 but -> as it should be easy to add ap processor in project properties now.
Comment 41 Petr Jiricka 2010-04-14 21:55:14 UTC
Anyway, until the EL issue is fixed, I think the right approach should be to enable this for Ant build, but disable in the editor.
Comment 42 Sergey Petrov 2010-04-15 05:23:50 UTC
It will generate metamodel but it will not be possible to use it in netbeans because of compile on save/deploy on save problems.
Comment 43 mpapamichael 2010-04-23 08:17:11 UTC
A QUICK QUESTION. what changes do i have to do to to the patch for it to work in a console application enviroment?
Thanks in advance.
Comment 44 Sergey Petrov 2010-04-23 08:27:13 UTC
if you'll add eclipselink-jpa-modelgen_2.0.1.v20100213-r6600.jar from eclipselink distribution to classpath, metamodel will be generated.
Comment 45 mpapamichael 2010-04-23 10:37:06 UTC
thank you for your quick response, 

when i built i get the following error

"Caused by: java.lang.RuntimeException: Unable to load persistence.xml : C:\Websites\DATAImporter\build\classes\META-INF\persistence.xml (The system cannot find the path specified)"

when i add "\classes\META-INF\persistence.xml" it creates the metamodels in the classes directory but i can not still reference them.

when i clean and built it all gone including "\classes\META-INF\persistence.xml"

am i missing something here?

thanks again

(In reply to comment #44)
> if you'll add eclipselink-jpa-modelgen_2.0.1.v20100213-r6600.jar from
> eclipselink distribution to classpath, metamodel will be generated.
Comment 46 Sergey Petrov 2010-04-23 11:13:51 UTC
I'm not sure what console application do you use, is it j2se application created in netbeans?
what build do you use?
Comment 47 mpapamichael 2010-04-23 12:15:02 UTC
Hi,

thanks for your response.

yes i am using java se console application generated from netbeans 6.8.
And i am building using the default build command that comes with netbeans. I assume netbeans is using the ant command to build.

i am pasting the error log from netbeans after build command.



init:
deps-clean:
Updating property file: C:\Websites\DataImporter\build\built-clean.properties
Deleting directory C:\Websites\DataImporter\build
clean:
init:
deps-jar:
Created dir: C:\Websites\DataImporter\build
Updating property file: C:\Websites\DataImporter\build\built-jar.properties
Created dir: C:\Websites\DataImporter\build\classes
Created dir: C:\Websites\DataImporter\build\empty
Compiling 37 source files to C:\Websites\DataImporter\build\classes
Note: Creating the metadata factory ...
Note: Building metadata class for round element: EntitieControllers.DetailsJpaController

.............

Note: Building metadata class for round element: entities.Users

error: java.lang.RuntimeException: Unable to load persistence.xml : C:\Websites\DataImporter\build\classes\META-INF\persistence.xml (The system cannot find the path specified)
Note: org.eclipse.persistence.internal.jpa.modelgen.objects.PersistenceUnitReader.getInputStream(PersistenceUnitReader.java:105)
Note: org.eclipse.persistence.internal.jpa.modelgen.objects.PersistenceUnitReader.initPersistenceUnits(PersistenceUnitReader.java:160)
Note: org.eclipse.persistence.internal.jpa.modelgen.objects.PersistenceUnitReader.<init>(PersistenceUnitReader.java:63)
Note: org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process(CanonicalModelProcessor.java:328)
Note: com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:624)
Note: com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:553)
Note: com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:698)
Note: com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:981)
Note: com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
Note: com.sun.tools.javac.main.Main.compile(Main.java:353)
Note: com.sun.tools.javac.main.Main.compile(Main.java:279)
Note: com.sun.tools.javac.main.Main.compile(Main.java:270)
Note: com.sun.tools.javac.Main.compile(Main.java:69)
Note: sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Note: sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Note: sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Note: java.lang.reflect.Method.invoke(Method.java:597)
Note: org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:56)
Note: org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1065)
Note: org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:882)
Note: org.netbeans.modules.java.source.ant.JavacTask.execute(JavacTask.java:120)
Note: org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
Note: sun.reflect.GeneratedMethodAccessor472.invoke(Unknown Source)
Note: sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Note: java.lang.reflect.Method.invoke(Method.java:597)
Note: org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
Note: org.apache.tools.ant.Task.perform(Task.java:348)
Note: org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
Note: org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
Note: sun.reflect.GeneratedMethodAccessor472.invoke(Unknown Source)
Note: sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Note: java.lang.reflect.Method.invoke(Method.java:597)
Note: org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
Note: org.apache.tools.ant.Task.perform(Task.java:348)
Note: org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:394)
Note: org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
Note: sun.reflect.GeneratedMethodAccessor472.invoke(Unknown Source)
Note: sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
Note: java.lang.reflect.Method.invoke(Method.java:597)
Note: org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
Note: org.apache.tools.ant.Task.perform(Task.java:348)
Note: org.apache.tools.ant.Target.execute(Target.java:357)
Note: org.apache.tools.ant.Target.performTasks(Target.java:385)
Note: org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
Note: org.apache.tools.ant.Project.executeTarget(Project.java:1306)
Note: org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
Note: org.apache.tools.ant.Project.executeTargets(Project.java:1189)
Note: org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:278)
Note: org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:498)
Note: org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)


An annotation processor threw an uncaught exception.
Consult the following stack trace for details.
java.lang.RuntimeException: java.lang.RuntimeException: Unable to load persistence.xml : C:\Websites\DataImporter\build\classes\META-INF\persistence.xml (The system cannot find the path specified)
        at org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process(CanonicalModelProcessor.java:365)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:624)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:553)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:698)
        at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:981)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
        at com.sun.tools.javac.main.Main.compile(Main.java:353)
        at com.sun.tools.javac.main.Main.compile(Main.java:279)
        at com.sun.tools.javac.main.Main.compile(Main.java:270)
        at com.sun.tools.javac.Main.compile(Main.java:69)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:56)
        at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1065)
        at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:882)
        at org.netbeans.modules.java.source.ant.JavacTask.execute(JavacTask.java:120)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor472.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:62)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor472.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:394)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor472.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
        at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:278)
        at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:498)
        at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
Caused by: java.lang.RuntimeException: Unable to load persistence.xml : C:\Websites\DataImporter\build\classes\META-INF\persistence.xml (The system cannot find the path specified)
        at org.eclipse.persistence.internal.jpa.modelgen.objects.PersistenceUnitReader.getInputStream(PersistenceUnitReader.java:105)
        at org.eclipse.persistence.internal.jpa.modelgen.objects.PersistenceUnitReader.initPersistenceUnits(PersistenceUnitReader.java:160)
        at org.eclipse.persistence.internal.jpa.modelgen.objects.PersistenceUnitReader.<init>(PersistenceUnitReader.java:63)
        at org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor.process(CanonicalModelProcessor.java:328)
        ... 46 more
C:\Websites\DataImporter\nbproject\build-impl.xml:413: The following error occurred while executing this line:
C:\Websites\DataImporter\nbproject\build-impl.xml:199: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)

(In reply to comment #46)
> I'm not sure what console application do you use, is it j2se application
> created in netbeans?
> what build do you use?
Comment 48 mpapamichael 2010-04-23 12:17:51 UTC
One more thing.

if i add the patch it doesnt built at all.

thanks in advance
Comment 49 Sergey Petrov 2010-04-23 13:54:36 UTC
For 6.8 more changes may be required, all I said before is 6.9 dev/beta related.
Some properties/paths may be missed.
Comment 50 mpapamichael 2010-04-23 14:09:40 UTC
ok thanks, so i will have to download and install beta then.

thank you very much.

(In reply to comment #49)
> For 6.8 more changes may be required, all I said before is 6.9 dev/beta
> related.
> Some properties/paths may be missed.
Comment 51 mpapamichael 2010-04-24 12:02:47 UTC
I managed to install netbeans 6.9 beta. I imported a web application and a console application i been working on. I also added eclipselink-jpa-modelgen_2.0.1.v20100213-r6600.jar in the classpath.

Now i have 2 issues.

1) the web application generates the metamodels same as this patch_for_build.xml, but it still does not build. it seems that it can not find the metamodels(where i import them it sais "can not find symbol"). this is an application which i been working on using the above patch and it worked very good using netbeans 6.8.

2)using the console application, i have the same issue, but the metamodels are not visible in the project tab. i can only find them in files tab.

i also had a serious issue with glassfish on netbeans 6.8(could not start it), it seems fixed on this new beta version :)

thanks in advance.  

(In reply to comment #49)
> For 6.8 more changes may be required, all I said before is 6.9 dev/beta
> related.
> Some properties/paths may be missed.
Comment 52 mpapamichael 2010-04-24 12:28:08 UTC
sorry what i was ment to say, my web application builds but i can not deploy. cause of metamodels not found.
Comment 53 Sergey Petrov 2010-04-24 18:03:11 UTC
yes, it's an issue considered as a feature, but may be there is an issue with update of old projects,
jpa2.0/annotation processor suppose source level is jdk6, update your project properties to jdk6.
Also see compile section if both checkboxes related to ap ae selected.
Comment 54 mpapamichael 2010-04-24 22:39:51 UTC
Thank you, that was the main issue with the console application, i was using jdk5. my web app was already using jdk6.

now for my final issue. the entity metamodels after a "clean and build" are created in a folder called "Generated Sources (ap-source-output)". when i try to deploy my project(I am refering to my web application, i get a similar issue in my console app, which in this case it does not run) I get the these messages.

"Caused by: java.lang.RuntimeException: Uncompilable source code - cannot find symbol
  symbol:   class Customer_
  location: package Entities"

i get the same error where for all the instances where i import my metamodel (etc: import Entities.Customer_;)classes. it seems my app can not read from the "generated sources(ap-source-output)/Entities" folder. is this an issue within netbeans 6.9 or am i missing another configuration somewhere.

in netbeans 6.8 i didnt have this issue, after the metamodel generation it was building and deployed fine.

is this feature going to be implemented in the final release on netbeans 6.9 in june?

thanks in advance

mike

(In reply to comment #53)
> yes, it's an issue considered as a feature, but may be there is an issue with
> update of old projects,
> jpa2.0/annotation processor suppose source level is jdk6, update your project
> properties to jdk6.
> Also see compile section if both checkboxes related to ap ae selected.
Comment 55 Sergey Petrov 2010-04-25 16:15:26 UTC
do you have "support ap ineditor" checkbox selected?
if yes, can you attach sample project[s]?
Comment 56 mpapamichael 2010-04-25 16:46:14 UTC
thanks for your response

where can i find this "support ap in editor" checkbox?

thanks 

(In reply to comment #55)
> do you have "support ap ineditor" checkbox selected?
> if yes, can you attach sample project[s]?
Comment 57 mpapamichael 2010-04-25 19:13:30 UTC
sorry i just realised what u ment. you were referring to "enable annotation processing in editor". yes its ticked.

when i get the chance i will sent you sample application.

i was reading the following bug
https://netbeans.org/bugzilla/show_bug.cgi?id=183779
and i realised i get a very similar warning too.

"Note: Building metadata class for round element: jdbc.DataAccessor
Note: File was not found: META-INF/orm.xml
Note: File was not found: META-INF/eclipselink-orm.xml"

i will send you the sample app sometime tomorrow




(In reply to comment #56)
> thanks for your response
> 
> where can i find this "support ap in editor" checkbox?
> 
> thanks 
> 
> (In reply to comment #55)
> > do you have "support ap ineditor" checkbox selected?
> > if yes, can you attach sample project[s]?
Comment 58 Sergey Petrov 2010-04-26 08:13:17 UTC
It will be good if you will attach to the issue, but if you can't share you can sent by e-mail.

>is this feature going to be implemented in the final release on netbeans 6.9 in
june?

it's expected to work in beta but looks like there is an issue, should be fixed in release.
Comment 59 mpapamichael 2010-04-26 08:39:24 UTC
Created attachment 98000 [details]
faulty application created with netbeans 6.9 using eclipselink JPA
Comment 60 mpapamichael 2010-04-26 08:43:33 UTC
i created another web application using 6.9, this app has only one entity. also
you can find the sql to create this entity.

thanks

(In reply to comment #59)
> Created an attachment (id=98000) [details]
> faulty application created with netbeans 6.9 using eclipselink JPA
Comment 61 Sergey Petrov 2010-04-26 10:05:46 UTC
thanks, easily reproducible, looks like a regression in beta
Comment 62 Sergey Petrov 2010-04-26 11:06:45 UTC
ok, with attached sample project there are two problems
 - networkID do not exist, but after change to pageID I can buyild the project
 - ap in editor do not work even it's selected and it can be workarounded by switch off "Deploy on save" in projects's properties, and also need to be investigated/fixed in nb.
Comment 63 mpapamichael 2010-04-26 12:29:11 UTC
sorry about the networkID its not supposed to be there, it was a bad copy and paste.

"Deploy and save" did the work.  it can be deployed now. :)
i assume i can continue working on my project now using 6.9. 

will you be able to let me know throught this post when its fixed so i can download the latest build? 

Thanks for your help.

(In reply to comment #62)
> ok, with attached sample project there are two problems
>  - networkID do not exist, but after change to pageID I can buyild the project
>  - ap in editor do not work even it's selected and it can be workarounded by
> switch off "Deploy on save" in projects's properties, and also need to be
> investigated/fixed in nb.
Comment 64 Sergey Petrov 2010-04-26 12:48:51 UTC
yes, the issue will be updated.

you can also add eclipselink with model jar to Processor libraries instead of Compile
Comment 65 mpapamichael 2010-04-26 14:14:10 UTC
thanks i will give it a try

(In reply to comment #64)
> yes, the issue will be updated.
> 
> you can also add eclipselink with model jar to Processor libraries instead of
> Compile
Comment 66 Tomas Zezula 2010-04-27 15:30:03 UTC
Fixed deleted persistence.xml in allFilesIndexing.
jet-main ab974a41cfd7
Comment 67 mpapamichael 2010-04-27 16:33:40 UTC
Thanks for the update.

how do i get the updated version of netbean? download the latest development build?

(In reply to comment #66)
> Fixed deleted persistence.xml in allFilesIndexing.
> jet-main ab974a41cfd7
Comment 68 Tomas Zezula 2010-04-27 16:43:08 UTC
It's not so easy, first it will take some time to propagate the patch from jet-main repository to golden-main from which the night builds are done (mostly it takes a day). Then it will be available in the dev (night) build.
Comment 69 mpapamichael 2010-04-27 16:47:26 UTC
thanks for your respose,

so i have to wait and download tomorrows night build then.

(In reply to comment #68)
> It's not so easy, first it will take some time to propagate the patch from
> jet-main repository to golden-main from which the night builds are done (mostly
> it takes a day). Then it will be available in the dev (night) build.
Comment 70 Tomas Zezula 2010-04-27 17:16:52 UTC
Fixed missed persistence.xml change.
jet-main a8fb9f0b3823
Comment 71 Sergey Petrov 2010-04-28 08:21:29 UTC
tested in web-main and it works for attached project after resolving missed references, thanks.
it's in main-golden already and should be in next nightly.
Comment 72 mpapamichael 2010-04-28 13:29:59 UTC
thanks surgey,

i will download as as soon as is available.
there is one more thing i would to ask. when iam importing an innodb database with relationships. there is a small issue with the @ManyToOne relationships naming conversion.

for example:

private Person personID;

isnt it more correct to be renamed automatically to the following? 

private Person person.

because everytime new entities are created by netbeans i have to go and change  the all the manytoone and onetomany variables and getter setters.

i assume this is on the eclipselink site instead of netbeans.

Am i correct?

(In reply to comment #71)
> tested in web-main and it works for attached project after resolving missed
> references, thanks.
> it's in main-golden already and should be in next nightly.
Comment 73 Sergey Petrov 2010-04-28 13:37:02 UTC
It should be netbeans issue, but I'm not sure if it's an issue yet, is there any problems with personID?
Comment 74 mpapamichael 2010-04-28 20:16:43 UTC
thanks for your response,

for example 
if there is a @manytoone relationship between between an address entity and a person entity.

using Expression Language in jsf file, if we want to access the PersonId with out any changes after entity generation we have to write
address.details.personID.personID but what is the logical way to write is address.details.person.personID.

i just created entities using a relational database i have in innodb and i check all the entities generated, i found out that i have an entity with a combined primaryID, and all its fields and getter and setters are generated the way its supposed to be, i will paste a couple of lines.

public class Tarrif implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TarrifPK tarrifPK;
   

    @JoinColumn(name = "CallDestinationID", referencedColumnName = "CallDestinationID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Calldestination calldestination;
    @JoinColumn(name = "CallEventID", referencedColumnName = "CallEventID", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Callevent callevent;
 
    //more many to one attributes 

    public Tarrif() {
    }

    public Tarrif(TarrifPK tarrifPK) {
        this.tarrifPK = tarrifPK;
    }


    public Calldestination getCalldestination() {
        return calldestination;
    }

    public void setCalldestination(Calldestination calldestination) {
        this.calldestination = calldestination;
    }

    public Callevent getCallevent() {
        return callevent;
    }

    public void setCallevent(Callevent callevent) {
        this.callevent = callevent;
    }

    
    //more manytoone getter and setters


   i will now paste a couple of lines from a normal entity without a compine key



(In reply to comment #73)
> It should be netbeans issue, but I'm not sure if it's an issue yet, is there
> any problems with personID?
Comment 75 mpapamichael 2010-04-28 20:36:28 UTC

 thanks for your response,

for example 
 if there is a @manytoone relationship between between an address entity and a
person entity.
 
 using Expression Language in jsf file, if we want to access the PersonId with
 out any changes after entity generation we have to write> address.details.personID.personID but what is the logical way to write is
 address.details.person.personID.
 
 i just created entities using a relational database i have in innodb and i
 check all the entities generated, i found out that i have an entity with a
 combined primaryID, and all its fields and getter and setters are generated the
 way its supposed to be, i will paste a couple of lines.
 
 public class Tarrif implements Serializable {
     private static final long serialVersionUID = 1L;
     @EmbeddedId
     protected TarrifPK tarrifPK;
 
 
     @JoinColumn(name = "CallDirectionID", referencedColumnName =
 "CallDirectionID", nullable = false, insertable = false, updatable = false)
     @ManyToOne(optional = false)
     private Calldirection calldirection;
     @JoinColumn(name = "CallEventID", referencedColumnName = "CallEventID",
 nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
     private Callevent callevent;
 
    //more many to one attributes 
 
     public Tarrif() {
     }

     public Tarrif(TarrifPK tarrifPK) {
        this.tarrifPK = tarrifPK;
    }
 
 
     public Calldirection getCalldirection() {
         return calldirection;
     }
 
     public void setCalldirection(Calldirection calldirection) {
        this.calldirection= calldirection;
     }
 
     public Callevent getCallevent() {
         return callevent;
     }
 
     public void setCallevent(Callevent callevent) {
         this.callevent = callevent;
     }
 
 
     //more manytoone getter and setters
 
 
    i will now paste a couple of lines from a normal entity without a compinekey 

public class Calldirection implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "CallDirectionID", nullable = false)
    private Integer callDirectionID;
    @Basic(optional = false)
    @Column(name = "CallDirectionName", nullable = false, length = 255)
    private String callDirectionName;
    @JoinColumn(name = "NetworkID", referencedColumnName = "NetworkID", nullable = false)
    @ManyToOne(optional = false)
    private Network networkID;

   public Calldirection() {
    }

    public void setDisplay(Boolean display) {
        this.display = display;
    }

    public Network getNetworkID() {
        return networkID;
    }

..................................

the Calldirection entity's manytoone attributes should be generated the same way as teh tarrif entity.(for example 

private Network networkId => private Network network  isn't that correct? 

thanks in advance
Comment 76 Sergey Petrov 2010-04-29 09:27:36 UTC
It may be better to open new one issue, for this case.
I need to recheck with specification but it looks like just a usability issue, if it cause no fails.
Comment 77 mpapamichael 2010-04-29 10:53:43 UTC
thanks, it can be very helpful and time saving specially when creating entities from a very large database with complex relationships. i assume this issue its going to be opened at your end correct?


(In reply to comment #76)
> It may be better to open new one issue, for this case.
> I need to recheck with specification but it looks like just a usability issue,
> if it cause no fails.
Comment 78 rjdkolb 2010-05-03 11:57:02 UTC
(In reply to comment #27)
> For Maven, the workaround that worked for me (starting with a Web project that
> already uses persistence, has persistence.xml, has the EclipseLink dependencies
> etc) is the following:
<snip>

Thanks you Petr Jiricka! :)
Works first time
Comment 79 Petr Jiricka 2010-05-03 13:03:10 UTC
You are welcome, but note that this approach has problems if you have tests in your project. A newer approach is now possible, see bug 181861 where the Maven aspect is tracked separately.
Comment 80 Sergey Petrov 2010-05-20 09:05:57 UTC
http://hg.netbeans.org/web-main/rev/6297551e6111

eclipselink is upgraded to 2.1.0-M7.
Comment 81 mpapamichael 2010-05-26 08:49:42 UTC
hi i installed the latest development build(20100525001), this version has the same issue as per our previous descussion. it builds but it does not deploy after metamodel generation. in order to deploy i have to tick Run/Deploy on save.

thanks

(In reply to comment #53)
> yes, it's an issue considered as a feature, but may be there is an issue with
> update of old projects,
> jpa2.0/annotation processor suppose source level is jdk6, update your project
> properties to jdk6.
> Also see compile section if both checkboxes related to ap ae selected.
Comment 82 Petr Jiricka 2010-05-26 09:18:19 UTC
Thanks for the heads up - but could you please file this problem as a separate bug report, so we don't mix too many things in one report? Thanks.
Comment 83 Sergey Petrov 2010-06-24 09:58:54 UTC
should be fixed now with bundled el 2.1.0 http://hg.netbeans.org/web-main/rev/894a6fea51ab

we may need to decide if it need to be ported to 6.9.1 having in mind issues like #187653 and may be more.
Comment 84 Petr Jiricka 2010-06-24 13:25:43 UTC
Thanks - and you are right, bug 187653 is really nasty and we probably don't want to put this in 6.9.1 because of this bug.
Comment 85 Tomas Zezula 2010-06-24 13:33:54 UTC
We was able to decrease the impact of the bug 187653 by caching the processor. This also significantly speeds up the class generation but there is still the memory leak (VM issue).
Comment 86 Quality Engineering 2010-06-25 03:15:45 UTC
Integrated into 'main-golden', will be available in build *201006250001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/894a6fea51ab
User: Sergey B. Petrov <sj-nb@netbeans.org>
Log: fix #178108 uupdate to el 2.1.0 release