Announcement Announcement Module
Collapse
No announcement yet.
Bizarre behaviour: java.lang.NoSuchMethodError: Person._persistence_checkFetched Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bizarre behaviour: java.lang.NoSuchMethodError: Person._persistence_checkFetched

    Exception:
    Code:
    java.lang.NoSuchMethodError: com.fred.Person._persistence_checkFetched(Ljava/lang/String;)V
    	at com.fred.entity.Person._persistence_getclient(Person.java)
    	at com.fred.entity.Person._persistence_setclient(Person.java)
    	at com.fred.entity.Person.setClient(Person.java:109)
    	at com.fred.entity.PersonPersistenceTests.testSaveClientWithItems(PersonPersistenceTests.java:58)
    I get the above exception when I run my maven unit tests but not when the application is deployed. I assume the error is associated with JPA & version management. The Spring configuration is identical.
    What is bizarre is that its not all my Entities, just some of them. And if I pull the code from the BaseEntity into the Entities (e.g. Person) and remove the 'extends BaseEntity' all the unit tests work. I assume the _persistence_xx methods are woven methods, so I am at a loss how to diagnose the problem. I've tried re-importing projects into clean workspace.

    Any ideas greatfully received.

    Code:
    @Entity(name="Person")
    @Table(name="PERSON")
    public class Person extends BaseEntity implements Serializable, DomainObject {
    
    	private static final long serialVersionUID = 1L;
    		
    	@ManyToOne(targetEntity=Client.class, cascade=CascadeType.PERSIST)
    	private Client client;
    	
         public void setClient(Client client) {
    		this.client = client;
    	}
        public Client getClient() {
    		return client;
    	}
        ....
    }   
    
    @MappedSuperclass
    public abstract class BaseEntity {
    
    	@Id
    	@GeneratedValue(strategy=GenerationType.AUTO)
    	private Long id;
    	
    	@Version
    	private Integer version;
    	
    	public void setId(long id) {
    		this.id = id;
    	}
    
    	public Long getId() {
    		return id;
    	}
    
    	public Integer getVersion() {
    		return version;
    	}
    
    	public void setVersion(Integer version) {
    		this.version = version;
    	}
    
    	public boolean isNew() {
    		return (this.id == null);
    	}
    
    }

  • #2
    The error you are seeing is caused by a JDK (Java Development Kit) version incompatibility. Errors like this occur when you compile a class with one version of the JDK, then run them with an older JVM (Java Virtual Machine).

    Gilberto

    Comment


    • #3
      Thanks for the feedback Gilbertoca, unfortunately I'm only using a single JDK 1.6.0_26 with compiler and execution environments pointing to the same. Currently I'm at a loss to understand what is going on. I sort of think I have some metadata hanging around somewhere but I've tried most of the rebuild strategies i can think of. I did have older 1.6 JREs which I removed - I wondering if something got corrupted in that process - some more investigation required.

      Comment


      • #4
        Update:

        At the moment I believe the problem has to do with EclipseLink + jpa 2, as If I replace Eclipselink with Hibernate the problem goes way - all other things remaining as before.

        Eclipselink:
        org.eclipse.persistence: javax.persistence: 2.0.3
        org.eclipse.persistence: eclipselink: 2.3.0

        Hibernate:
        org.hibernate.java-persistence: jpa-api: 2.0-cr-1
        org.hibernate: hibernate-entitymanager: 3.6.6.Final

        The only thing i can think of is a mismatched set of eclipse jars?

        Comment

        Working...
        X