0

Issue on Mac OS X 10.13.6 x86_64 using Java 17 Temurin on users machine, but cannot replicate locally

This code is failing

  static
    {
        try
        {
            jc = JAXBContext.newInstance("com.jthink.musicschema");

        }
        catch (JAXBException e)
        {
            throw new RuntimeException("Unable to create SongKong prepared statement:" + e.getMessage(), e);
        }
    }

With

28/05/2022 08.23.18:EDT:UncaughtExceptionHandler:uncaughtException:SEVERE: An unexpected error has occurred  on thread main, please report to support @jthink.net
java.lang.ExceptionInInitializerError
    at com.jthink.songkong.cmdline.SongKong.checkCache(SongKong.java:1380)
    at com.jthink.songkong.cmdline.SongKong.guiStart(SongKong.java:1166)
    at com.jthink.songkong.cmdline.SongKong.finish(SongKong.java:1251)
    at com.jthink.songkong.cmdline.SongKong.main(SongKong.java:1276)
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.reflect.Method.invoke(Object, Object[])" because "com.sun.xml.bind.v2.runtime.reflect.opt.Injector.defineClass" is null
    at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Injector.java:311)
    at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.inject(Injector.java:97)
    at com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector.prepare(AccessorInjector.java:87)
    at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:179)
    at com.sun.xml.bind.v2.runtime.reflect.Accessor$FieldReflection.optimize(Accessor.java:285)
    at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.<init>(SingleElementLeafProperty.java:92)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at com.sun.xml.bind.v2.runtime.property.PropertyFactory.create(PropertyFactory.java:128)
    at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.<init>(ClassBeanInfoImpl.java:181)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:514)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:331)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:139)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1156)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:165)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:289)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:217)
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:175)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:353)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:508)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:465)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:366)
    at com.jthink.songkong.cache.AlbunackCache.<clinit>(AlbunackCache.java:37)
    ... 4 more

and this similar question explains it is because Java 17 doesnt have jaxb classes inbuilt. However I know this and already include them in my maven build

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-core</artifactId>
            <version>2.3.0</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <version>2.3.1</version>
        </dependency>

and the problem seems to only occurs for one user.

Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
  • 1
    According to https://github.com/highsource/maven-jaxb2-plugin/issues/207 the developer Matt Pavlovich hopes that 3.0.0 will fix the issue – Holger May 31 '22 at 09:27
  • @Holger Im not using jaxb plugin in this project (since Im not defining xml jaxb mappings just using jaxb to marshall xml into classes created with another project. But it does make me wonder should I be using javax.xml.bind or jakarta.xml.bind and if so what are the equivalent core and impl dependencies to go with it. – Paul Taylor May 31 '22 at 09:40

0 Answers0