You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Dianne Richards (JIRA)" <ji...@apache.org> on 2008/12/08 22:59:44 UTC

[jira] Created: (OPENJPA-819) NPE when no metadata is defined for a persistent class

NPE when no metadata is defined for a persistent class
------------------------------------------------------

                 Key: OPENJPA-819
                 URL: https://issues.apache.org/jira/browse/OPENJPA-819
             Project: OpenJPA
          Issue Type: Bug
          Components: kernel
    Affects Versions: 2.0.0
            Reporter: Dianne Richards
            Priority: Minor
             Fix For: 2.0.0


The persistent class was specified in the persistence.xml under <class>, but persistence metadata was not specified for the class, either through annotation or the orm.xml. A NPE was thrown. We need a better message.

This issue was reported in the user forum by post http://n2.nabble.com/NullPointerException-when-calling-createEntityManager-on--EntityManagerFactory-td1621881.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Assigned: (OPENJPA-819) NPE when no metadata is defined for a persistent class

Posted by Pinaki Poddar <pp...@apache.org>.
Hi,
  Thank you for your contribution.
   Few comments on th epatch follow:

1. Many error messages in OpenJPA not only tells what the error is, it also
tries to help what can be common cause of the error. From that standpoint,
the message
   no-meta: No registered metadata for type "{0}".
could be changed to something like
   no-meta: No registered metadata for class "{0}". This can happen if this
class has not been annotated as persistent entity or specified in the
persistence unit.

2. The test case can benefit from deriving from SingleEMFTest case and its
setUp(Object...args). There are many examples available in
openjpa-persistence-jdbc test package on its usage.

3. If SingleEMFTestCase is used, persistence.xml is not needed.

4. The comments just above where the new exception is raised should be
modified, as after this change it sounds contradictory.

-- 
View this message in context: http://n2.nabble.com/-jira--Created%3A-%28OPENJPA-819%29-NPE-when-no-metadata-is-defined-for-a-persistent-class-tp1631178p1663557.html
Sent from the OpenJPA Developers mailing list archive at Nabble.com.


[jira] Assigned: (OPENJPA-819) NPE when no metadata is defined for a persistent class

Posted by "Jeremy Bauer (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-819?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeremy Bauer reassigned OPENJPA-819:
------------------------------------

    Assignee: Dianne Richards

> NPE when no metadata is defined for a persistent class
> ------------------------------------------------------
>
>                 Key: OPENJPA-819
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-819
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0
>            Reporter: Dianne Richards
>            Assignee: Dianne Richards
>            Priority: Minor
>             Fix For: 2.0.0
>
>
> The persistent class was specified in the persistence.xml under <class>, but persistence metadata was not specified for the class, either through annotation or the orm.xml. A NPE was thrown. We need a better message.
> This issue was reported in the user forum by post http://n2.nabble.com/NullPointerException-when-calling-createEntityManager-on--EntityManagerFactory-td1621881.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (OPENJPA-819) NPE when no metadata is defined for a persistent class

Posted by "Jeremy Bauer (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-819?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeremy Bauer resolved OPENJPA-819.
----------------------------------

    Resolution: Fixed

Committed for Dianne Richards to trunk under revision 727813.  Resolving issue.

> NPE when no metadata is defined for a persistent class
> ------------------------------------------------------
>
>                 Key: OPENJPA-819
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-819
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0
>            Reporter: Dianne Richards
>            Assignee: Dianne Richards
>            Priority: Minor
>             Fix For: 2.0.0
>
>         Attachments: OPENJPA-819.patch, OPENJPA-819.patch
>
>
> The persistent class was specified in the persistence.xml under <class>, but persistence metadata was not specified for the class, either through annotation or the orm.xml. A NPE was thrown. We need a better message.
> This issue was reported in the user forum by post http://n2.nabble.com/NullPointerException-when-calling-createEntityManager-on--EntityManagerFactory-td1621881.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (OPENJPA-819) NPE when no metadata is defined for a persistent class

