Issue
The problem is that, at each build of the project with Maven, the build produces randomly a working jar or a broken one. Obviously there aren't any changes neither in code or configuration.
What I mean with broken?
Usually, each 5/6 builds, 1 working JAR is generated, while 4/5 are broken. The broken and working jars are identical with binary comparison.
Once a JAR is compiled, if it is broken, each execution will be broken, regardless of how many times it is executed. Same goes for the working one.
What I Already Tried
Configuration
I have a Spring Batch Project, based on Spring Data JPA and Hibernate. The batch is executed by a sh file. As you can see in the configuration, for debug reasons, I have hibernate.show_sql
parameter set to true. The database is Oracle 11g.
POM:
<properties>
<spring-version>5.1.5.RELEASE</spring-version>
<hibernate-version>5.4.1.Final</hibernate-version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>4.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.1.5.RELEASE</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate-version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-version}</version>
</dependency>
.....
</dependencies>
Hibernate Properties:
hibernate.synonyms=true
hibernate.allocationSize=1000
hibernate.order_inserts=true
hibernate.order_updates=true
hibernate.show_sql=true
hibernate.jdbc.batch_versioned_data=true
hibernate.id.new_generator_mappings=true
hibernate.jdbc.batch_size=30
hibernate.generate_statistics=false
Working Log:
2019-06-27 10:42:03.558 [pool-3-thread-19] INFO i.a.n.b.t.XXX (246) - Elaborazione TABLE1 con SEQU: 2071042
Hibernate: select SEQUENCE1.nextval from dual
Hibernate: insert into TABLE2 (........) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: select column1, column2 ... from TABLE3 where condtion
2019-06-27 10:42:03.651 [pool-3-thread-19] INFO i.a.n.b.s.i.BaseOrderServiceImpl (185) - Recuperato record dalla TABLE3 con ID : 2071042
Broken Log:
2019-06-27 10:42:03.558 [pool-3-thread-19] INFO i.a.n.b.t.XXX (246) - Elaborazione TABLE1 con SEQU: 2071042
Hibernate: select SEQUENCE1.nextval from dual
INSERT MISSING HERE
Hibernate: select column1, column2 ... from TABLE3 where condtion
2019-06-27 10:42:03.651 [pool-3-thread-19] INFO i.a.n.b.s.i.BaseOrderServiceImpl (185) - Recuperato record dalla TABLE3 con ID : 2071042
Call for help:
I am building my project multiple times each time I need to deploy it, for months. I'd like to solve this problem once and for all and I'd appreciate your help.
If you need snippet of codes ask me, but generally they are normal save with basic entities, with @Transactional
notation working fine with working JAR.
Thank you.
Update
As suggested I tried to uniform spring and hibernate dependencies to the same version. The problem is still there.
Update pom
<properties>
<spring-version>5.0.12.RELEASE</spring-version>
<hibernate-version>5.2.17.Final</hibernate-version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-core</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.1.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.17.Final</version>
</dependency>
</dependencies>
I resolved the issue with the following steps:
These steps resolved the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.