Exception:
java.lang.IllegalArgumentException: argument type mismatch at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.openjpa.enhance.Reflection.set(Reflection.java:777) at org.apache.openjpa.persistence.EntityManagerImpl.setKernelProperty(EntityManagerImpl.java:1936) at org.apache.openjpa.persistence.EntityManagerImpl.setProperty(EntityManagerImpl.java:1911) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:258) at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:58) Caused by: java.lang.IllegalArgumentException: Error while setting value 34567 of class java.lang.String by setter method public org.apache.openjpa.persistence.jdbc.JDBCFetchPlan org.apache.openjpa.persistence.jdbc.JDBCFetchPlanImpl.setLockTimeout(int) of instance org.apache.openjpa.persistence.jdbc.JDBCFetchPlanImpl@28d133b9 by reflection. at org.apache.openjpa.enhance.Reflection.wrapReflectionException(Reflection.java:347) at org.apache.openjpa.enhance.Reflection.set(Reflection.java:779)
Fairly easy to reproduce:
Test:
Map<String, Object> properties = new HashMap<String, Object>(); properties.put("javax.persistence.lock.timeout", "34567"); EntityManager em = emf.createEntityManager(properties);
Whats happening:
`org.apache.openjpa.enhance.Reflection.findSetter(org.apache.openjpa.persistence.jdbc.JDBCFetchPlanImpl, "LockTimeout")` is returning a setter
```
public org.apache.openjpa.persistence.jdbc.JDBCFetchPlan org.apache.openjpa.persistence.jdbc.JDBCFetchPlanImpl.setLockTimeout(int)
```
However, `org.apache.openjpa.persistence.EntityManagerImpl.convertUserValue("javax.persistence.lock.timeout", "34567", int)` is failing to accurately convert the value from String -> int. You might think "oh, well then just pass in (int) 34567 and not (String) 34567". However, this isnt always possible. The actual usecase that exposed this issue is using deployment descriptors to pass the persistence context property:
<persistence-context-ref> <persistence-property> <name>javax.persistence.lock.timeout</name> <value>34567</value> </persistence-property> </persistence-context-ref>
also, this reflection exception doesnt occur if the same property is passed to createEntityManagerFactory(Map)! Inconsistent behavior and a runtime reflection exception that shouldn't occur.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4