Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jollyday fails with Java 16 #148

Open
alexoooo opened this issue Mar 22, 2021 · 1 comment
Open

Jollyday fails with Java 16 #148

alexoooo opened this issue Mar 22, 2021 · 1 comment

Comments

@alexoooo
Copy link

alexoooo commented Mar 22, 2021

Jollyday uses JAXB to read the configuration XML, this results in illegal access violations.
In Java 16 some of the illegal access violations that used to be flagged as warnings have been escalated to errors.

I was able to get around the issue using XStream instead of JAXB, first exporting the config using Java 15:

ManagerParameter parameter = ManagerParameters.create(calendarPart);
Configuration configuration = HolidayManager.getInstance(parameter).getConfigurationDataSource().getConfiguration(parameter);
String export = new XStream().toXML(configuration);

Then replace the contents of Holidays_[x].xml with the XStream format, and load them back with Java 16:

HolidayManager manager = new DefaultHolidayManager();
manager.setConfigurationDataSource(new XStreamConfigurationDataSource());

ManagerParameter parameter = ManagerParameters.create(calendarPart);
new ConfigurationProviderManager().mergeConfigurationProperties(parameter);
manager.init(parameter);

private static class XStreamConfigurationDataSource implements ConfigurationDataSource {
	@Override
	public Configuration getConfiguration(ManagerParameter managerParameter) {
		URL resourceUrl = managerParameter.createResourceUrl();
		try (InputStream inputStream = resourceUrl.openStream()) {
			return (Configuration) new XStream().fromXML(inputStream);
		}
		catch (IOException e) {
			throw new UncheckedIOException(e);
		}
	}
}
@fanste
Copy link
Contributor

fanste commented Jun 7, 2021

I'm able to run jollyday on JDK 16 and JAXB as long as a JAXB implementation is available on the classpath. In my case I used the newer implementation from Jakarta (see https://eclipse-ee4j.github.io/jaxb-ri/)

    <!--dependency>
        <groupId>jakarta.xml.bind</groupId>
        <artifactId>jakarta.xml.bind-api</artifactId>
        <version>3.0.0</version>
    </dependency-->
    <dependency>
        <groupId>com.sun.xml.bind</groupId>
        <artifactId>jaxb-impl</artifactId>
        <version>3.0.0</version>
        <scope>runtime</scope>
    </dependency>

The Jakarta compatible jollday artifact is produced by a fixed pom.xml which could be found in the pull request #150.

But it should also work with jaxb-impl version 2.x which still uses the legacy javax namespace (totally untested).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants