Why Jandex and Classmate Libraries Used in Hibernate 4.2 Core

Hibernate uses various third part dependencies internally to resolve the various problems. One of the dependency is Jandex (jandex-1.1.0.Final.jar) and Classmate (classmate-1.0.0) libraries which are not required for the hibernate’s core functionality. If you don’t add them to the libraries, you would get the below exceptions.

Jandex and Classmate are not required for the main Hibernate functionality. They are required for the metadata generation . In order to not break things for people that don’t use the metadata generation they added the dependencies as test dependencies. If you’re using the metadata generation you will need to obtain those dependencies.

Faster XML Classmate Maven Entry

<dependencies>
	<dependency>
		<groupId>com.fasterxml</groupId>
		<artifactId>classmate</artifactId>
		<version>1.0</version>
	</dependency>
</dependencies>

Exception Trace

Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/classmate/TypeResolver
	at org.hibernate.metamodel.source.annotations.AnnotationBindingContextImpl.<init>(AnnotationBindingContextImpl.java:53)
	at org.hibernate.metamodel.source.annotations.AnnotationMetadataSourceProcessorImpl.prepare(AnnotationMetadataSourceProcessorImpl.java:105)
	at org.hibernate.metamodel.source.internal.MetadataImpl.prepare(MetadataImpl.java:175)
	at org.hibernate.metamodel.source.internal.MetadataImpl.<init>(MetadataImpl.java:160)
	at org.hibernate.metamodel.source.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:123)
	at org.hibernate.metamodel.MetadataSources.buildMetadata(MetadataSources.java:151)
	at javabeat.net.hibernate.HibernateUtil.main(HibernateUtil.java:16)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.classmate.TypeResolver
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	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)

Jandex Maven Entry

<dependencies>
	<dependency>
		<groupId>org.jboss</groupId>
		<artifactId>jandex</artifactId>
		<version>1.1.0</version>
	</dependency>
</dependencies>

Exception Trace

Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/jandex/Indexer
	at org.hibernate.metamodel.source.annotations.AnnotationMetadataSourceProcessorImpl.prepare(AnnotationMetadataSourceProcessorImpl.java:78)
	at org.hibernate.metamodel.source.internal.MetadataImpl.prepare(MetadataImpl.java:175)
	at org.hibernate.metamodel.source.internal.MetadataImpl.<init>(MetadataImpl.java:160)
	at org.hibernate.metamodel.source.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:123)
	at org.hibernate.metamodel.MetadataSources.buildMetadata(MetadataSources.java:151)
	at javabeat.net.hibernate.HibernateUtil.main(HibernateUtil.java:16)
Caused by: java.lang.ClassNotFoundException: org.jboss.jandex.Indexer
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	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)

Comments

comments

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Speak Your Mind

*