[ https://issues.apache.org/jira/browse/OPENJPA-2882?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17432212#comment-17432212 ]
ASF subversion and git services commented on OPENJPA-2882: ---------------------------------------------------------- Commit 0fa0ee9790e1246934b9a553bf55e0a658b0e5c3 in openjpa's branch refs/heads/master from Romain Manni-Bucau [ https://gitbox.apache.org/repos/asf?p=openjpa.git;h=0fa0ee9 ] Merge pull request #82 from dazey3/OJ2882_master [master] OPENJPA-2882: Exception passing javax.persistence.* String values to … > Exception passing javax.persistence.* String values to > createEntityManager(Map) > ------------------------------------------------------------------------------- > > Key: OPENJPA-2882 > URL: https://issues.apache.org/jira/browse/OPENJPA-2882 > Project: OpenJPA > Issue Type: Bug > Affects Versions: 2.2.3 > Reporter: Will Dazey > Priority: Minor > > Exception: > {code:java} > 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) > {code} > Fairly easy to reproduce: > Test: > {code:java} > Map<String, Object> properties = new HashMap<String, Object>(); > properties.put("javax.persistence.lock.timeout", "34567"); > EntityManager em = emf.createEntityManager(properties); > {code} > 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: > {code:java} > <persistence-context-ref> > <persistence-property> > <name>javax.persistence.lock.timeout</name> > <value>34567</value> > </persistence-property> > </persistence-context-ref> > {code} > 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. -- This message was sent by Atlassian Jira (v8.3.4#803005)