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.
Using the 'Properties' I have added a Project in the library which has a Persistence Unit and the associated Entity Classes defined. For my current project when I use the 'New' >> 'Persistence' >> 'New JSF Pages from Entity Classes' I am being shown the Available Entity Classes from that other project which has a Persistence Unit in it. I can add those classes as my Selected Entity Classes. However at the same time the wizard insists I have no Persistence Unit and that I must create one. I believe that project 'Properties' >> 'Libraries' added project that has the Entity Classes found and presented for use should also find and use the Persistence Unit.
at first it looks like invalide issue, what do you mean by use of persistemnce unit from library, do you mean extract and pack into main project or just find and know about and consider as existent? I just tried to remove second persistence unit and failed to work with entities from main project on server side. Can you create working example manually? Also what kind of project do you use? I tried ejb module as library and web module as main.
missed issue is about jsf pages, jsf works nice after deletion fro entities from library project and do not work for entities from main project, so wizard may need to be updated to allow jsf creation for entities from library.
I created Java EE >> Enterprise Application Client to contain my Persistence Unit. I made that a stand-alone project for my persistence. I created several entities from my database and a persistence unit. This works great with several other projects. The project I refer to as 'my current project' is a Java Web >> Web Application. Right clicking on this project I selected Properties >> Library. To this library I added the Persistence Unit project from my preceding paragraph. I saved the Properties with the newly added project. As described in my initial bug report when I attempted to create a new JSF Page from my Entity Classes the entities from the persistence project were displayed, but the persistence unit from the same project was not found. I did not want to create a persistence unit attached to the Web Application when I already had a persistence unit defined. I create the error readily from my existing code. I agree that the issue is with the Wizard finding the Persistence Unit in the project in which it found the Entities.
The issue is more complex then just allow usage of pu from libraries, most container managed servers like glassfish prohibit usage of RESOURCE_LOCAL transactions, this way se case above shouldn't work and shouldn't be allowed. Also if library use JTA resources in persistence.xml but was comfigures for another server it may cause some problems only, only in case if library is for this server and use the same transaction type as main project it's ok to use persistence.xml from library and even it's better to use this persistnce.xml rather then local one. Also there is a question what to do with mix of entities from different libraries and from main project with different persistence.xml. Also there may be persistence xml in library but with entities out of PU scope.. As all issues seems hard to address, may be just one checkbox can be added with "Use persistence.xml from library if exist" option. It may cover most usual simple cases. The issue itself may be considered as missed support for PU in libraries and as enhancement request to implement this support. workaround: create new pu with name matching one from library, remove persistence.xml from main(web) project.
*** This issue has been marked as a duplicate of 101556 ***