org.datanucleus.sco.backed.ArrayList cannot be cas

2019-07-19 06:45发布

Since 4 days ago, in random short periods of time, my deployed application is throwing this error:

org.datanucleus.sco.backed.ArrayList cannot be cast to java.util.Set

We are using GWT 2.4 / Java 1.7 (We recently migrate from 1.6 to 1.7)

It happens when retrieving or persisting an entity with a String set:

import java.util.HashSet;
import java.util.Set;
...
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class DbAccount {
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
...
    @Persistent
    private Set<String> accounts;
...
    public DbAccount(SerAccount account) throws Exception {
        ...
        this.accounts= new HashSet<String>();
        ...
        key = KeyFactory.createKey(DbCuentas.class.getSimpleName(), this.id);
    }
}

I have checked my entire project for a reference to org.datanucleus.sco.backed.ArrayList and it does not exist.

Any idea?

1条回答
何必那么认真
2楼-- · 2019-07-19 07:38

It may sound stupid, but have you tried to use List instead of Set ?

After checking out the docs again, I can't find any example from Google with a Collection other than List.

Reading your issue, it looks like the JPA datanucleus impl is indeed using their own ArrayList implementation whatever you do. I don't know why the problem happens randomly though...

查看更多
登录 后发表回答