Error java.lang.ClassNotFoundException: "Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.type.TypeReference

5

I'm developing a Java, FX, Hibernate application and using log4j2 for my logs. When I run the application through the IDE (Eclipse) everything works normally, but when creating the application .jar, the following errors appear (just when starting the database in Hibernate):

26/01/2016 11:22:32.186 [ INFO] LogHelper.java:31 - HHH000204: Processing PersistenceUnitInfo [
    name: crp
    ...]
26/01/2016 11:22:32.243 [ INFO] Version.java:37 - HHH000412: Hibernate  Core {5.0.7.Final}
26/01/2016 11:22:32.248 [ INFO] Environment.java:198 - HHH000205: Loaded properties from resource hibernate.properties: {hibernate.bytecode.use_reflection_optimizer=false}
26/01/2016 11:22:32.250 [ INFO] Environment.java:317 - HHH000021:Bytecode provider name : javassist
26/01/2016 11:22:32.293 [ INFO] JavaReflectionManager.java:66 - HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
26/01/2016 11:22:33.761 [ERROR] Conexao.java:20 - Erro em Persistence.createEntityManagerFactory(crp) => Unable to build entity manager factory javax.persistence.PersistenceException: Unable to build entity manager factory at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:66)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
    at br.org.eldorado.crp.util.Conexao.<clinit>(Conexao.java:18)
    at br.org.eldorado.crp.controller.Tasks$2.call(Tasks.java:39)
    at br.org.eldorado.crp.controller.Tasks$2.call(Tasks.java:1)
    at javafx.concurrent.Task$TaskCallable.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [org.apache.logging.log4j.core.appender.
db.jpa.converter.ContextMapJsonAttributeConverter] 
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:232)
    at org.hibernate.boot.model.process.internal.ScanningCoordinator.applyScanResultsToManagedResources(ScanningCoordinator.java:235)
    at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:81)
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:98)
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:194)
    at org.hibernate.jpa.boot.spi.Bootstrap.getEntityManagerFactoryBuilder(Bootstrap.java:34)
    at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilder(HibernatePersistenceProvider.java:165)
    at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:114)
    at org.hibernate.jpa.HibernatePersistenceProvider.getEntityManagerFactoryBuilderOrNull(HibernatePersistenceProvider.java:71)
    at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:52)
    ... 8 more
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/type/TypeReference
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:226)
    ... 17 more
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.type.TypeReference
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 20 more
26/01/2016 11:22:33.863 [ERROR] MainController.java:433 - Falha ao conectar com o banco de dados!

I'm totally lost where the error may be. Please, somebody can give some help, at least to understand what is happening.

Thank you very much.

    
asked by anonymous 26.01.2016 / 14:43

1 answer

1

Make sure the Jackson dependencies are included in your jar .

You can do this by opening the .jar of your project and checking to see if there is .jar of Jackson inside, if not, add and package again.

If you are using a dependency manager like Maven or Gradle, just add the dependency in the configuration files, pom.xml to maven and build.gradle to gradle.

    
09.03.2016 / 20:14