wiki:DatabaseLock

Database Lock Timout : could not insert: [com.j2anywhere.addressbookserver.entities.RecordAddition]

If you have a large number of deleted records it can lead to errors during synchronisation. Errors like the one shown below will be reported in your log file:

javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not insert: [com.j2anywhere.addressbookserver.entities.RecordAddition]
	at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
	at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:226)
	at com.j2anywhere.addressbookserver.SyncService.storeRecords(SyncService.java:540)
	at com.j2anywhere.addressbookserver.CentralAddressBook.storeRecords(CentralAddressBook.java:116)
	at sun.reflect.GeneratedMethodAccessor200.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.sun.xml.ws.server.PeptTie._invoke(PeptTie.java:58)
	at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.invokeEndpoint(SOAPMessageDispatcher.java:278)
	at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher$SoapInvoker.invoke(SOAPMessageDispatcher.java:586)
	at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.receive(SOAPMessageDispatcher.java:141)
	at com.sun.xml.ws.server.Tie.handle(Tie.java:88)

or

Database Lock Timout : could not insert: [com.j2anywhere.addressbookserver.entities.RecordDeletion]

javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not insert: [com.j2anywhere.addressbookserver.entities.RecordDeletion]
	at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614)
	at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:226)
	at com.j2anywhere.addressbookserver.SyncService.storeRecords(SyncService.java:783)
	at com.j2anywhere.addressbookserver.CentralAddressBook.storeRecords(CentralAddressBook.java:111)
	at sun.reflect.GeneratedMethodAccessor188.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:592)
	at com.sun.xml.ws.server.PeptTie._invoke(PeptTie.java:58)
	at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.invokeEndpoint(SOAPMessageDispatcher.java:278)
	at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher$SoapInvoker.invoke(SOAPMessageDispatcher.java:586)
	at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.receive(SOAPMessageDispatcher.java:141)
	at com.sun.xml.ws.server.Tie.handle(Tie.java:88)

To resolve this problem you can either:

Flush Audit Trail

You can remove your entire audit trail via the *Flush Audit Trail* found under the Tools tab.

Remove Deleted Records

Via the Tools tab on the web you can remove all deleted records. This process can take several minutes as it it processing a fair amount of data. Once completed try to sync your clients again.

Extend the lock timeout value

Edit the server.conf file in /usr/share/addressBookServerEnterpriseEdition/apache-tomcat-6.0.18/conf/ and append ;LOCK_TIMEOUT=60000 to both sections as shown in this example

<Context path="" docBase="AddressBookServer.war">
  <Resource name="jdbc/AddressBookDB" auth="Container" type="javax.sql.DataSource"
     maxActive="25" maxIdle="5" maxWait="-1"
     username="sa" password="" driverClassName="org.h2.Driver"
     url="jdbc:h2:tcp://localhost:28081/../db/AddressBookDB;LOCK_TIMEOUT=60000"/>
  <Realm className="org.apache.catalina.realm.JDBCRealm"
    driverName="org.h2.Driver"
    connectionURL="jdbc:h2:tcp://localhost:28081/../db/AddressBookDB;LOCK_TIMEOUT=60000"
    connectionName="sa" connectionPassword=""
    userTable="WEBUSERS" userNameCol="USERID" userCredCol="PASSWORD"
    userRoleTable="WEBROLES" roleNameCol="ACCESSROLE"/>
</Context>