question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JPA runtime exception: java.lang.ClassNotFoundException: javassist.bytecode.ClassFile

See original GitHub issue

Everything is fine if running the project from IDEA, but getting the following runtime exception (jar mode, not graalvm):

~/Documents/dev/src/Notes/NotesServerApp asmirnov$java -jar app-micronaut/build/libs/app-micronaut-1.1-all.jar
01:20:56.763 [main] INFO  io.micronaut.runtime.Micronaut - Startup completed in 6349ms. Server Running: http://localhost:8080
01:21:04.933 [pool-1-thread-1] INFO  o.h.jpa.internal.util.LogHelper - HHH000204: Processing PersistenceUnitInfo [name: NotesProductionPersistenceUnit]
01:21:04.975 [pool-1-thread-1] INFO  org.hibernate.Version - HHH000412: Hibernate Core {[WORKING]}
01:21:05.142 [pool-1-thread-1] INFO  o.h.annotations.common.Version - HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
01:21:05.220 [pool-1-thread-1] ERROR i.m.h.s.netty.RoutingInBoundHandler - Unexpected error occurred: Error instantiating bean of type  [name.antonsmirnov.notes.controller.rest.ListNotesController]

Message: javassist/bytecode/ClassFile
Path Taken: ListNotesController.useCase
io.micronaut.context.exceptions.BeanInstantiationException: Error instantiating bean of type  [name.antonsmirnov.notes.controller.rest.ListNotesController]

Message: javassist/bytecode/ClassFile
Path Taken: ListNotesController.useCase
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1555)
	at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:2248)
	at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1917)
	at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1892)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1007)
	at name.antonsmirnov.notes.$Configuration$GetListNotesUseCase1Definition.build(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1535)
	at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:2248)
	at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1917)
	at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1892)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:1021)
	at io.micronaut.context.AbstractBeanDefinition.getBeanForField(AbstractBeanDefinition.java:1379)
	at io.micronaut.context.AbstractBeanDefinition.injectBeanField(AbstractBeanDefinition.java:714)
	at name.antonsmirnov.notes.controller.rest.$ListNotesControllerDefinition.injectBean(Unknown Source)
	at name.antonsmirnov.notes.controller.rest.$ListNotesControllerDefinition.build(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1535)
	at io.micronaut.context.DefaultBeanContext.createAndRegisterSingleton(DefaultBeanContext.java:2248)
	at io.micronaut.context.DefaultBeanContext.getBeanForDefinition(DefaultBeanContext.java:1917)
	at io.micronaut.context.DefaultBeanContext.getBeanInternal(DefaultBeanContext.java:1892)
	at io.micronaut.context.DefaultBeanContext.getBean(DefaultBeanContext.java:577)
	at io.micronaut.context.DefaultBeanContext$BeanExecutionHandle.getTarget(DefaultBeanContext.java:2769)
	at io.micronaut.context.DefaultBeanContext$BeanExecutionHandle.invoke(DefaultBeanContext.java:2790)
	at io.micronaut.web.router.AbstractRouteMatch.execute(AbstractRouteMatch.java:235)
	at io.micronaut.web.router.RouteMatch.execute(RouteMatch.java:122)
	at io.micronaut.http.server.netty.RoutingInBoundHandler.lambda$buildResultEmitter$19(RoutingInBoundHandler.java:1408)
	at io.reactivex.internal.operators.flowable.FlowableCreate.subscribeActual(FlowableCreate.java:71)
	at io.reactivex.Flowable.subscribe(Flowable.java:14918)
	at io.reactivex.Flowable.subscribe(Flowable.java:14865)
	at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:68)
	at io.reactivex.Flowable.subscribe(Flowable.java:14918)
	at io.reactivex.internal.operators.flowable.FlowableMap.subscribeActual(FlowableMap.java:37)
	at io.reactivex.Flowable.subscribe(Flowable.java:14918)
	at io.reactivex.Flowable.subscribe(Flowable.java:14865)
	at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:68)
	at io.reactivex.Flowable.subscribe(Flowable.java:14918)
	at io.reactivex.internal.operators.flowable.FlowableSwitchIfEmpty.subscribeActual(FlowableSwitchIfEmpty.java:32)
	at io.reactivex.Flowable.subscribe(Flowable.java:14918)
	at io.reactivex.Flowable.subscribe(Flowable.java:14865)
	at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:68)
	at io.reactivex.Flowable.subscribe(Flowable.java:14918)
	at io.reactivex.Flowable.subscribe(Flowable.java:14868)
	at io.micronaut.http.context.ServerRequestTracingPublisher.lambda$subscribe$0(ServerRequestTracingPublisher.java:52)
	at io.micronaut.http.context.ServerRequestContext.with(ServerRequestContext.java:52)
	at io.micronaut.http.context.ServerRequestTracingPublisher.subscribe(ServerRequestTracingPublisher.java:52)
	at io.reactivex.internal.operators.flowable.FlowableFromPublisher.subscribeActual(FlowableFromPublisher.java:29)
	at io.reactivex.Flowable.subscribe(Flowable.java:14918)
	at io.reactivex.Flowable.subscribe(Flowable.java:14865)
	at io.micronaut.reactive.rxjava2.RxInstrumentedFlowable.subscribeActual(RxInstrumentedFlowable.java:68)
	at io.reactivex.Flowable.subscribe(Flowable.java:14918)
	at io.reactivex.Flowable.subscribe(Flowable.java:14865)
	at io.reactivex.internal.operators.flowable.FlowableSubscribeOn$SubscribeOnSubscriber.run(FlowableSubscribeOn.java:82)
	at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker$BooleanRunnable.run(ExecutorScheduler.java:288)
	at io.reactivex.internal.schedulers.ExecutorScheduler$ExecutorWorker.run(ExecutorScheduler.java:253)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
	at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.toClassFile(ClassFileArchiveEntryHandler.java:61)
	at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.handleEntry(ClassFileArchiveEntryHandler.java:47)
	at org.hibernate.boot.archive.internal.JarFileBasedArchiveDescriptor.visitArchive(JarFileBasedArchiveDescriptor.java:147)
	at org.hibernate.boot.archive.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:47)
	at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:76)
	at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:98)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:234)
	at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:174)
	at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:76)
	at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:171)
	at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:119)
	at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:61)
	at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:50)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
	at name.antonsmirnov.notes.Configuration.<init>(Application.kt:12)
	at name.antonsmirnov.notes.$ConfigurationDefinition.build(Unknown Source)
	at io.micronaut.context.DefaultBeanContext.doCreateBean(DefaultBeanContext.java:1535)
	... 55 common frames omitted
Caused by: java.lang.ClassNotFoundException: javassist.bytecode.ClassFile
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 73 common frames omitted

Any transitive dependencies lost?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
4ntoinecommented, Oct 10, 2019

Is there any possibility to configure it without using of “application.yaml” in resources and having 100500 micronaut-specific annotations in source code and 100500 micronaut-specific modules dependencies ?

0reactions
graemerochercommented, Sep 23, 2019

Since you are creating the entity manager yourself it is using whatever the defaults you request. The Hibernate defaults are such that a bytecode provider is necessary and in this case javassist. This is not a Micronaut problem but a problem with the way you have configured your application.

You have a few options.

  1. Add javassist to your classpath
  2. Don’t use bytecode enhancement but instead build time enhancment. See the example here which uses Hibernate’s plugin to do this https://github.com/micronaut-projects/micronaut-data/blob/master/examples/example-jpa/build.gradle#L6
  3. Switch to another bytecode provider (like bytebuddy) that is on the classpath
Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring boot: javassist not found
When I'm trying to run my application I've got java.lang.ClassNotFoundException: javassist.bytecode.ClassFile So I gueesed javassit jar was ...
Read more >
Sonar Qube - java.lang.NoClassDefFoundError: javassist ...
My team is starting to use Sonar Qube as our "code coverage helper" and when we try "mvn sonar:sonar" or "mvn clean install...
Read more >
java.lang.ClassNotFoundException : javassist.util.proxy. ...
Problem. Using Hibernate 3.6.3, but hits this javassist not found error, see below for error stacks : Caused by: java.lang.
Read more >
3 ways to solve java.lang.NoClassDefFoundError in Java ...
ClassNotFoundException comes when JVM tries to load a class at runtime dynamically means you give the name of the class at runtime and...
Read more >
View Bytecode of a Class File in Java
Explore ways to view the bytecode of a class file in Java. ... InterruptedException; public final void wait() throws java.lang.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found