Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoSuchMethodError with ManyToMany and ManyToOne

 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic