aspose file tools*
The moose likes Object Relational Mapping and the fly likes NoSuchMethodError with ManyToMany and ManyToOne Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "NoSuchMethodError with ManyToMany and ManyToOne" Watch "NoSuchMethodError with ManyToMany and ManyToOne" New topic
Author

NoSuchMethodError with ManyToMany and ManyToOne

Mirko Bonasorte
Ranch Hand

Joined: May 14, 2007
Posts: 244
Greetings,

I'm using EJB 3 annotations with JBoss and I have a strange problem:
Suppose that I have two classes, A and B.
Suppose that I have a ManyToOne from A to B, bidirectional.
If I try to invoke A.getB(), I get a NoSuchMethodError.
So, I tried to check the methods of my class and results that getB() returns java.lang.String, and NOT B. So, using ejbQL, I can read this field, but as string ("select a.B from A a" -> List<String> .

The strange thing is that the A.getClass() method gives the correct class name and B.getAs() returns correctly a List<A>.




I get a similar problem when I create a many-to-many unidirectional from A to B: in this case, no such List<B> getB() method results in A, so that I get a NoSuchMethodError, as above.

Thanks a lot in advances!

P.S. I'm working with JBoss 4.2.0


SCJP<br />SCWCD 1.4 Upgrade (Remember: me stupid)<br />SCWCD 1.4<br /><a href="http://jcp.org/aboutJava/communityprocess/final/jsr220/index.html" target="_blank" rel="nofollow">SCBCD 5.0</a><br /><a href="http://www.enthuware.com" target="_blank" rel="nofollow">SCBCD 5.0 mock exam</a> <br /> <br />SCEA 5 Part1: Preparing...
Mirko Bonasorte
Ranch Hand

Joined: May 14, 2007
Posts: 244
Hi,
I've also tried with a simple OneToOne unidirectional.
The result is the same.

Watching the jboss logs, it seems that it completely ignores the getter method for the OneToOne.

Here it's the stuff:



In this situation, Ricetta.getPreparazione() invocation gives 'NoSuchMethodError'. Moreover, in JBoss logs, nothing is found about my 'preparazione' property.

Thanks a lot!
Mirko Bonasorte
Ranch Hand

Joined: May 14, 2007
Posts: 244
That's it!
The problem was that, for previous experiments, I had deployed an old version of my persistence unit, where my classes had no one-to-one/many-to-one.
Removing it, all went ok!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoSuchMethodError with ManyToMany and ManyToOne