0 Replies Latest reply on Nov 12, 2009 6:37 PM by J. Robinson

    TimedCachePolicy.insert... Attempt to insert duplicate entry

    J. Robinson Newbie

      Hello everyone,

      I see this stack trace very intermittently when my bean attempts to run a JPA query, and I'm looking for ideas on what the problem could be and how to solve it.

      I'm running with JBoss 5.0.1GA on linux with an Oracle data source. The oracle-ds.xml has the directive "<security-domain>EncryptOraclePassword</security-domain>".

      java.lang.IllegalStateException: Attempt to insert duplicate entry
      at org.jboss.util.TimedCachePolicy.insert(TimedCachePolicy.java:219)
      at org.jboss.security.plugins.auth.JaasSecurityManagerBase.updateCache(JaasSecurityManagerBase.java:751)
      at org.jboss.security.plugins.auth.JaasSecurityManagerBase.authenticate(JaasSecurityManagerBase.java:504)
      at org.jboss.security.plugins.auth.JaasSecurityManagerBase.isValid(JaasSecurityManagerBase.java:365)
      at org.jboss.security.plugins.JaasSecurityManager.isValid(JaasSecurityManager.java:160)
      at org.jboss.security.integration.JBossSecuritySubjectFactory.createSubject(JBossSecuritySubjectFactory.java:90)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.getSubject(BaseConnectionManager2.java:687)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:495)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
      at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:46)
      at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
      at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
      at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:161)
      at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1573)
      at org.hibernate.loader.Loader.doQuery(Loader.java:696)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
      at org.hibernate.loader.Loader.doList(Loader.java:2228)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
      at org.hibernate.loader.Loader.list(Loader.java:2120)
      at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
      at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
      at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
      at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
      at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
      at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:88)
      at com.myorganization.UserLocatorLocalBean.findUser(UserLocatorLocalBean.java:200)

      the findUser() method is running the following code:

      Query q = entityManager.createNamedQuery("findUser");
      q.setParameter("username", username);
      Object obj = q.getSingleResult();
      // ...

      The named query:

      @NamedQuery(name = "findUser", query = "SELECT e from UserEntity e where e.username = :username")