File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()" Watch "java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()" New topic
Author

java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()

Indrayani Godbole
Greenhorn

Joined: Oct 09, 2012
Posts: 26
Hi,
I am using liferay server to run my web application.
So i am deploying my application's war on the tomcat that is bundled with liferay.

I am using jpa2 and my scenario is, there are 2 projects, one is web application and another is maven jar project

jar project handles all database related operations. jar's application context contains the entity manager settings.

the web application's application context xml has the jar's application context imported.

now when i deploy the web application, i am getting following error on console.


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [jar:file:/D:/for_work/EBCP_Liferay_soft/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/temp/1-EbcpAdminPortlet/WEB-INF/lib/ebcp-beans-1.0.jar!/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;


Please let me know in case of any solution.
have already spent a lot of time on this but no success.
checked few posts on net but still no success.
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1020
    
    5

A NoSuchMethodError usually indicates that you have compiled your code against a different version of a library than the version available at runtime.

What jar(s) are you using in your build for JPA? And what version is available on the application server?
Indrayani Godbole
Greenhorn

Joined: Oct 09, 2012
Posts: 26
following are the maven dependencies added for build for jpa

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.5.3-Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.5.3-Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.0.1.Final</version>
<scope>compile</scope>
</dependency>

same dependencies i am using for the web application war project
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1020
    
    5

What reading different articles, it doesn't look as if Liferay supports JPA out of the box.

May I suggest you try placing the necessary JPA jars in the endorsed libs directory for tomcat - in your case, this should be D:/for_work/EBCP_Liferay_soft/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/endorsed. You may need to created the endorsed directory beforehand.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41816
    
  62
James Boswell wrote:May I suggest you try placing the necessary JPA jars in the endorsed libs directory for tomcat - in your case, this should be D:/for_work/EBCP_Liferay_soft/liferay-portal-6.1.1-ce-ga2/tomcat-7.0.27/endorsed.

While this is worth a try, I think the problem may lie elsewhere. While I know nothing about Liferay, it sounds to me as if there is another, conflicting, version of JPA already present. Moving the one that's used with this web app into the endorsed directory would not necessarily resolve that conflict, as long as there is another incompatible version elsewhere.

What's not clear to me is with which other version it would be conflicting. The way Tomcat web apps usually work is that libraries that are inside of WEB-INF/lib take precedence over libraries that exist elsewhere in Tomcat's classloader hierarchy. So this conflicting version would have to exist far up the classloader hierarchy in order to cause problems - maybe even in one of the JRE directories? Or maybe as part of Liferay (as opposed to Tomcat)?


Ping & DNS - my free Android networking tools app
Indrayani Godbole
Greenhorn

Joined: Oct 09, 2012
Posts: 26
i added the endorsed folder in tomcat , after that i am getting a new exception :

java.lang.NoSuchMethodError: org.hibernate.mapping.PersistentClass.getSuperMappedSuperclass()

any idea about the cause?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()