2 Replies Latest reply: Jan 16, 2011 8:22 PM by 612864 RSS

    OpenJPA_2.0 NoSuchMethod error (getValidationMode())

    826749
      Hi, i'm trying to use openJpa using NetBeans and Tomcat server but when I call these instructions in my simple Test Unit:

      emf = Persistence.createEntityManagerFactory("akros.evtmanager.pu");

      I get this error:

      javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
      java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;

      This is my persistence.xml file:

      <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
      <persistence-unit name="akros.evtmanager.pu" transaction-type="RESOURCE_LOCAL">
      <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
      <exclude-unlisted-classes>false</exclude-unlisted-classes>
      <properties>
      <property name="openjpa.ConnectionPassword" value="xxxxx"/>
      <property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
      <property name="openjpa.ConnectionUserName" value="root"/>
      <property name="openjpa.ConnectionURL" value="jdbc:mysql://giotto.dna:3307/akros_evtmanager"/>
      <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(SchemaAction=&apos;add,deleteTableContents&apos;,ForeignKeys=true)"/>
      </properties>
      </persistence-unit>
      </persistence>


      Does anyone can help me?

      Edited by: user13550594 on 27-dic-2010 1.33
        • 1. Re: OpenJPA_2.0 NoSuchMethod error (getValidationMode())
          612864
          Hi,
          The issue is that your persistence.xml schema is version 2.0 - not 1.0. It looks like your version of NetBeans supports JPA 2.0 since I assume that the persistence.xml was initially generated by it (since you are using the 2.0 schema but nothing in your persistence.xml requires anything beyond JPA 1.0 (IE: no cache-mode NONE)).
          The NoSuchMethodError is a direct result of your version of Tomcat running the 1.0 version of javax.persistence.jar.
          Either add the 2.0 version of javax.persistence.jar to Tomcat or use another catalina based servlet container like full JEE6 (JPA 2.0 included) compliant GlassFish V3 - that comes with NetBeans - you will then be fine predeploying/deploying/running your application managed WAR.
          Or just change the following XSD definition from 2.0 to 1.0 - as you don't need any design-time 2.0 (I don't know if you are using 2.0 runtime in your code though). You can still run JPA 2.0 API even if you define a JPA 1.0 schema.

          <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

          to
          <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">

          Also, in my other post I mentioned that EclipseLink JPA is an option - more so since you are running the JEE6 RI = GlassFish which runs the JPA 2.0 RI = EclipseLink.

          thank you
          /Michael O'Brien
          http://www.eclipselink.org
          • 2. Re: OpenJPA_2.0 NoSuchMethod error (getValidationMode())
            612864
            See the recent OTN post from 20110115 detailing the latest release of Oracle WebLogic Server and some retesting of the previous issues related to JSR-317 JPA 2.0 support below.
            Re: Deploy Hibernate based EAR file on Weblogic 10.3.3?

            In 10.3.3.0 you were required to use the FilteringClassLoader via the *<wls:prefer-application-packages>* addition to your application managed persistence unit - this workaround is now fully deprecated and not required in 10.3.4.0 for both application and container managed persistence contexts.
            As of 20110115 the 5 outstanding issues below look to be fixed by applying the http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309 patch for QWG8 or manually prepending to the WebLogic 10.3.4.0 server classpath.
            JPA 2.0 using EclipseLink as the persistence provider on WebLogic is detailed in the analysis section below
            1) JPA 2.0 XSD parsing
            2) New JPA 2.0 schema elements like <shared-cache-mode>NONE</shared-cache-mode>
            3) JPA 2.0 runtime API like a entityManager.getMetamodel(); call on the Servlet or Stateless session bean
            4) JPA 2.0 weaving/instrumentation - this will require a more detailed lazy model and more debugging to verify
            5) Dependency Injection of a container managed JPA 2.0 entityManager on a EJB component like a stateless session bean
            http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#Enabling_JPA2_support
            OTN download
            http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-main-097127.html
            Patching
            http://download.oracle.com/docs/cd/E18476_01/doc.220/e18480/weblogicchap.htm
            Documentation
            http://download.oracle.com/docs/cd/E17904_01/web.1111/e13852/toc.htm
            Supported Oracle WebLogic Server Versions
            http://download.oracle.com/docs/cd/E15315_06/help/oracle.eclipse.tools.weblogic.doc/html/SupportedServerVersions.html
            TopLink JPA 2.0 Specific
            http://download.oracle.com/docs/cd/E17904_01/web.1111/e13720/using_toplink.htm#EJBAD1309
            JPA 2.0 using EclipseLink on WebLogic analysis (XSD, Weaving, DI of @PersistenceContext)
            http://wiki.eclipse.org/EclipseLink/Development/JPA_2.0/weblogic#Enabling_JPA2_support

            thank you
            /Michael O'Brien
            http://www.eclipselink.org