Hi Jorg, It's a bit difficult to say from your mail ... I'm not exactly sure what you're attempting to do.
The quartz job will be run multiple times, depending on what's in quartz-config.xml, eg every 10 seconds.. Therefore those "init" methods will be attempting to creating objects every 10 secs too. If the code you are running is not idempotent, then I could quite imagine you getting the duplicate key exceptions that you are seeing. HTH Dan On Tue, 16 Jan 2018 at 15:44 Rade, Joerg / Kuehne + Nagel / Ham GI-DP < [email protected]> wrote: > Hi, > > I've setup isisaddons (command, quartz) in order to check for changed > files and to create objects accordingly. > > When I execute the import via FixtureScripts everything works as expected, > but via Quartz I get the following stacktrace: > > 16:17:03,904 [Datastore SchedulerQuartzConfigXml_Worker-1 > ERROR] Add request failed : INSERT INTO "RELEASES_PROVIDEDSERVICES" > ("RELEASE_ID","PROVIDESSERVICE_ID") VALUES (?,?) > org.datanucleus.store.rdbms.exceptions.MappedDatastoreException: INSERT > INTO "RELEASES_PROVIDEDSERVICES" ("RELEASE_ID","PROVIDESSERVICE_ID") VALUES > (?,?) > at > org.datanucleus.store.rdbms.scostore.JoinSetStore.doInternalAdd(JoinSetStore.java:715) > at > org.datanucleus.store.rdbms.scostore.JoinSetStore.add(JoinSetStore.java:297) > at > org.datanucleus.store.types.wrappers.backed.TreeSet.add(TreeSet.java:674) > at > org.datanucleus.store.types.SCOUtils.updateCollectionWithCollection(SCOUtils.java:870) > at > org.datanucleus.store.types.wrappers.backed.TreeSet.initialise(TreeSet.java:148) > at > org.datanucleus.store.types.wrappers.backed.TreeSet.initialise(TreeSet.java:68) > at > org.datanucleus.store.types.SCOUtils.wrapAndReplaceSCOField(SCOUtils.java:176) > at > org.datanucleus.state.StateManagerImpl.setObjectField(StateManagerImpl.java:1804) > at ife.dep.Release.dnSetcapabilities(Release.java) > at ife.dep.Release.setCapabilities(Release.java:93) > at > ife.util.ApplicationReader.handleRelease(ApplicationReader.java:136) > at > ife.util.ApplicationReader.handleReleases(ApplicationReader.java:120) > at > ife.util.ApplicationReader.handleApplication(ApplicationReader.java:109) > at > ife.util.ApplicationReader.init(ApplicationReader.java:90) > at > ife.util.MasterDataUpdateCommand.execute(MasterDataUpdateCommand.java:32) > at > ife.util.MasterDataBackgroundCommandsJob.execute(MasterDataBackgroundCommandsJob.java:26) > at org.quartz.core.JobRunShell.run(JobRunShell.java:202) > at > org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) > Caused by: java.sql.SQLIntegrityConstraintViolationException: integrity > constraint violation: unique constraint or index violation; > "RELEASES_PROVIDEDSERVICES_PK" table: "RELEASES_PROVIDEDSERVICES" > at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) > at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) > at > org.hsqldb.jdbc.JDBCPreparedStatement.fetchResult(Unknown Source) > at > org.hsqldb.jdbc.JDBCPreparedStatement.executeUpdate(Unknown Source) > at > com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105) > at > org.datanucleus.store.rdbms.ParamLoggingPreparedStatement.executeUpdate(ParamLoggingPreparedStatement.java:393) > at > org.datanucleus.store.rdbms.SQLController.executeStatementUpdate(SQLController.java:431) > at > org.datanucleus.store.rdbms.scostore.JoinSetStore.doInternalAdd(JoinSetStore.java:694) > ... 17 more > Caused by: org.hsqldb.HsqlException: integrity constraint violation: > unique constraint or index violation; "RELEASES_PROVIDEDSERVICES_PK" table: > "RELEASES_PROVIDEDSERVICES" > at org.hsqldb.error.Error.error(Unknown Source) > at org.hsqldb.Constraint.getException(Unknown Source) > at org.hsqldb.index.IndexAVLMemory.insert(Unknown Source) > at org.hsqldb.persist.RowStoreAVL.indexRow(Unknown Source) > at org.hsqldb.TransactionManager2PL.addInsertAction(Unknown > Source) > at org.hsqldb.Session.addInsertAction(Unknown Source) > at org.hsqldb.Table.insertSingleRow(Unknown Source) > at org.hsqldb.StatementDML.insertSingleRow(Unknown Source) > at org.hsqldb.StatementInsert.getResult(Unknown Source) > at org.hsqldb.StatementDMQL.execute(Unknown Source) > at org.hsqldb.Session.executeCompiledStatement(Unknown > Source) > at org.hsqldb.Session.execute(Unknown Source) > ... 23 more > > The relation Release-RequiredService is m:n. My Job class: > > package ife.util; > > import org.apache.isis.core.commons.authentication.AuthenticationSession; > import > org.apache.isis.core.runtime.sessiontemplate.AbstractIsisSessionTemplate; > import org.apache.isis.core.runtime.system.persistence.PersistenceSession; > > import ife.env.RuntimeEnvironments; > > public class MasterDataUpdateCommand extends AbstractIsisSessionTemplate { > @javax.inject.Inject > private ApplicationReader applicationReader; > @javax.inject.Inject > private Properties properties; > @javax.inject.Inject > private RuntimeEnvironments runtimeEnvironments; > > @Override > public void execute(AuthenticationSession authSession, Object context) > { > try { > this.getIsisSessionFactory().openSession(authSession); > PersistenceSession persistenceSession = > this.getPersistenceSession(); > > persistenceSession.getServicesInjector().injectServicesInto(this); > > properties.init(); // simple objects without relation -> OK > applicationReader.init(); // m:n relation breaks > runtimeEnvironments.init(); > } finally { > this.getIsisSessionFactory().closeSession(); > } > } > > } > > > > ApplicationReader is in the same package as MasterDataUpdateCommand and is > annotated with > > @DomainService(nature = NatureOfService.DOMAIN) > > 1.16.0 and 1.15.1 behave the same. > > Am I doing something wrong? > > Thanks in advance > Jörg > > > Kühne + Nagel (AG & Co.) KG > Rechtsform: Kommanditgesellschaft, Bremen HRA 21928, USt-IdNr.: DE > 812773878. > Geschäftsleitung Kühne + Nagel (AG & Co.) KG: Dr. Hansjörg Rodi (Vors. ), > Martin Brinkmann, Holger Ketz, Jan-Hendrik Köstergarten, Nicholas Minde, > Michael Nebel, Lars Wedel, Matthias Weiner. > Persönlich haftende Gesellschafterin: Kühne & Nagel A.G., Rechtsform: > Aktiengesellschaft nach luxemburgischem Recht, HR-Nr.: B 18745, > Geschäftsführendes Verwaltungsratsmitglied: Karl Gernandt. > Geschäftsleitung Region Zentral- und Osteuropa: Dr. Hansjörg Rodi (Vors.), > Dominic Edmonds, Thierry Held, Uwe Hött, Richard Huhn, Holger Ketz, > Jan-Hendrik Köstergarten, Jan Kunze, Michael Nebel, Mustafa Sener. > > Wir arbeiten ausschließlich auf Grundlage der Allgemeinen Deutschen > Spediteurbedingungen 2017 (ADSp 2017). Hinweis: Die ADSp 2017 weichen in > Ziffer 23 hinsichtlich des Haftungshöchstbetrages für Güterschäden (§ 431 > HGB) vom Gesetz ab, indem sie die Haftung bei multimodalen Transporten > unter Einschluss einer Seebeförderung und bei unbekanntem Schadenort auf 2 > SZR/kg und im Übrigen die Regelhaftung von 8,33 SZR/kg zusätzlich auf 1,25 > Millionen Euro je Schadenfall sowie 2,5 Millionen Euro je Schadenereignis, > mindestens aber 2 SZR/kg, beschränken. Die ADSp sind auf unserer Webseite > als Download erhältlich. Auf Anfrage senden wir Ihnen diese auch gerne zu. >
