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.
Summary: | New Entity Class wizard does not add JPA API to the classpath (EE 5 + WebLogic) | ||
---|---|---|---|
Product: | javaee | Reporter: | Petr Jiricka <pjiricka> |
Component: | Persistence | Assignee: | Sergey Petrov <sj-nb> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | phejl |
Priority: | P2 | ||
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: |
Description
Petr Jiricka
2010-08-09 16:34:54 UTC
Do you have any samples where api is added? JPA wizards add provider libraries only if available/bundled with nb. may be I have never saw usage of "default provider" before. > 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) may be, I need to investigate a bit more to be sure 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. 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? Initial fix in web-main 1fd9f19bcbef. (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. 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. 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) 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? 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? 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. (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. 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?
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? 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. 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? > 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?
>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?
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. 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? > 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. |