java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil;

Hibernate JIRA | Vitaly Polonetsky | 6 years ago
  1. 0

    [HV-374] NoSuchMethodError on Persistence.getPersistenceUtil() on WebLogic 10.3.3 (11g) - Hibernate JIRA

    atlassian.net | 1 year ago
    java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil;
  2. 0

    The latest WebLogic comes with hybrid configuration of JPA 1.0 with some features of JPA 2.0: https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&doctype=FAQ&id=1091853.1 This causes a problem with the way Hibernate Validator checks for existence of JPA 2.0: org.hibernate.validator.engine.resolver.DefaultTraversableResolver.detectJPA() checks for existance of javax.persistence.PersistenceUtil class (which exists only in JPA 2.0), but org.hibernate.validator.engine.resolver.JPATraversableResolver will not use it directly, instead it will use javax.persistence.Persistence.getPersistenceUtil() (the class exists for JPA 1.0, but the method is available only at JPA 2.0). This check is good for situations where either full JPA 1.0 or full 2.0 implementation is available, but is cases like we have in WebLogic it leads to an Error: {code} java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil; at org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:62) at org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:94) at org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:47) at org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:757) at org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:324) at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForRedefinedDefaultGroup(ValidatorImpl.java:273) at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:256) at org.hibernate.validator.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:210) at org.hibernate.validator.engine.ValidatorImpl.validate(ValidatorImpl.java:119) ... {code} I would suggest a possible way to overcome this situation in Hibernate Validator: To check for existence of JPA 2.0, check the existence of Persistence.getPersistenceUtil() method, instead of checking for the existence of PersistenceUtil class. This will disable the use of JPA 2.0 features inside HV when the method is not available.

    Hibernate JIRA | 6 years ago | Vitaly Polonetsky
    java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil;
  3. 0

    The latest WebLogic comes with hybrid configuration of JPA 1.0 with some features of JPA 2.0: https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&doctype=FAQ&id=1091853.1 This causes a problem with the way Hibernate Validator checks for existence of JPA 2.0: org.hibernate.validator.engine.resolver.DefaultTraversableResolver.detectJPA() checks for existance of javax.persistence.PersistenceUtil class (which exists only in JPA 2.0), but org.hibernate.validator.engine.resolver.JPATraversableResolver will not use it directly, instead it will use javax.persistence.Persistence.getPersistenceUtil() (the class exists for JPA 1.0, but the method is available only at JPA 2.0). This check is good for situations where either full JPA 1.0 or full 2.0 implementation is available, but is cases like we have in WebLogic it leads to an Error: {code} java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil; at org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:62) at org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:94) at org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:47) at org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:757) at org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:324) at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForRedefinedDefaultGroup(ValidatorImpl.java:273) at org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:256) at org.hibernate.validator.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:210) at org.hibernate.validator.engine.ValidatorImpl.validate(ValidatorImpl.java:119) ... {code} I would suggest a possible way to overcome this situation in Hibernate Validator: To check for existence of JPA 2.0, check the existence of Persistence.getPersistenceUtil() method, instead of checking for the existence of PersistenceUtil class. This will disable the use of JPA 2.0 features inside HV when the method is not available.

    Hibernate JIRA | 6 years ago | Vitaly Polonetsky
    java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil;
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Saving works using Tomcat, jetty is giving me a java.lang.NoSuchMethodError for Persistence.getPersistenceUtil()

    Stack Overflow | 4 years ago | Blankman
    java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil;
  6. 0

    Spring MVC, Hibernate 3 and @Valid Problem

    Stack Overflow | 6 years ago | Lyndon
    java.lang.NoSuchMethodError: javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil;

    2 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NoSuchMethodError

      javax.persistence.Persistence.getPersistenceUtil()Ljavax/persistence/PersistenceUtil;

      at org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable()
    2. Embedded GlassFish Web
      SingleThreadCachedTraversableResolver.isReachable
      1. org.hibernate.validator.engine.resolver.JPATraversableResolver.isReachable(JPATraversableResolver.java:62)
      2. org.hibernate.validator.engine.resolver.DefaultTraversableResolver.isReachable(DefaultTraversableResolver.java:94)
      3. org.hibernate.validator.engine.resolver.SingleThreadCachedTraversableResolver.isReachable(SingleThreadCachedTraversableResolver.java:47)
      3 frames
    3. Vaadin
      ValidatorImpl.validate
      1. org.hibernate.validator.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:757)
      2. org.hibernate.validator.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:324)
      3. org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForRedefinedDefaultGroup(ValidatorImpl.java:273)
      4. org.hibernate.validator.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:256)
      5. org.hibernate.validator.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:210)
      6. org.hibernate.validator.engine.ValidatorImpl.validate(ValidatorImpl.java:119)
      6 frames