Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
IllegalArgumentException occurred while calling setter for property [com.sun.ts.tests.jpa.common.schema30.Order.creditCard (expected type = com.sun.ts.tests.jpa.common.schema30.CreditCard)]; target = [Order[id: 1, totalPrice: 0.0, lineitem.id[], custId: null, custName: null, cc: null, type: null]], property value = [LineItem[id: 29, quantity: 0,…
Failing test:
jpa/core/criteriaapi/CriteriaBuilder/Client.java\#abs_from_pmservlet test source
jpa/core/criteriaapi/CriteriaBuilder/Client.java\#abs_from_stateless3 test source
Source Link https://github.com/eclipse-ee4j/jakartaee-tck/blob/master/src/com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/Client.java#L5240
Question: Why would the below exception be thrown for application code that works
correctly when the entire test is done under a single container manager JTA transaction
but gets the failure when under application controlled user transaction?
As far as I can tell, the test code only obtains the EntityManager.getCriteriaBuilder()
is called before the user transaction is started (failing case). When using container
managed transaction, the EntityManager.getCriteriaBuilder() is called after the JTA transaction is started.
To recreate locally using export testName=abs_from_pmservlet
FYI the EntityManager is container managed
[javatest.batch] Caused by: IllegalArgumentException occurred while calling setter for property [com.sun.ts.tests.jpa.common.schema30.Order.creditCard (expected type = com.sun.ts.tests.jpa.common.schema30.CreditCard)]; target = [Order[id: 1, totalPrice: 0.0, lineitem.id[], custId: null, custName: null, cc: null, type: null]], property value = [LineItem[id: 29, quantity: 0, fk_order.id: null, fk_product.id: null]]
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.property.access.spi.SetterMethodImpl.set(SetterMethodImpl.java:98)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.persister.entity.AbstractEntityPersister.lambda$setPropertyValues$13(AbstractEntityPersister.java:5073)
[javatest.batch] at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.persister.entity.AbstractEntityPersister.visitFetchables(AbstractEntityPersister.java:6689)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:5066)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.initializeEntity(AbstractEntityInitializer.java:710)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.results.graph.entity.AbstractEntityInitializer.initializeInstance(AbstractEntityInitializer.java:661)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.results.internal.StandardRowReader.coordinateInitializers(StandardRowReader.java:150)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.results.internal.StandardRowReader.readRow(StandardRowReader.java:91)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:92)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:26)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.doExecuteQuery(JdbcSelectExecutorStandardImpl.java:429)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.executeQuery(JdbcSelectExecutorStandardImpl.java:166)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.list(JdbcSelectExecutorStandardImpl.java:94)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.loader.ast.internal.SingleUniqueKeyEntityLoaderStandard.load(SingleUniqueKeyEntityLoaderStandard.java:102)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:2741)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.persister.entity.AbstractEntityPersister.loadByUniqueKey(AbstractEntityPersister.java:2733)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.results.graph.entity.internal.EntitySelectFetchByUniqueKeyInitializer.initializeInstance(EntitySelectFetchByUniqueKeyInitializer.java:75)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.results.internal.StandardRowReader.coordinateInitializers(StandardRowReader.java:150)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.results.internal.StandardRowReader.readRow(StandardRowReader.java:91)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:92)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.results.spi.ListResultsConsumer.consume(ListResultsConsumer.java:26)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.doExecuteQuery(JdbcSelectExecutorStandardImpl.java:429)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.executeQuery(JdbcSelectExecutorStandardImpl.java:166)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl.list(JdbcSelectExecutorStandardImpl.java:94)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.lambda$new$0(ConcreteSqmSelectQueryPlan.java:103)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.withCacheableSqmInterpretation(ConcreteSqmSelectQueryPlan.java:307)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.query.sqm.internal.ConcreteSqmSelectQueryPlan.performList(ConcreteSqmSelectQueryPlan.java:248)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.query.sqm.internal.QuerySqmImpl.doList(QuerySqmImpl.java:517)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.query.spi.AbstractSelectionQuery.list(AbstractSelectionQuery.java:352)
[javatest.batch] ... 59 more
[javatest.batch] Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@2b5425ff
[javatest.batch] at jdk.internal.reflect.GeneratedMethodAccessor232.invoke(Unknown Source)
[javatest.batch] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[javatest.batch] at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[javatest.batch] at org.hibernate@6.0.0-SNAPSHOT//org.hibernate.property.access.spi.SetterMethodImpl.set(SetterMethodImpl.java:43)
[javatest.batch] ... 88 more
[javatest.batch]
[javatest.batch] 03-29-2022 10:56:31: Test: returning from running in a pmservlet vehicle
[javatest.batch] STATUS:Failed.Test case throws exception: Converting `org.hibernate.PropertySetterAccessException` to JPA `PersistenceException` : IllegalArgumentException occurred while calling setter for property [com.sun.ts.tests.jpa.common.schema30.Order.creditCard (expected type = com.sun.ts.tests.jpa.common.schema30.CreditCard)]; target = [Order[id: 1, totalPrice: 0.0, lineitem.id[], custId: null, custName: null, cc: null, type: null]], property value = [LineItem[id: 29, quantity: 0, fk_order.id: null, fk_product.id: null]] : `com.sun.ts.tests.jpa.common.schema30.Order.creditCard` (setter)
[javatest.batch] Failed. Test case throws exception: Converting `org.hibernate.PropertySetterAccessException` to JPA `PersistenceException` : IllegalArgumentException occurred while calling setter for property [com.sun.ts.tests.jpa.common.schema30.Order.creditCard (expected type = com.sun.ts.tests.jpa.common.schema30.CreditCard)]; target = [Order[id: 1, totalPrice: 0.0, lineitem.id[], custId: null, custName: null, cc: null, type: null]], property value = [LineItem[id: 29, quantity: 0, fk_order.id: null, fk_product.id: null]] : `com.sun.ts.tests.jpa.common.schema30.Order.creditCard` (setter)
[javatest.batch] ********************************************************************************
[javatest.batch] Finished Test: FAILED........com/sun/ts/tests/jpa/core/criteriaapi/CriteriaBuilder/Client.java#abs_from_pmservlet
The below problem only occurs with Persistence Test Vehicles `stateless3` + `pmservlet`
(uses UserTransaction methods for transaction demarcation) but passes with the others.
Descriptions are in https://github.com/eclipse-ee4j/jakartaee-tck/blob/master/user_guides/jakartaee/src/main/jbake/content/config.adoc:
"
5.4.14.3 Persistence Test Vehicles
++++++++++++++++++++++++++++++++++
The persistence tests are run in a variety of "vehicles" from which the
entity manager is obtained and the transaction type is defined for use.
There are six vehicles used for these tests:
* `stateless3`: Bean-managed stateless session bean using JNDI to lookup
a Jakarta Transactions `EntityManager`; uses `UserTransaction` methods for transaction
demarcation
* `stateful3`: Container-managed stateful session bean using
`@PersistenceContext` annotation to inject Jakarta Transactions `EntityManager;` uses
container-managed transaction demarcation with a transaction attribute
(required)
* `appmanaged`: Container-managed stateful session bean using
`@PersistenceUnit` annotation to inject an `EntityManagerFactory`; the
`EntityManagerFactory` API is used to create an Application-Managed Jakarta Transactions
`EntityManager`, and uses the container to demarcate transactions
* `appmanagedNoTx`: Container-managed stateful session bean using
`@PersistenceUnit` annotation to inject an `EntityManagerFactory`; the
`EntityManagerFactory` API is used to create an Application-Managed
Resource Local `EntityManager`, and uses the `EntityTransaction` APIs to
control transactions
* `pmservlet`: Servlet that uses the `@PersistenceContext` annotation at
the class level and then uses JNDI lookup to obtain the `EntityManager`;
alternative to declaring the persistence context dependency via a
`persistence-context-ref` in `web.xml` and uses `UserTransaction`
methods for transaction demarcation
* `puservlet`: Servlet that injects an `EntityManagerFactory` using the
`@PersistenceUnit` annotation to create a to Resource Local
`EntityManager`, and uses `EntityTransaction` APIs for transaction
demarcation
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment