2 Replies Latest reply on Jan 17, 2011 2:22 AM by obrienmi8

    OpenJPA_2.0 NoSuchMethod error (getValidationMode())

      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:

      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">
      <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)"/>

      Does anyone can help me?

      Edited by: user13550594 on 27-dic-2010 1.33
        • 1. Re: OpenJPA_2.0 NoSuchMethod error (getValidationMode())
          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">

          <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
          • 2. Re: OpenJPA_2.0 NoSuchMethod error (getValidationMode())
            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 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 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 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
            OTN download
            Supported Oracle WebLogic Server Versions
            TopLink JPA 2.0 Specific
            JPA 2.0 using EclipseLink on WebLogic analysis (XSD, Weaving, DI of @PersistenceContext)

            thank you
            /Michael O'Brien