Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 189326 - New Entity Class wizard does not add JPA API to the classpath (EE 5 + WebLogic)
New Entity Class wizard does not add JPA API to the classpath (EE 5 + WebLogic)
Status: RESOLVED FIXED
Product: javaee
Classification: Unclassified
Component: Persistence
6.x
All All
: P2 (vote)
: 7.0
Assigned To: Sergey Petrov
issues@javaee
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-08-09 16:34 UTC by Petr Jiricka
Modified: 2010-08-26 13:59 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Jiricka 2010-08-09 16:34:54 UTC
1. Create a new Java EE 5 Maven Web Application
2. Set the target server to WebLogic
3. Create a new Entity Class from template (use default persistence provider)

The JPA API is not added to classpath, so the imports have red underlines, and the project does not compile.
Comment 1 Sergey Petrov 2010-08-11 12:48:06 UTC
Do you have any samples where api is added?
JPA wizards add provider libraries only if available/bundled with nb.
Comment 2 Sergey Petrov 2010-08-11 12:52:45 UTC
may be I have never saw usage of "default provider" before.
Comment 3 Petr Jiricka 2010-08-11 13:24:22 UTC
> Do you have any samples where api is added?

For Entities from Database, it is added.

> may be I have never saw usage of "default provider" before.

You are right that for GlassFish (both 3.1 and v2) the label with the default provider refers to the particular product (e.g. EclipseLink), for WebLogic it is just labeled as <Default Provider>. Is this something that needs to be changed on the plugin side? (cc'ing Petr H)
Comment 4 Sergey Petrov 2010-08-11 13:35:38 UTC
may be, I need to investigate a bit more to be sure
Comment 5 Sergey Petrov 2010-08-11 15:49:07 UTC
Hk2JavaEEPlatformImpl (J2eePlatformImpl implementation for glassfish)
provide next way to get default provider in @public boolean isToolSupported(String toolName):

       if("eclipseLinkPersistenceProviderIsDefault".equals(toolName)) {
            return true;
        }

There is no information regarding default provider from WLJ2eePlatformFactory, only existence of default provider is declared, which one is used as default by weblogic?

On other side if I create pu/and entities in web project on gf no api will be for default provider. And it seems appropriate as default one api is already on classpath and I see the same for weblogic (javax.persistence1* jars on classpath). So it's likely an issue to add some api in some cases for default provider but it may be an issue related to missed information regarding whcih one is default.
Comment 6 Petr Jiricka 2010-08-12 09:59:04 UTC
Just discussed this with Petr H, he says that changes should be done on the WebLogic plugin side, to provide the information about the default provider. (This will require finding out which implementation - Kodo or TopLink - is set as default for the domain.) So Petr, should this be assigned to you for this subtask?
Comment 7 Petr Hejl 2010-08-12 11:24:20 UTC
Initial fix in web-main 1fd9f19bcbef.
Comment 8 Petr Hejl 2010-08-12 11:26:07 UTC
(In reply to comment #6)
> Just discussed this with Petr H, he says that changes should be done on the
> WebLogic plugin side, to provide the information about the default provider.
> (This will require finding out which implementation - Kodo or TopLink - is set
> as default for the domain.) So Petr, should this be assigned to you for this
> subtask?

Yes. I need to find a way to get the default provider.
Comment 9 Petr Hejl 2010-08-12 14:48:28 UTC
Serverplugin part fixed in web-main d2ee02ca3b31.

Couple of notes
- Although admin console offers Kodo/Toplink in fact is OpenJPA/EclipseLink - at least on 10.3.4
- The UI reports 2.0 versions which is wrong. This is because PersistenceProviderSuppliers such as WebPersistenceProviderSupplier do not really care about the level supported by the default provider (at the time of dialog creation). The created persistence unit spec level however correctly matches the API on classpath (which is 1.0). I think suppliers should use this information to display the proper version in combo. In worse case we can add some constant like "defaultPersistenceProviderJPA1Only" which suppliers would use and respect. 

Passing this to Sergey.
Comment 10 Quality Engineering 2010-08-13 03:08:32 UTC
Integrated into 'main-golden', will be available in build *201008130001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/1fd9f19bcbef
User: Petr Hejl <phejl@netbeans.org>
Log: #189326 New Entity Class wizard does not add JPA API to the classpath (EE 5 + WebLogic)
Comment 11 Sergey Petrov 2010-08-13 12:28:31 UTC
regarding addition of api, it's the way it works if application is container managed and default provider is used then no api is added if application is self-managed or non default provider is selected provider jars are added if available.
Is it required to add api even for default provider in case of web logic?
Should it be special case for weblogic or for all cases?
Comment 12 Petr Hejl 2010-08-13 12:41:33 UTC
Original issue is still reproducible - note it is maven project. The provided scope dependencies are not added for WL. For GF everything works as expected (pom.xml is modified to mention the api's with provided scope). Is there anything weblogic should do?
Comment 13 Sergey Petrov 2010-08-13 12:45:46 UTC
Missed it's something with maven project but looks strange if for maven dependencies are added when for ant are not added (in case of gf). Will test.
Comment 14 Petr Hejl 2010-08-13 12:53:33 UTC
(In reply to comment #13)
> Missed it's something with maven project but looks strange if for maven
> dependencies are added when for ant are not added (in case of gf). Will test.

I guess it's ok because in ant case the API is already on server classpath and the ant project requires the server to be assigned.
Comment 15 Sergey Petrov 2010-08-13 13:01:43 UTC
ok, dependencies are added in case of maven web project targeted gf3.
but I'm not sure if the issue is no added dependncies in case of web logic or added dependencies in case of gf3.
 it's first question. second one, nb add dependencies only for known libraries, but for openjpa only provider is known without any library information. In this realization openjpa dependencies can't be added, but realization can be changed.

One more solution is to add clear persistence api for jpa2 and use already existent jpa1 api and add it in all cases where now libraries are not added if there is no api on classpath. But it may cause scanning delays even in simple persistence.xml creation. Also I'm not sure someone would like to have jpa1.0 ibrary added to the project on weblogic as if got it right jpa1.0 is already in classpath on weblogic.

Any ideas?

> guess it's ok because in ant case the API is already on server classpath
do you mean is maven project is used api is not on server classpath?
Comment 16 Sergey Petrov 2010-08-13 13:14:15 UTC
may be I miss some maven feature.
If maven project have dependency, how it will be handled on deployment, in case of gf3+maven+eclipselink, will it deploy eclipselink with the project?
Comment 17 Sergey Petrov 2010-08-13 13:17:12 UTC
Just made a small verification, for the project purpose it's not required to add eclipselink dependencies also as javax.persistence api is contained in javaee-web-api-6.0.jar.

Looking forward for more ideas what behavior is expected in each case.
Comment 18 Sergey Petrov 2010-08-13 13:25:46 UTC
Ok, was mixed a bit, ee6 jars work only for ee6 projects in case of ee5 project here is no common api jar and addition of providers to dependencies may have sense, it likely do not work for default openjpa only because we do not have openjpa module with libraries for ant project and pom specifications. Is it an issue?
Comment 19 Petr Jiricka 2010-08-13 17:13:58 UTC
> Original issue is still reproducible

Well I can no longer reproduce it after the latest changes. For me, the pre-selected persistence provider is now "EclipseLink(JPA 2.0)(default)". [As an aside, this is still not quite correct, as for WLS it should be JPA 2.0, and currently persistence.xml is incorrectly generated as version 2.0. But that's a separate problem.]

After this, the JPA dependencies are added to the classpath. I would assume that the IDE is looking at the pom volume of the JPA provider library, right? So if it can not determine what is the default provider, it does not know what to add.

So, you are saying you can still reproduce? What is the exact behavior for you?
Comment 20 Sergey Petrov 2010-08-17 08:41:44 UTC
>After this, the JPA dependencies are added to the classpath. I would assume
that the IDE is looking at the pom volume of the JPA provider library, right?

For ant project, default provider libraries(if available) are added to processors classpath only, in case of maven addition to processors classpath seems to add dependencies to usual classpath. Is it really required to fix {subj}? Does it mean behavior should be differnt for ant/maven or I miss something and api is added in case of ant?
Comment 21 Sergey Petrov 2010-08-18 07:38:31 UTC
Just verified it's really on compile classpath in maven instead of just processor classpath. I'm able to build an application with specific eclipselink classes.
Comment 22 Sergey Petrov 2010-08-23 11:11:42 UTC
What I see now,
in case of ant - web project have weblogic api on classpath and the api includes persistence api.
in case of maven+javaee6, there is javaee6 api dependency and this api includes persistence api
in case of javaee5+maven, there is only jsp and servlet api dependency, and as side effect of unrecognized difference between processor classpath and compile classpath eclipselink api(include persistence api) can be added to dependencies.

In my opinion, jpa api should be in dependencies right after project creation as it's in javaee6 and as it's for servlets and jsps api. Is it an option?
Comment 23 Petr Jiricka 2010-08-26 13:59:29 UTC
> Is it really required to fix {subj}? 

Not necessarily, I think this could stay as it is now if it does not cause user visible problems.

> Does it mean behavior should be different for ant/maven

Possibly. Ant and Maven are different build systems, so the behavior could be different.

> In my opinion, jpa api should be in dependencies right after project creation
> as it's in javaee6 and as it's for servlets and jsps api. Is it an option?

I don't think this would be too helpful. The nature of Maven is that you are allowed to add any dependencies in pom, and the IDE must be able to read in your project and work with it. So we would still need to count with projects that do not have JPA API on the classpath. In fact, some people say that we should go back to the fine granularity of individual Java EE APIs and not have the monolitic ee6-api and ee6-web-api jar files. I know that Spring is packaging Java EE APIs in their Maven repository, and they are doing it this way.

Anyway, since the original report is fixed, I am marking this as fixed. If there are additional problems and if it is desirable to make any other changes in the behavior, let's file separate issues.


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