persistence@glassfish.java.net

Re: Netbeans 5.5 Persistance issue with MySQL

From: Rajesh Chenji <Rajesh.Chenji_at_Sun.COM>
Date: Wed, 10 Jan 2007 19:05:00 +0530

Hi All,

Thanks for your valuable suggestions.The customer resolved his issue,but
he wants some advices for his project.

Customer Requirements :

The content of your answer/suggestion made me wonder whether I was trying to implement a sensible structure in my Library2 Enterprise Application project.
In formulating questions that I had arising from your answer/response I discovered that I had not in fact completely replicated the structure from the project which
worked ok, i.e. Library using the built-in App. Server jdbc/sample data source.

Adding the omission has solved the problem raised with you initially. However, I would be very grateful if you could cast an eye over the structure that I am
proposing to use, and build upon, and let me have any criticism you may have.

In my WAR module I have created a separate, uniquely named Persistence Unit containing the fully qualified names of the classes that get persisted using
the EJB module

  <persistence-unit name="Library2-warPU" transaction-type="JTA">

    <jta-data-source>jdbc/myDS2</jta-data-source>

    <class>library2.model.Book</class>

    <class>library2.model.Libmem</class>

    <class>library2.model.Reservation</class>

    <exclude-unlisted-classes>true</exclude-unlisted-classes>

    <properties/>

  </persistence-unit>

</persistence>

As previously mentioned, I modify the JSF page statements generated by NetBeans from the above Persistence Unit so that only the standard CRUD operations
can be performed. The statements derived from Entity associations have been deleted.

My next step, where I am anxious to avoid problems arising from my structure choice, is to expand the WEB module operations by creating my own Managed Beans
 and linking these, using annotations, to Session Beans in my EJB module.

I would be most grateful if you could supplement the very useful and timely support that you have offered already with some comment re my Enterprise Application
structure plans.


Can any one suggest on this?

Regards

Rajesh Chenji



Erno Mononen wrote:
>
> In addition to what Pavel suggests, a third option would be to create
> a JAR containing the entities and the persistence.xml file and put it
> in the library directory of the EAR. The entities and the persistence
> unit would then be visible to all modules in the application.
>
> Erno
>
>
> Pavel Buzek wrote:
>> That's correct. The persistence classes are in EJB module along with
>> the persistence.xml. But the controller classes which are trying to
>> access the entity classes are in the WAR. You have to define
>> persistence.xml in the project where you use it. Either use a session
>> facade and keep the persistence.xml in EJB module or create a
>> persistence.xml in WAR module. Note that in the later case you also
>> have to list the jar file of EJB module in persistence.xml so that
>> the entity manager can find the classes - it normally only looks in
>> the current module.
>>
>> hope this helps
>>
>> -pavel
>>
>> David W. Van Couvering wrote:
>>> I'm pretty much a newbie when it comes to the new Java Persistence
>>> stuff, but it sure seems to me that the Glassfish persistence code
>>> (e.g. TopLink) is not able to find the descriptors for the entity
>>> classes it is trying to persist. This is either because it can't
>>> find the persistence.xml file or the persistence.xml file is missing
>>> the descriptor for the entity class.
>>>
>>> I am copying the glassfish persistence team as this is their area of
>>> expertise.
>>>
>>> David
>>>
>>> Rajesh Chenji wrote:
>>>> Hi All,
>>>>
>>>> We have one of our customer trying run a simple Enterprise
>>>> Application which uses Entity Beans & JSF using MySQL 4.1.Attached
>>>> are the sample project & issue details.
>>>>
>>>> I tried to work out the same issue using default derby database
>>>> which is bundled with Netbeans 5.5.But i keep encountering the
>>>> following exception which the customer also encounters
>>>>
>>>> *exception*
>>>>
>>>> javax.servlet.ServletException: Exception Description: A problem
>>>> was encountered resolving the class name - The descriptor for
>>>> [Reservation] was not found.
>>>>
>>>> *root cause*
>>>>
>>>> Exception [TOPLINK-8006] (Oracle TopLink Essentials - 2006.8 (Build
>>>> 060830)): oracle.toplink.essentials.exceptions.EJBQLException
>>>> Exception Description: A problem was encountered resolving the
>>>> class name - The descriptor for [Reservation] was not found.
>>>>
>>>> Please refer the following attached documents for more details
>>>>
>>>> Regards
>>>> Rajesh Chenji
>