To support JDK17 compilation, I updated my project's Maven compiler plugin source from 1.6 to 1.8..
Now, I can build it with JDK17, but during the JUnit test, one of the test cases is failing, and it seems to be related to JiBX.
Encountering the same issue with 1.7 also but version 1.6 works fine
Tests in error:
testAll(com.jk.rpt.health.report.CompHealthReportTest): class com.jk.rpt.var.JiBX_ActionListBindingMungeAdapter tried to access protected method 'boolean com.jk.rpt.health.report.CompHealthStats.isSummaryAvailable()' (com.jk.rpt.var.JiBX_ActionListBindingMungeAdapter and com.jk.rpt.health.report.CompHealthStats are in unnamed module of loader 'app')
Test set: com.jk.rpt.health.report.CompHealthReportTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.138 sec <<< FAILURE!
testAll(com.jk.rpt.health.report.CompHealthReportTest) Time elapsed: 0.006 sec <<< ERROR!
java.lang.IllegalAccessError: class com.jk.rpt.var.JiBX_ActionListBindingMungeAdapter tried to access protected method 'boolean com.jk.rpt.health.report.CompHealthStats.isSummaryAvailable()' (com.jk.rpt.var.JiBX_ActionListBindingMungeAdapter and com.jk.rpt.health.report.CompHealthStats are in unnamed module of loader 'app')
at com.jk.rpt.var.JiBX_ActionListBindingMungeAdapter.JiBX_CompHealthBinding_marshal_1_179()
at com.jk.rpt.var.JiBX_CompHealthBindingCompHealthStats_access.marshal()
at com.jk.rpt.health.report.CompHealthStats.marshal(CompHealthStats.java)
at com.jk.rpt.var.JiBX_ActionListBindingMungeAdapter.JiBX_ActionListBinding_marshal_1_4()
at com.jk.rpt.var.JiBX_ActionListBindingMungeAdapter.JiBX_ActionListBinding_marshal_1_23()
at com.jk.rpt.var.JiBX_CompHealthBindingBasicReportElement_access.marshal()
at com.jk.rpt.BasicReportElement.marshal(BasicReportElement.java)
at com.jk.rpt.var.JiBX_ActionListBindingMungeAdapter.JiBX_ActionListBinding_marshal_1_10()
at com.jk.rpt.var.JiBX_ActionListBindingMungeAdapter.JiBX_ActionBinding_marshal_1_41()
at com.jk.rpt.var.JiBX_CompHealthBindingReport_access.marshal()
at com.jk.rpt.Report.marshal(Report.java)
at org.jibx.runtime.impl.MarshallingContext.marshalRoot(MarshallingContext.java:1021)
at org.jibx.runtime.impl.MarshallingContext.marshalDocument(MarshallingContext.java:1041)
at com.jk.rpt.Report.marshalDocument(Report.java:134)
at com.jk.rpt.cdr.report.AbstractReportTest.verifyReport(AbstractReportTest.java:75)
at com.jk.rpt.health.report.CompHealthReportTest.testAll(CompHealthReportTest.java:87)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at junit.framework.TestCase.runTest(TestCase.java:176)
at junit.framework.TestCase.runBare(TestCase.java:141)
at junit.framework.TestResult$1.protect(TestResult.java:122)
at junit.framework.TestResult.runProtected(TestResult.java:142)
at junit.framework.TestResult.run(TestResult.java:125)
at junit.framework.TestCase.run(TestCase.java:129)
at junit.framework.TestSuite.runTest(TestSuite.java:252)
at junit.framework.TestSuite.run(TestSuite.java:247)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:86)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at org.junit.runner.JUnitCore.run(JUnitCore.java:105)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:52)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:112)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:164)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:110)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:172)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcessWhenForked(SurefireStarter.java:104)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:70)
Pom file:
<dependencies>
<dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-run</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.jibx</groupId>
<artifactId>jibx-extras</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.restlet.jse</groupId>
<artifactId>org.restlet</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.5.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20230618</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.15.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.15.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.3</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>test</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>jing</groupId>
<artifactId>jing</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/thirdparty-lib/jing.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-resources-1</id>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/test-classes/Core</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/test/java</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.txt</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<configuration>
<skip>false</skip>
<workingDirectory>${project.build.directory}/test-classes</workingDirectory>
<argLine>-Duser.timezone=America/New_York</argLine>
<excludes>
<exclude>**/*Suite.java</exclude>
</excludes>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.9</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>testExecution</id>
<phase>test</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>copyDependencies</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>normal</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<!-- Empty default profile -->
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<configuration>
<additionalConfig>
<file>
<name>.settings/org.eclipse.core.resources.prefs</name>
<content>
<![CDATA[eclipse.preferences.version=1${line.separator}encoding/<project>=${project.build.sourceEncoding}${line.separator}]]>
</content>
</file>
</additionalConfig>
</configuration>
</configuration>
<version>2.10</version>
</plugin>
<plugin>
<groupId>org.jibx</groupId>
<artifactId>maven-jibx-plugin</artifactId>
<version>1.3.1</version>
<configuration>
<directory>src/main/jibx</directory>
<includes>
<includes>DefaultReportBinding.xml</includes>
<includes>ActionBinding.xml</includes>
<includes>TenantOutbUsageBinding.xml</includes>
<includes>CompHealthBinding.xml</includes>
<includes>WADLApplicationBinding.xml</includes>
<includes>ActionListBinding.xml</includes>
</includes>
<verbose>true</verbose>
<load>true</load>
</configuration>
<executions>
<execution>
<goals>
<goal>bind</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.bcel</groupId>
<artifactId>bcel</artifactId>
<version>6.6.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
ActionListBinding.xml file:
<?xml version="1.0"?>
<binding direction="output">
<include path="DetailsReportBinding.xml"/>
<mapping name="call-details" class="com.jk.rpt.var.ActionDetails">
<structure field="cdr" type="com.jk.rpt.var.VARCallDetailRecord"/>
<collection name="action-list" get-method="getActionChildList" usage="optional">
<structure map-as="com.jk.rpt.var.ActionRecord"/>
</collection>
</mapping>
<mapping name="action" class="com.jk.rpt.var.ActionRecord">
<value style="attribute" name="action-id" get-method="getActionId"/>
<value style="attribute" name="start-time" get-method="getStartString"
usage="optional"/>
<value style="attribute" name="duration" get-method="getDuration"/>
<value style="attribute" name="result" get-method="getResult" usage="optional"/>
<value style="attribute" name="reason" get-method="getReason" usage="optional"/>
<collection name="notes" get-method="getNotes" usage="optional">
<value name="note"/>
</collection>
<value style="attribute" name="implicitly-ended" get-method="isImplicitlyEnded"/>
<collection name="action-list" get-method="getActionList" usage="optional">
<structure map-as="com.jk.rpt.var.ActionRecord"/>
</collection>
</mapping>
</binding>
CompHealthBinding :
<?xml version="1.0"?>
<binding direction="output">
<include path="ReportBinding.xml"/>
<mapping name="request-params" class="com.jk.rpt.ReportRequest">
<structure map-as="ReportRequest"/>
</mapping>
<mapping name="comp-snmp-stats" class="com.jk.rpt.BasicReportElement">
<collection field="items" usage="optional"/>
</mapping>
<mapping name="comp-snmp" class="com.jk.rpt.health.report.CompHealthStats">
<value style="attribute" name="last-updated" get-method="getLastUpdated"/>
<structure field="component"/>
<structure name="snmp-summary" usage="optional" test-method="isSummaryAvailable">
<collection get-method="getSummary"/>
</structure>
<structure name="snmp-details" usage="optional" test-method="isDetailsAvailable">
<collection get-method="getDetails"/>
</structure>
</mapping>
<mapping name="snmp-oid" class="com.jk.rpt.health.report.SnmpDataItem">
<value style="attribute" name="name" get-method="getName"/>
<value style="attribute" name="value" get-method="getValue"/>
</mapping>
<mapping name="snmp-table-row" class="com.jk.rpt.health.report.SnmpDataRow">
<value style="attribute" name="name" get-method="getTableName"/>
<value style="attribute" name="index" get-method="getGroupByInstance"/>
<collection get-method="getTableItems" usage="optional" />
</mapping>
</binding>
CompHealthStats.java :
package com.jk.rpt.health.report;
import java.util.Collection;
import java.util.Date;
import com.jk.rpt.Component;
import com.jk.rpt.ComponentType;
import com.jk.rpt.health.ICompHealthItem;
import com.jk.rpt.health.ICompHealthTable;
public class CompHealthStats {
protected Component component = new Component();
protected Collection<? extends ICompHealthItem> summary;
protected Collection<? extends ICompHealthTable> details;
private Date lastUpdated = new Date();
public Long getCompId() {
return component.getId();
}
public void setCompId(Long id) {
component.setId(id);
}
public int getCompType()
{
return component.getType().getCompType();
}
public void setCompType(int type)
{
component.setType(ComponentType.valueOf(type));
}
public void setComponent(Component component) {
this.component = component != null ? component : this.component;
}
public Component getComponent()
{
return this.component;
}
public Collection<? extends ICompHealthItem> getSummary()
{
return this.summary;
}
/**
* this is introduced to enable JiBX binding to skip empty summary section when marshalling
* It is not a part of public API
* @return
*/
protected boolean isSummaryAvailable()
{
return this.summary != null;
}
public Collection<? extends ICompHealthTable> getDetails()
{
return this.details;
}
/**
* this is introduced to enable JiBX binding to skip empty details section when marshalling
* It is not a part of publis API
* @return
*/
protected boolean isDetailsAvailable()
{
return this.details != null;
}
public void setSummary(Collection<? extends ICompHealthItem> summary)
{
this.summary = summary;
}
public void setDetails(Collection<? extends ICompHealthTable> details)
{
this.details = details;
}
/**
* provide a timestamp when this health stat was created
* @return
*/
public Date getLastUpdated() {
return lastUpdated;
}
/**
* update timestamp
* @param now
*/
public void setLastUpdated(Date now) {
this.lastUpdated = now;
}
}
Try using the latest version of JiBX (1.4.2). You cannot mix JiBX components from different versions like you have in this example: