I am following http://spring.io/guides/tutorials/data/3 ; I am not sure what I did wrong, but I keep on getting exceptions that I don\'t understand. I tried searching for q
First, get the version of javassist
that works with Java 8:
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.2-GA</version>
</dependency>
If you use maven, exclude all others javassist
dependencies:
`<exclusions>
<exclusion>
<artifactId>javassist</artifactId>
<groupId>org.javassist</groupId>
</exclusion>
</exclusions>`
I had similar issue. My problem was that I had another dependency (in my case jboss weld) that used different version of javassist. Excluding did not help.
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-se</artifactId>
<version>1.0.1-Final</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>javassist</artifactId>
<groupId>org.javassist</groupId>
</exclusion>
</exclusions>
</dependency>
So, above exclusion does not work. I had to find a workaround for jboss weld.
The error:
invalid constant type: 18
Indicates that you have built the Jars with Java 8, but are attempting to run the application in a lower version.
From what I have seen elsewhere, you probably need to switch to a newer version of javassist (which is raising the error), as the version you are using is not compatible with Java 8.
If you use 3.6.10-Final you need exclude javassist (without org. prefix)
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.10.Final</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<artifactId>javassist</artifactId>
<groupId>javassist</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- javassist with fixed https://issues.jboss.org/browse/JASSIST-174 -->
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.2-GA</version>
</dependency>
I had the same problem while migrating one of my projects to Java 8. Fixed it by updating the hibernate-entitymanager artifact version from 4.2.0.Final to 4.3.8.Final.
You do not need to provide beans for EntityManagerFactory and EntityManager. Just provide a bean LocalContainerEntityManagerFactoryBean