[
https://issues.apache.org/jira/browse/OPENJPA-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rick Curtis closed OPENJPA-1976.
--------------------------------
Resolution: Not A Problem
Assignee: Rick Curtis
Chuong -
Lets start off with the javadoc for
javax.persistence.EntityManager.find(Class<T> entityClass, Object primaryKey).
----
<T> T find(Class<T> entityClass, Object primaryKey)
Find by primary key.
Parameters:
entityClass -
primaryKey -
Returns:
the found entity instance or null if the entity does not exist
Throws:
IllegalStateException - if this EntityManager has been closed.
IllegalArgumentException - if the first argument does not denote an
entity type or the second argument is not a valid type for that entity's
primary key
---
The last part of the IllegalArgumentException states an exception will be
thrown when "the second argument is not a valid type for that entity's primary
key". By looking at your BookModel there is one column annotated as the ID
column and that column is not a java.lang.String. I'm not sure what your intent
was, but it was wrong. You can't call EntityManager.find with a non-primary key
value. (Your primary key is a Long, but you passed a String.)
Now on to stacktrace 2. If you dig down through that you will see that OpenJPA
is getting an IllegalStateException[1] from the application server. After doing
a little bit of googling around, I was able to find a number of posts that talk
about Glassfish having problems reloading classes after WAR redeploy. I'm not
sure if that is your scenario, but it surely this isn't an OpenJPA problem.
Perhaps you could try to restart the application server? The net of this is
that you're going to have to work with the glassfish folks to figure out why we
can't load that class.
In the future, please utilize the users/dev mailing lists[2] to ask questions
and wait to open a JIRA until we're sure there is a bug. I'm closing this JIRA
as there is nothing to do here. If you would like to continue asking questions,
please move this over to the users mailing list.
Thanks,
Rick
[1] Caused by: java.lang.IllegalStateException: WEB9031: WebappClassLoader
unable to load resource [org.apache.openjpa.util.LongId], because it has not
yet been started, or was already stopped
at
org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1410)
<-- Glassfish
at
org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1368)
at au.com.ckd.model.BookModel.pcNewObjectIdInstance(BookModel.java)
[2] http://openjpa.apache.org/mailing-lists.html
> EntityManager.find method cause errors
> --------------------------------------
>
> Key: OPENJPA-1976
> URL: https://issues.apache.org/jira/browse/OPENJPA-1976
> Project: OpenJPA
> Issue Type: Bug
> Components: jpa
> Affects Versions: 2.1.0
> Environment: Glassfish 3.1, JSF 2.1.0, Apache OpenJPA 2.1.0, MySQL
> 5.5.10, Eclipse Helios IDE, Windows XP Service Pack 3
> Reporter: Chuong Pham
> Assignee: Rick Curtis
> Labels: features, test
> Attachments: ENTITY.txt, SCENARIO 1 STACKTRACE.txt, SCENARIO 2
> STACKTRACE.txt
>
>
> Scenario 1: The EntityManager.find method is unable to pass a String value as
> its second parameter and caused the following error:
> <openjpa-2.1.0-r422266:1071316 nonfatal user error>
> org.apache.openjpa.persistence.ArgumentException: The given value
> "214736890D96ED598E1D3050F1F025A7" cannot be converted into an identity for
> "com.ckd.model.BookModel". The value is the wrong type (java.lang.String).
> java.lang.NumberFormatException: For input string:
> "214736890D96ED598E1D3050F1F025A7"
> It seems from the errors above that the EntityManager.find method will only
> accept a numeric value as its second parameter.
> Scenario 2: The EntityManager.find method is unable to pass a Long value and
> caused the following error:
> <openjpa-2.1.0-r422266:1071316 fatal user error>
> org.apache.openjpa.persistence.ArgumentException: An error occurred while
> processing registered class "class com.ckd.model.BookModel".
> java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load
> resource [org.apache.openjpa.util.LongId], because it has not yet been
> started, or was already stopped
> The columns used for testing are from a MySQL 5.x table and have the
> following definitions:
> ID SMALLINT(5)
> HASHID VARCHAR(32)
> The value of HASHID is used to test Scenario 1; while the value of ID is used
> to test Scenario 2.
> Conclusion: The above scenarios show that the EntityManager.find method is
> currently unusable/buggy and needs to be investigated for the next release.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira