hibernate with jbang fails with class loader issue
See original GitHub issueDescribe the bug use this code:
//usr/bin/env jbang "$0" "$@" ; exit $?
//DEPS io.quarkus:quarkus-picocli:1.8.0.CR1
//DEPS io.quarkus:quarkus-hibernate-orm-panache:1.8.0.CR1
//DEPS io.quarkus:quarkus-jdbc-postgresql:1.8.0.CR1
//JAVA_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager
//Q:CONFIG quarkus.banner.enabled=false
//Q:CONFIG quarkus.log.level=WARN
//Q:CONFIG quarkus.datasource.db-kind = postgresql
//Q:CONFIG quarkus.datasource.username = sarah
//Q:CONFIG quarkus.datasource.password = connor
//Q:CONFIG quarkus.datasource.jdbc.url = jdbc:tc:postgresql:9.6.8:///databasename
//Q:CONFIG quarkus.hibernate-orm.database.generation = drop-and-create
import io.quarkus.hibernate.orm.panache.PanacheEntity;
import picocli.CommandLine;
import javax.enterprise.context.Dependent;
import javax.inject.Inject;
import javax.persistence.Entity;
import io.quarkus.runtime.annotations.QuarkusMain;
import io.quarkus.runtime.QuarkusApplication;
import java.time.LocalDate;
import java.util.List;
@QuarkusMain
@CommandLine.Command
public class quarkusclidb implements Runnable, QuarkusApplication {
@CommandLine.Option(names = {"-n", "--name"}, description = "Who will we greet?", defaultValue = "World")
String name;
@Inject
CommandLine.IFactory factory;
private final GreetingService greetingService;
public quarkusclidb(GreetingService greetingService) {
this.greetingService = greetingService;
}
@Override
public void run() {
greetingService.sayHello(name);
}
@Override
public int run(String... args) throws Exception {
return new CommandLine(this, factory).execute(args);
}
public static void main(String... args) {
io.quarkus.runtime.Quarkus.run(quarkusclidb.class, args);
}
@Entity
static public class Person extends PanacheEntity {
public String name;
public LocalDate birth;
public String status;
public static Person findByName(String name){
return find("name", name).firstResult();
}
public static List<Person> findAlive(){
return list("status", "alive");
}
public static void deleteStefs(){
delete("name", "Stef");
}
}
}
@Dependent
class GreetingService {
void sayHello(String name) {
System.out.println("Hello " + name + "!");
}
}
build/run it with: jbang quarkusclidb.java
and you get:
[jbang] Post build with io.quarkus.launcher.JBangIntegration
Sep 05, 2020 12:42:05 AM org.jboss.threads.Version <clinit>
INFO: JBoss Threads version 3.1.1.Final
Sep 05, 2020 12:42:05 AM io.quarkus.agroal.deployment.AgroalProcessor build
WARN: The Agroal dependency is present but no JDBC datasources have been defined.
dev.jbang.ExitException: Issue running postBuild()
at dev.jbang.IntegrationManager.runIntegration(IntegrationManager.java:116)
at dev.jbang.cli.Run.build(Run.java:217)
at dev.jbang.cli.Run.doCall(Run.java:97)
at dev.jbang.cli.BaseCommand.call(BaseCommand.java:59)
at dev.jbang.cli.BaseCommand.call(BaseCommand.java:13)
at picocli.CommandLine.executeUserObject(CommandLine.java:1933)
at picocli.CommandLine.access$1100(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2332)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2326)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2291)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2159)
at picocli.CommandLine.execute(CommandLine.java:2058)
at dev.jbang.Main.main(Main.java:14)
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 dev.jbang.IntegrationManager.runIntegration(IntegrationManager.java:89)
... 12 more
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at io.quarkus.launcher.JBangIntegration.postBuild(JBangIntegration.java:85)
... 17 more
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 io.quarkus.launcher.JBangIntegration.postBuild(JBangIntegration.java:77)
... 17 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#parsePersistenceXmlDescriptors threw an exception: java.lang.NoClassDefFoundError: org/xml/sax/SAXException
at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.parsePersistenceXmlDescriptors(HibernateOrmProcessor.java:225)
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 io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:936)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: java.lang.ClassNotFoundException: org.xml.sax.SAXException
at io.quarkus.launcher.RuntimeLaunchClassLoader.findClass(RuntimeLaunchClassLoader.java:25)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:406)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:363)
... 13 more
at io.quarkus.bootstrap.JBangBuilderImpl.postBuild(JBangBuilderImpl.java:81)
... 22 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#parsePersistenceXmlDescriptors threw an exception: java.lang.NoClassDefFoundError: org/xml/sax/SAXException
at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.parsePersistenceXmlDescriptors(HibernateOrmProcessor.java:225)
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 io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:936)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: java.lang.ClassNotFoundException: org.xml.sax.SAXException
at io.quarkus.launcher.RuntimeLaunchClassLoader.findClass(RuntimeLaunchClassLoader.java:25)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:406)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:363)
... 13 more
at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:132)
at io.quarkus.bootstrap.app.CuratedApplication.runInAugmentClassLoader(CuratedApplication.java:82)
at io.quarkus.bootstrap.JBangBuilderImpl.postBuild(JBangBuilderImpl.java:78)
... 22 more
Caused by: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#parsePersistenceXmlDescriptors threw an exception: java.lang.NoClassDefFoundError: org/xml/sax/SAXException
at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.parsePersistenceXmlDescriptors(HibernateOrmProcessor.java:225)
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 io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:936)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: java.lang.ClassNotFoundException: org.xml.sax.SAXException
at io.quarkus.launcher.RuntimeLaunchClassLoader.findClass(RuntimeLaunchClassLoader.java:25)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:406)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:363)
... 13 more
at io.quarkus.deployment.jbang.JBangAugmentorImpl.accept(JBangAugmentorImpl.java:119)
at io.quarkus.deployment.jbang.JBangAugmentorImpl.accept(JBangAugmentorImpl.java:36)
at io.quarkus.bootstrap.app.CuratedApplication.runInCl(CuratedApplication.java:129)
... 24 more
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#parsePersistenceXmlDescriptors threw an exception: java.lang.NoClassDefFoundError: org/xml/sax/SAXException
at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.parsePersistenceXmlDescriptors(HibernateOrmProcessor.java:225)
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 io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:936)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: java.lang.ClassNotFoundException: org.xml.sax.SAXException
at io.quarkus.launcher.RuntimeLaunchClassLoader.findClass(RuntimeLaunchClassLoader.java:25)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:406)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:363)
... 13 more
at io.quarkus.builder.Execution.run(Execution.java:116)
at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:149)
at io.quarkus.deployment.jbang.JBangAugmentorImpl.accept(JBangAugmentorImpl.java:97)
... 26 more
Caused by: java.lang.NoClassDefFoundError: org/xml/sax/SAXException
at io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor.parsePersistenceXmlDescriptors(HibernateOrmProcessor.java:225)
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 io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:936)
at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
at java.base/java.lang.Thread.run(Thread.java:834)
at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: java.lang.ClassNotFoundException: org.xml.sax.SAXException
at io.quarkus.launcher.RuntimeLaunchClassLoader.findClass(RuntimeLaunchClassLoader.java:25)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:406)
at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:363)
... 13 more
Probably similar issue as in #11542 where we found places TCCL was not put as a fallback for class.forname.
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (13 by maintainers)
Top Results From Across the Web
JPA class loading issue with Hibernate - java - Stack Overflow
The issue was that the libraries that loads the libraries which scans for annotated @Entity classes is not in the lib folder for...
Read more >Class Loading Reference - Quarkus
When running a production application using the legacy-jar package type everything is loaded in the system ClassLoader, so it is a completely flat...
Read more >Home of Quarkus Cheat-Sheet - GitHub Pages
Quarkus is a Kubernetes Native Java stack tailored for GraalVM & OpenJDK HotSpot, crafted from the best of breed Java libraries and standards....
Read more >quarkusio/quarkus 1.8.0.Final on GitHub - NewReleases.io
CR1; #11913 - hibernate with jbang fails with class loader issue; #11912 - Make native tests work with random port; #11911 - -Dquarkus.http.host=0.0.0.0 ......
Read more >Unable to load class InfinispanDirectoryProvider - JBoss.org
I'm trying to create a project in wildfly 10 using infinispan as second cache for hibernate. When deploying my project I get the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
hum, sorry yes it seemed to work but I forgot to use
--verbose
. It actually still fails.with #11957 this updated (as the original had bugs/was incomplete) works: