Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » java.lang.NoSuchMethodError: xxx._persistence_checkFetched(Ljava/lang/String;)V
java.lang.NoSuchMethodError: xxx._persistence_checkFetched(Ljava/lang/String;)V [message #701541] Mon, 25 July 2011 08:32 Go to next message
jj Missing name is currently offline jj Missing nameFriend
Messages: 9
Registered: February 2011
Junior Member
Error:
java.lang.NoSuchMethodError: com.Sales._persistence_checkFetched(Ljava/lang/String;)V
	at com.Sales._persistence_getOutlet(Sales.java)
	at com.Sales._persistence_setOutlet(Sales.java)
	at com.Sales.setOutlet(Sales.java:109)
	at com.SalesPersistenceTests.testSaveOutletWithItems(SalesPersistenceTests.java:58)



Code:
@Entity(name="Sales")
@Table(name="Sales")
public class Sales extends BaseEntity implements Serializable, DomainObject {

	private static final long serialVersionUID = 1L;
		
	@ManyToOne(targetEntity=Outlet.class, cascade=CascadeType.PERSIST)
	private Outlet outlet;
	
     public void setOutlet(Outlet outlet) {  this.Outlet = outlet; }
     public Outlet getOutlet() { return outlet; 	}
     ....
}   

@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; }
}


With JDK 1.6 within a Win7 environment.

The exception seems to be related to the use of the EclipseLink JPA 2 jars & the mappedSuperClass. If I substitute Hibernate jars the problems goes way. I'm happy Ive fixed (or hidden) the problem for myself but I suspect there is an underlying issue to address, assumming Ive made no blunder eleswhere Smile

Eclipselink: Get above exception.
org.eclipse.persistence: javax.persistence: 2.0.3
org.eclipse.persistence: eclipselink: 2.3.0

Hibernate: Runs Okay.
org.hibernate.java-persistence: jpa-api: 2.0-cr-1
org.hibernate: hibernate-entitymanager: 3.6.6.Final
Re: java.lang.NoSuchMethodError: xxx._persistence_checkFetched(Ljava/lang/String;)V [message #701762 is a reply to message #701541] Mon, 25 July 2011 14:54 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Hello,

The entity is being weaved for change tracking, but it looks like the mapped super class isn't. Is the mapped superclass BaseEntity listed as an entity in the persistence.xml?
If not, try adding it so it can be weaved as well.

If nothing else works, you can disable weaving as described here:
http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#Using_EclipseLink_JPA_Weaving

Best Regards,
Chris
(no subject) [message #701764 is a reply to message #701541] Mon, 25 July 2011 14:54 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
Hello,

The entity is being weaved for change tracking, but it looks like the mapped super class isn't. Is the mapped superclass BaseEntity listed as an entity in the persistence.xml?
If not, try adding it so it can be weaved as well.

If nothing else works, you can disable weaving as described here:
http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#Using_EclipseLink_JPA_Weaving

Best Regards,
Chris
Re: java.lang.NoSuchMethodError: xxx._persistence_checkFetched(Ljava/lang/String;)V [message #714132 is a reply to message #701762] Tue, 09 August 2011 21:24 Go to previous messageGo to next message
Scott Bishopp is currently offline Scott BishoppFriend
Messages: 2
Registered: August 2011
Junior Member
I found the same issue. When the weaver detected a @MappedSuperclass in the hierarchy it simple stops weaving. Therefore objects under the Mappedsuperclass get ignored. I found this by by decompiling some of the weaved code.

When you have a MappedSuperClass you WILL NOT see the
"return super._persistence_get(s)" call.


public Object _persistence_get(String s)
{
if(s == "authorizationContexts")
return authorizationContexts;
if(s == "primarySecurityContext")
return primarySecurityContext;
if(s == "lastName")
return lastName;
if(s == "lastLogin")
return lastLogin;
if(s == "email")
return email;
if(s == "userId")
return userId;
if(s == "adminFlag")
return adminFlag;
if(s == "firstName")
return firstName;
if(s == "password")
return password;
else
return super._persistence_get(s);
}
Re: java.lang.NoSuchMethodError: xxx._persistence_checkFetched(Ljava/lang/String;)V [message #714138 is a reply to message #714132] Tue, 09 August 2011 21:47 Go to previous message
Rolf Paulsen is currently offline Rolf PaulsenFriend
Messages: 14
Registered: June 2010
Junior Member
A MappedSuperClass also does not get weaved (woven?) if there is no entity subclass present during weaving.
A MappedSuperClass is not ignored for weaving if itself and a subclass entity are in the persistence.xml during weaving because the MappedSuperClass gets marked for weaving only if it is found in the superclass hierarchy of an entity. So if you have your base classes in one jar/project and your entities in another jar/project and you compile the first jar on its own, you must have a dummy entity in the first jar to enable weaving of the MappedSuperClass; both must be in a "weaving only" persistence.xml.

[Updated on: Tue, 09 August 2011 21:52]

Report message to a moderator

(no subject) [message #714144 is a reply to message #701764] Tue, 09 August 2011 21:24 Go to previous message
Scott Bishopp is currently offline Scott BishoppFriend
Messages: 2
Registered: August 2011
Junior Member
I found the same issue. When the weaver detected a @MappedSuperclass in the hierarchy it simple stops weaving. Therefore objects under the Mappedsuperclass get ignored. I found this by by decompiling some of the weaved code.

When you have a MappedSuperClass you WILL NOT see the
"return super._persistence_get(s)" call.


public Object _persistence_get(String s)
{
if(s == "authorizationContexts")
return authorizationContexts;
if(s == "primarySecurityContext")
return primarySecurityContext;
if(s == "lastName")
return lastName;
if(s == "lastLogin")
return lastLogin;
if(s == "email")
return email;
if(s == "userId")
return userId;
if(s == "adminFlag")
return adminFlag;
if(s == "firstName")
return firstName;
if(s == "password")
return password;
else
return super._persistence_get(s);
}
(no subject) [message #714145 is a reply to message #714132] Tue, 09 August 2011 21:47 Go to previous message
Rolf Paulsen is currently offline Rolf PaulsenFriend
Messages: 14
Registered: June 2010
Junior Member
A MappedSuperClass also does not get weaved (woven?) if there is no entity subclass present during weaving.
A MappedSuperClass is not ignored for weaving if it and a subclass entity are in the persistence.xml during weaving. So if you have your MappedSuperClass without any subclassed entity in one jar/project and your entities in another jar/project and you compile the first project on its own, you must have a dummy "weaving helper" entity in the first jar to enable weaving of the MappedSuperClass. This dummy entity should be excluded from the first jar and the "real application" persistence.xml.

See http://www.eclipse.org/forums/index.php/t/175165/

[Updated on: Tue, 09 August 2011 22:18]

Report message to a moderator

Previous Topic:JPA2: how access entity name for projection query
Next Topic:(no subject)
Goto Forum:
  


Current Time: Fri Apr 19 23:23:42 GMT 2024

Powered by FUDForum. Page generated in 0.03183 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top