[ 
https://issues.apache.org/jira/browse/OPENJPA-2906?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17719634#comment-17719634
 ] 

Maxim Solodovnik commented on OPENJPA-2906:
-------------------------------------------

Hello [~adityah],

sorry for being silent (was busy with other projects)

According to Stacktrace:
{code}
Caused by: java.lang.ClassCastException: java.lang.Long incompatible with 
java.lang.String
    at 
org.apache.openjpa.kernel.DetachedStateManager.attach(DetachedStateManager.java:260)
{code}

The error happens here 
https://github.com/apache/openjpa/blob/2.2.0/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachedStateManager.java#L260

It seems field is declared as String in the DB, so the value is casted to String

Can you check your DB?

in case DB field is declared correctly, could you please provide some sort of 
small demo application demonstrating the problem?

So I can debug?

BTW version 2.2.0 seems to be very old and vulnerable: 
https://mvnrepository.com/artifact/org.apache.openjpa/openjpa
Maybe you can switch to newer version? :)

> ClassCastException - java.lang.Long incompatible with java.lang.String
> ----------------------------------------------------------------------
>
>                 Key: OPENJPA-2906
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2906
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jpa
>    Affects Versions: 2.2.0
>            Reporter: Aditya Holikatti
>            Priority: Minor
>
> An attempt to update a table results in the error below. This behaviour is 
> erratic and the error occurs about once every 3 attempts. There is no pattern 
> or environmental factor I have been able to isolate.  Please let me know what 
> diagnostics I can collect.
> {code:java}
>  WARNING: Unexpected
> <openjpa-2.2.3-SNAPSHOT-r172c084 nonfatal general error> 
> org.apache.openjpa.persistence.PersistenceException: java.lang.Long 
> incompatible with java.lang.String
> FailedObject: com.ibm.ecm.task.entities.Task-17801 [java.lang.String]
>     at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3499)
>     at 
> org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1214)
>     at 
> org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:878)
>     at 
> com.ibm.ecm.task.entities.controller.EntitiesMediator.updateTask(EntitiesMediator.java:2212)
>     ...
>     at com.ibm.ws.asynchbeans.ScheduledTask.call(ScheduledTask.java:500)
>     at 
> com.ibm.ws.asynchbeans.ScheduledTask.runListenerAsCJWork(ScheduledTask.java:756)
>     at com.ibm.ws.asynchbeans.am._Alarm.fireAlarm(_Alarm.java:340)
>     at com.ibm.ws.asynchbeans.am._Alarm.run(_Alarm.java:237)
>     at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1909)
> Caused by: java.lang.ClassCastException: java.lang.Long incompatible with 
> java.lang.String
>     at 
> org.apache.openjpa.kernel.DetachedStateManager.attach(DetachedStateManager.java:260)
>     at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:252)
>     at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:105)
>     at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3492)
>     ... 10 moreNov 12, 2021 4:13:30 PM TaskStatusListenerJCA setTaskStatus
> SEVERE: setTaskStatus
> java.lang.RuntimeException: <openjpa-2.2.3-SNAPSHOT-r172c084 nonfatal general 
> error> org.apache.openjpa.persistence.PersistenceException: java.lang.Long 
> incompatible with java.lang.String
> FailedObject: com.ibm.ecm.task.entities.Task-17801 [java.lang.String]
>     at 
> com.ibm.ecm.task.entities.controller.EntitiesMediator.updateTask(EntitiesMediator.java:2262)
>     ...
>     at com.ibm.ws.asynchbeans.ScheduledTask.call(ScheduledTask.java:500)
>     at 
> com.ibm.ws.asynchbeans.ScheduledTask.runListenerAsCJWork(ScheduledTask.java:756)
>     at com.ibm.ws.asynchbeans.am._Alarm.fireAlarm(_Alarm.java:340)
>     at com.ibm.ws.asynchbeans.am._Alarm.run(_Alarm.java:237)
>     at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1909)
> Caused by: <openjpa-2.2.3-SNAPSHOT-r172c084 nonfatal general error> 
> org.apache.openjpa.persistence.PersistenceException: java.lang.Long 
> incompatible with java.lang.String
> FailedObject: com.ibm.ecm.task.entities.Task-17801 [java.lang.String]
>     at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3499)
>     at 
> org.apache.openjpa.kernel.DelegatingBroker.attach(DelegatingBroker.java:1214)
>     at 
> org.apache.openjpa.persistence.EntityManagerImpl.merge(EntityManagerImpl.java:878)
>     at 
> com.ibm.ecm.task.entities.controller.EntitiesMediator.updateTask(EntitiesMediator.java:2212)
>     ... 7 more
> Caused by: java.lang.ClassCastException: java.lang.Long incompatible with 
> java.lang.String
>     at 
> org.apache.openjpa.kernel.DetachedStateManager.attach(DetachedStateManager.java:260)
>     at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:252)
>     at org.apache.openjpa.kernel.AttachManager.attach(AttachManager.java:105)
>     at org.apache.openjpa.kernel.BrokerImpl.attach(BrokerImpl.java:3492)
>     ... 10 more {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to