I created 2 classes one Message.java with all annotation and it will be persisted.Other class HelloWorld.java which has main method and makes Use of Hibernate EntityManager.
As told in gavin king's book i didnt created a hibernate.cfg.xml for this, instead i created this file structure in classpath
META-INF/persistence.xml
but as expected code didn't run and showed these exceptions::
Code:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/spi/ProviderUtil
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at javax.persistence.Persistence.findAllProviders(Persistence.java:79)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
at hello.HelloWorld.main(HelloWorld.java:10)
Caused by: java.lang.ClassNotFoundException: javax.persistence.spi.ProviderUtil
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)
... 9 more
Please tell me what to do in order to make it work.