Git Product home page Git Product logo

Comments (2)

boncey avatar boncey commented on July 1, 2024

I can replicate this by checking out this project and running ApplicationValidatorTest under Java 11.

    Failed to call configuration validation method
    
    java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
    
        at com.google.common.base.Throwables.propagate(Throwables.java:160)
        at com.jamierf.dropwizard.debpkg.validation.ApplicationValidator.validateConfiguration(ApplicationValidator.java:71)
        at com.jamierf.dropwizard.debpkg.validation.ApplicationValidator.validateConfiguration(ApplicationValidator.java:48)
        at com.jamierf.dropwizard.debpkg.validation.ApplicationValidatorTest.testValidConfiguration(ApplicationValidatorTest.java:50)
        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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
        at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
        at org.junit.rules.RunRules.evaluate(RunRules.java:20)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:77)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:56)
        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 com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
        at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
        at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
        at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
    Caused by: java.lang.reflect.InvocationTargetException
        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 com.jamierf.dropwizard.debpkg.validation.ApplicationValidator.validateConfiguration(ApplicationValidator.java:59)
        ... 27 more
    Caused by: java.lang.NoClassDefFoundError: javax/sql/DataSource
        at io.dropwizard.hibernate.HibernateBundle.<init>(HibernateBundle.java:20)
        at com.example.helloworld.HelloWorldApplication$1.<init>(HelloWorldApplication.java:26)
        at com.example.helloworld.HelloWorldApplication.<init>(HelloWorldApplication.java:25)
        at com.example.helloworld.HelloWorldApplication.main(HelloWorldApplication.java:22)
        ... 32 more
    Caused by: java.lang.ClassNotFoundException: javax.sql.DataSource
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 36 more

from dropwizard-debpkg-maven-plugin.

boncey avatar boncey commented on July 1, 2024

This change fixes the problem.

    --- a/src/main/java/com/jamierf/dropwizard/debpkg/validation/ApplicationValidator.java
    +++ b/src/main/java/com/jamierf/dropwizard/debpkg/validation/ApplicationValidator.java
    @@ -26,7 +26,7 @@ public class ApplicationValidator {
             this.log = log;
     
             // Set parent to null to avoid pulling in SLF4J and other conflicts from our self
    -        classLoader = new URLClassLoader(new URL[]{artifactFile.toURI().toURL()}, null);
    +        classLoader = new URLClassLoader(new URL[]{artifactFile.toURI().toURL()}, ClassLoader.getPlatformClassLoader());
         }
     
         private Class<?> getMainClass() throws IOException, ClassNotFoundException {

There was a change in Java 11 to the ClassLoader.

In Java 11, the boot class loader only loads core modules. If you create a class loader with a null parent, it may not find all platform classes. In Java 11, you need to pass ClassLoader.getPlatformClassLoader() instead of null as the parent class loader in such cases.

However, that change requires at least Java version 9 so it will no longer work with Java 8.
Also, the HelloWorld application used in the tests will need updating to Java 11 too.

-Also, I was unable to get the code to build locally so I can't even roll my own fork.-

Got it built locally by upgrading maven-plugin-plugin to 3.6.0. 👍

Update:

I've pushed my various hacks and fixes to https://github.com/boncey/dropwizard-debpkg-maven-plugin/tree/java-11-changes.
I won't raise a PR as I think it will need some cleanup work and it will also most like break Java 8 compatibility.

from dropwizard-debpkg-maven-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.