Hello Stack Overflow Community!
I'm encountering an issue with Jenkins, and I've hit a roadblock in finding a solution. We recently upgraded from Java 8 to Java 17, and as expected, we're encountering problems with Java modularization. Locally, I've been able to resolve some of the issues by adding the following statements to prevent local unit test failures:
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.time=ALL-UNNAMED
For another project, I successfully addressed the issue by including the following lines in the pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version> <!-- Use a version that supports JUnit 5 and Java 17 -->
<configuration>
<argLine>--add-opens=java.base/java.time=ALL-UNNAMED</argLine>
<argLine>--add-opens=java.base/java.lang=ALL-UNNAMED</argLine>
</configuration>
</plugin>
These changes worked perfectly for that project. However, for this specific project, the same approach doesn't seem to be effective.
EDIT: Follwoing the Stacktrace
16:09:56 [ERROR] Tests run: 2, Failures: 1, Errors: 1, Skipped: 0, Time elapsed: 0.83 s <<< FAILURE! - in ch.irix.asco.export.dimensional.ownbids.entity.OwnBidParameterIntegrationTest
16:09:56 [ERROR] ch.irix.asco.export.dimensional.ownbids.entity.OwnBidParameterIntegrationTest.testUniqueCompositeKeyConstraintWhenSaving Time elapsed: 0.11 s <<< FAILURE!
16:09:56 org.opentest4j.AssertionFailedError: Unexpected exception type thrown, expected: <javax.persistence.RollbackException> but was: <java.lang.reflect.InaccessibleObjectException>
16:09:56 at ch.irix.asco.export.dimensional.ownbids.entity.OwnBidParameterIntegrationTest.testUniqueCompositeKeyConstraintWhenSaving(OwnBidParameterIntegrationTest.java:92)
16:09:56 Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.time.LocalDate java.time.LocalDateTime.date accessible: module java.base does not "opens java.time" to unnamed module @192d3247
16:09:56 at ch.irix.asco.export.dimensional.ownbids.entity.OwnBidParameterIntegrationTest.createOwnBidParamEntity(OwnBidParameterIntegrationTest.java:133)
16:09:56 at ch.irix.asco.export.dimensional.ownbids.entity.OwnBidParameterIntegrationTest.lambda$testUniqueCompositeKeyConstraintWhenSaving$2(OwnBidParameterIntegrationTest.java:93)
16:09:56 at ch.irix.asco.export.dimensional.ownbids.entity.OwnBidParameterIntegrationTest.testUniqueCompositeKeyConstraintWhenSaving(OwnBidParameterIntegrationTest.java:92)
EDIT 2: I've probably found the error which is based in the JSON File. I will work further on this and close the question if this was the problem.
"timestampUtc": {
"date": {
"year": 2020,
"month": 1,
"day": 1
},
"time": {
"hour": 10,
"minute": 0,
"second": 0,
"nano": 0
}
},
Removing the timestamp did not work
This is the Method to create the OwnBidParameterEntities:
private OwnBidParameterEntity createOwnBidParamEntity() throws IOException {
return JSONReader.readJsonDocument(getClass().getClassLoader(),
OwnBidParameterEntity.class,
SAMPLE_OWN_BID_PARAM_ENTITY_PATH);
}
And this is the corresponding json:
{
"volumePe": 600.0,
"auctionAward": 90.0,
"priceP0": 20.0,
"pricePE": 250,
"strategy": "NOT YET IMPLEMENTED",
"refPriceCH": 0.0,
"optimalPrice": 0.0,
"priceOffsetPercent": 10,
"priceOffset": 20,
"calculatedStartPrice": 20.0,
"fixedVolume": 3,
"maxVolume": 600.0,
"volumeFactor": 4,
"maxStandingVolume": 500,
"minPercentRotating": 0,
"interpolationParameters": [
{
"stepSize": 5,
"volumePercent": 10,
"pricePercent": 10,
"calculatedPrice": 43.0,
"calculatedVolumeManual": 60.0
},
{
"stepSize": 5,
"volumePercent": 20,
"pricePercent": 20,
"calculatedPrice": 66.0,
"calculatedVolumeManual": 120.0
},
{
"stepSize": 5,
"volumePercent": 30,
"pricePercent": 30,
"calculatedPrice": 89.0,
"calculatedVolumeManual": 180.0
},
{
"stepSize": 5,
"volumePercent": 40,
"pricePercent": 40,
"calculatedPrice": 112.0,
"calculatedVolumeManual": 240.0
},
{
"stepSize": 5,
"volumePercent": 80,
"pricePercent": 100,
"calculatedPrice": 250.0,
"calculatedVolumeManual": 480.0
}
],
"startTimeEntity": {
"id": 10,
"year": 2020,
"month": 1,
"day": 1,
"hour": 10,
"minute": 0,
"cetOffsetToUtc": 1
},
"endTimeEntity": {
"id": 11,
"year": 2020,
"month": 1,
"day": 1,
"hour": 11,
"minute": 0,
"cetOffsetToUtc": 1
},
"marketParticipantEntity": {
"id": 1,
"marketParticipantMRid": "XYZ"
},
"productEntity": {
"businessType": "A10",
"productName": "TRE_PLUS",
"direction": "A01",
"activationConstraint": "PT15M"
},
"marketEntity": {
"id": 1,
"area": "CH",
"auctionMRId": "something"
},
"ascoBidId": 42
}
I'm currently using Java Version 17.0.8. Does anyone have any ideas or suggestions on what might be causing this issue? Your help would be greatly appreciated!
OwnBidParameterIntegrationTest#createOwnBidParamEntitymethod?