Posted by "Dianne Richards (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12657064#action_12657064 ] 

Dianne Richards commented on OPENJPA-819:
-----------------------------------------

Pinaki responded with the following in the mailing list. I'm documenting here. Thanks Pinaki. See my embedded responses:

1. Many error messages in OpenJPA not only tells what the error is, it also
tries to help what can be common cause of the error. From that standpoint,
the message
  no-meta: No registered metadata for type "{0}".
could be changed to something like
  no-meta: No registered metadata for class "{0}". This can happen if this
class has not been annotated as persistent entity or specified in the
persistence unit.

<der>I agree. I just used an existing message. But, I'll update it as part of this fix.</der>

2. The test case can benefit from deriving from SingleEMFTest case and its
setUp(Object...args). There are many examples available in
openjpa-persistence-jdbc test package on its usage.

<der>Actually, I know about this class and I initially tried it. But, it went down a different path. It issued a similar message, but it did not go through the code that I changed. So, I had to resort to the current scheme.</der>

3. If SingleEMFTestCase is used, persistence.xml is not needed.

<der>See my comment under 2.</der>

4. The comments just above where the new exception is raised should be
modified, as after this change it sounds contradictory.

<der>Will do</der>

> NPE when no metadata is defined for a persistent class
> ------------------------------------------------------
>
>                 Key: OPENJPA-819
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-819
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0
>            Reporter: Dianne Richards
>            Assignee: Dianne Richards
>            Priority: Minor
>             Fix For: 2.0.0
>
>         Attachments: OPENJPA-819.patch
>
>
> The persistent class was specified in the persistence.xml under <class>, but persistence metadata was not specified for the class, either through annotation or the orm.xml. A NPE was thrown. We need a better message.
> This issue was reported in the user forum by post http://n2.nabble.com/NullPointerException-when-calling-createEntityManager-on--EntityManagerFactory-td1621881.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-819) NPE when no metadata is defined for a persistent class

Posted by "Dianne Richards (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-819?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dianne Richards updated OPENJPA-819:
------------------------------------

    Attachment: OPENJPA-819.patch

Attaching patch for this problem. Please review and commit if ok.

> NPE when no metadata is defined for a persistent class
> ------------------------------------------------------
>
>                 Key: OPENJPA-819
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-819
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0
>            Reporter: Dianne Richards
>            Assignee: Dianne Richards
>            Priority: Minor
>             Fix For: 2.0.0
>
>         Attachments: OPENJPA-819.patch
>
>
> The persistent class was specified in the persistence.xml under <class>, but persistence metadata was not specified for the class, either through annotation or the orm.xml. A NPE was thrown. We need a better message.
> This issue was reported in the user forum by post http://n2.nabble.com/NullPointerException-when-calling-createEntityManager-on--EntityManagerFactory-td1621881.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (OPENJPA-819) NPE when no metadata is defined for a persistent class

Posted by "Dianne Richards (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-819?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dianne Richards updated OPENJPA-819:
------------------------------------

    Attachment: OPENJPA-819.patch

Updated patch incorporating Pinaki's comments. Please review.

> NPE when no metadata is defined for a persistent class
> ------------------------------------------------------
>
>                 Key: OPENJPA-819
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-819
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 2.0.0
>            Reporter: Dianne Richards
>            Assignee: Dianne Richards
>            Priority: Minor
>             Fix For: 2.0.0
>
>         Attachments: OPENJPA-819.patch, OPENJPA-819.patch
>
>
> The persistent class was specified in the persistence.xml under <class>, but persistence metadata was not specified for the class, either through annotation or the orm.xml. A NPE was thrown. We need a better message.
> This issue was reported in the user forum by post http://n2.nabble.com/NullPointerException-when-calling-createEntityManager-on--EntityManagerFactory-td1621881.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.